Coverity fixes (#2074)

This commit is contained in:
Michal Podhradsky
2017-06-07 18:34:56 -07:00
committed by GitHub
parent b61dba70ac
commit e759df8208
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ static uint64_t vn_get_time_of_week(void)
localtime_r(&curTime.tv_sec, &t_res);
struct tm *tt = &t_res;
uint64_t tow = GPS_SEC_IN_DAY * tt->tm_wday + 3600 * tt->tm_hour + 60 * tt->tm_min + tt->tm_sec; // sec
uint64_t tow = (uint64_t)GPS_SEC_IN_DAY * tt->tm_wday + (uint64_t)3600 * tt->tm_hour + (uint64_t)60 * tt->tm_min + tt->tm_sec; // sec
tow = tow * 1000; // tow to ms
tow = tow + milli; // tow with added ms
tow = tow * 1e6; // tow in nanoseconds
+6
View File
@@ -213,6 +213,8 @@ void *nps_ap_data_loop(void *data __attribute__((unused)))
struct pprz_transport pprz_tp_logger;
pprz_transport_init(&pprz_tp_logger);
while (TRUE) {
// receive messages from the autopilot
rdlen = read(fd, buf, sizeof(buf) - 1);
@@ -256,6 +258,10 @@ void *nps_ap_data_loop(void *data __attribute__((unused)))
case DL_MOTOR_MIXING:
// parse actuarors message
cmd_len = DL_MOTOR_MIXING_values_length(buf);
// check for out-of-bounds access
if (cmd_len > NPS_COMMANDS_NB) {
cmd_len = NPS_COMMANDS_NB;
}
memcpy(&cmd_buf, DL_MOTOR_MIXING_values(buf), cmd_len * sizeof(int16_t));
pthread_mutex_lock(&fdm_mutex);
// update commands