From b123c095384b57446d45d8678dff5448a7c659e4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 28 Jan 2022 15:12:47 -0800 Subject: [PATCH] ao_log: Add casts to reduce -Wconversion warnings No bugs noted here. Signed-off-by: Keith Packard --- src/kernel/ao_log_fireone.c | 4 ++-- src/kernel/ao_log_micro.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/kernel/ao_log_fireone.c b/src/kernel/ao_log_fireone.c index b3515c7e..fcf86c54 100644 --- a/src/kernel/ao_log_fireone.c +++ b/src/kernel/ao_log_fireone.c @@ -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]; // } diff --git a/src/kernel/ao_log_micro.c b/src/kernel/ao_log_micro.c index 1cb03715..cfc0bcfd 100644 --- a/src/kernel/ao_log_micro.c +++ b/src/kernel/ao_log_micro.c @@ -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(); } -- 2.30.2