ao_log: Add casts to reduce -Wconversion warnings
authorKeith Packard <keithp@keithp.com>
Fri, 28 Jan 2022 23:12:47 +0000 (15:12 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 01:26:49 +0000 (17:26 -0800)
No bugs noted here.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_log_fireone.c
src/kernel/ao_log_micro.c

index b3515c7edeb7af04198573ca99b71f92d707d5d7..fcf86c542706ac2b2b64d6441e600816408b7ed3 100644 (file)
@@ -89,8 +89,8 @@ ao_log(void)
                        while (ao_fireone_data_pos != ao_data_head) {
                                ao_fireone_data.tick = (uint16_t) ao_data_ring[ao_fireone_data_pos].tick;
                                ao_fireone_data.type = AO_LOG_SENSOR;
-                               ao_fireone_data.u.sensor.pressure = ao_data_ring[ao_fireone_data_pos].adc.pressure;
-                               ao_fireone_data.u.sensor.thrust = ao_data_ring[ao_fireone_data_pos].adc.thrust;
+                               ao_fireone_data.u.sensor.pressure = (uint16_t) ao_data_ring[ao_fireone_data_pos].adc.pressure;
+                               ao_fireone_data.u.sensor.thrust = (uint16_t) ao_data_ring[ao_fireone_data_pos].adc.thrust;
        //                      for (i = 0; i < 4; i++) {
        //                              ao_fireone_data.u.sensor.thermistor[i] = ao_data_ring[ao_fireone_data_pos].sensor.thermistor[i];
        //                      }
index 1cb03715b23eb284573e5e5ba6e22ff1e7c90b8d..cfc0bcfd76ced85de0e99e28ef10d4634f96d50f 100644 (file)
@@ -52,7 +52,7 @@ ao_log_micro_restore(void)
 void
 ao_log_micro_data(void)
 {
-       uint16_t        low_bits = pa;
+       uint16_t        low_bits = (uint16_t) pa;
 
        if (ao_log_offset < MAX_LOG_OFFSET) {
                ao_eeprom_write(ao_log_offset, &low_bits, sizeof (low_bits));
@@ -81,9 +81,9 @@ static void
 ao_log_hex_nibble(uint8_t b)
 {
        if (b < 10)
-               ao_async_byte('0' + b);
+               ao_async_byte((uint8_t) ('0' + b));
        else
-               ao_async_byte('a' - 10 + b);
+               ao_async_byte((uint8_t) ('a' - 10 + b));
 }
 
 void
@@ -115,7 +115,7 @@ ao_log_micro_dump(void)
 
        if (n_samples == (N_SAMPLES_TYPE) (~0))
                n_samples = 0;
-       nbytes = STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples;
+       nbytes = (uint16_t) (STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples);
 
        /*
         * Rewrite n_samples so that it includes the log ID value with
@@ -140,7 +140,7 @@ ao_log_micro_dump(void)
                ao_eeprom_read(b, &byte, 1);
 #if AO_LOG_ID
                if (N_SAMPLES_OFFSET <= b && b < (N_SAMPLES_OFFSET + sizeof(n_samples))) {
-                       byte = n_samples >> ((b - N_SAMPLES_OFFSET) << 3);
+                       byte = (uint8_t) (n_samples >> ((b - N_SAMPLES_OFFSET) << 3));
                }
 #endif
                ao_log_hex(byte);
@@ -148,8 +148,8 @@ ao_log_micro_dump(void)
        }
        ao_log_newline();
        crc = ~crc;
-       ao_log_hex(crc >> 8);
-       ao_log_hex(crc);
+       ao_log_hex((uint8_t) (crc >> 8));
+       ao_log_hex((uint8_t) crc);
        ao_log_newline();
        ao_async_stop();
 }