mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-29 19:17:28 +08:00
Coverity fixes (#2074)
This commit is contained in:
committed by
GitHub
parent
b61dba70ac
commit
e759df8208
@@ -105,7 +105,7 @@ static uint64_t vn_get_time_of_week(void)
|
|||||||
localtime_r(&curTime.tv_sec, &t_res);
|
localtime_r(&curTime.tv_sec, &t_res);
|
||||||
struct tm *tt = &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 * 1000; // tow to ms
|
||||||
tow = tow + milli; // tow with added ms
|
tow = tow + milli; // tow with added ms
|
||||||
tow = tow * 1e6; // tow in nanoseconds
|
tow = tow * 1e6; // tow in nanoseconds
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ void *nps_ap_data_loop(void *data __attribute__((unused)))
|
|||||||
|
|
||||||
struct pprz_transport pprz_tp_logger;
|
struct pprz_transport pprz_tp_logger;
|
||||||
|
|
||||||
|
pprz_transport_init(&pprz_tp_logger);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
// receive messages from the autopilot
|
// receive messages from the autopilot
|
||||||
rdlen = read(fd, buf, sizeof(buf) - 1);
|
rdlen = read(fd, buf, sizeof(buf) - 1);
|
||||||
@@ -256,6 +258,10 @@ void *nps_ap_data_loop(void *data __attribute__((unused)))
|
|||||||
case DL_MOTOR_MIXING:
|
case DL_MOTOR_MIXING:
|
||||||
// parse actuarors message
|
// parse actuarors message
|
||||||
cmd_len = DL_MOTOR_MIXING_values_length(buf);
|
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));
|
memcpy(&cmd_buf, DL_MOTOR_MIXING_values(buf), cmd_len * sizeof(int16_t));
|
||||||
pthread_mutex_lock(&fdm_mutex);
|
pthread_mutex_lock(&fdm_mutex);
|
||||||
// update commands
|
// update commands
|
||||||
|
|||||||
Reference in New Issue
Block a user