Replace a lot of memset with {} initializers

This commit is contained in:
Matthias Grob
2019-10-15 10:01:03 -04:00
committed by Daniel Agar
parent b8f70e865c
commit e843090383
12 changed files with 35 additions and 80 deletions
@@ -643,8 +643,7 @@ calibrate_return read_accelerometer_avg(int sensor_correction_sub, int (&subs)[m
}
unsigned counts[max_accel_sens] = { 0 };
float accel_sum[max_accel_sens][3];
memset(accel_sum, 0, sizeof(accel_sum));
float accel_sum[max_accel_sens][3] {};
unsigned errcount = 0;
struct sensor_correction_s sensor_correction; /**< sensor thermal corrections */
+6 -9
View File
@@ -120,23 +120,20 @@ bool is_ground_rover(const struct vehicle_status_s *current_status)
return current_status->system_type == VEHICLE_TYPE_GROUND_ROVER;
}
static hrt_abstime blink_msg_end = 0; // end time for currently blinking LED message, 0 if no blink message
static hrt_abstime tune_end = 0; // end time of currently played tune, 0 for repeating tunes or silence
static int tune_current = TONE_STOP_TUNE; // currently playing tune, can be interrupted after tune_end
static unsigned int tune_durations[TONE_NUMBER_OF_TUNES];
static hrt_abstime blink_msg_end = 0; // end time for currently blinking LED message, 0 if no blink message
static hrt_abstime tune_end = 0; // end time of currently played tune, 0 for repeating tunes or silence
static int tune_current = TONE_STOP_TUNE; // currently playing tune, can be interrupted after tune_end
static unsigned int tune_durations[TONE_NUMBER_OF_TUNES] {};
static DevHandle h_leds;
static DevHandle h_buzzer;
static led_control_s led_control = {};
static led_control_s led_control {};
static orb_advert_t led_control_pub = nullptr;
static tune_control_s tune_control = {};
static tune_control_s tune_control {};
static orb_advert_t tune_control_pub = nullptr;
int buzzer_init()
{
tune_end = 0;
tune_current = 0;
memset(tune_durations, 0, sizeof(tune_durations));
tune_durations[TONE_NOTIFY_POSITIVE_TUNE] = 800000;
tune_durations[TONE_NOTIFY_NEGATIVE_TUNE] = 900000;
tune_durations[TONE_NOTIFY_NEUTRAL_TUNE] = 500000;
+1 -4
View File
@@ -82,12 +82,9 @@ static calibrate_return gyro_calibration_worker(int cancel_sub, void *data)
sensor_gyro_s gyro_report;
unsigned poll_errcount = 0;
struct sensor_correction_s sensor_correction; /**< sensor thermal corrections */
struct sensor_correction_s sensor_correction {}; /**< sensor thermal corrections */
if (orb_copy(ORB_ID(sensor_correction), worker_data->sensor_correction_sub, &sensor_correction) != 0) {
/* use default values */
memset(&sensor_correction, 0, sizeof(sensor_correction));
for (unsigned i = 0; i < 3; i++) {
sensor_correction.gyro_scale_0[i] = 1.0f;
sensor_correction.gyro_scale_1[i] = 1.0f;