From 2e9223daaeac73d19e1c349662040d84089836c6 Mon Sep 17 00:00:00 2001 From: Scheiffler Date: Fri, 6 Oct 2023 10:11:14 -0500 Subject: [PATCH] Fix snprintf bugs in MAX32665 ADC example --- Examples/MAX32665/ADC/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/MAX32665/ADC/main.c b/Examples/MAX32665/ADC/main.c index d8147e7fba..a6886a8738 100644 --- a/Examples/MAX32665/ADC/main.c +++ b/Examples/MAX32665/ADC/main.c @@ -146,20 +146,20 @@ int main(void) overflow[3] = (MXC_ADC_GetData(&adc_val[3]) == E_OVERFLOW ? 1 : 0); /* Display results on OLED display, display asterisk if overflow */ - snprintf((char *)fmtstr, sizeof((char *)fmtstr), "0: 0x%04x%s 2: 0x%04x%s", adc_val[0], + snprintf((char *)fmtstr, sizeof(fmtstr), "0: 0x%04x%s 2: 0x%04x%s", adc_val[0], overflow[0] ? "*" : " ", adc_val[2], overflow[2] ? "*" : " "); printf("%s\n", fmtstr); - snprintf((char *)fmtstr, sizeof((char *)fmtstr), "1: 0x%04x%s 3: 0x%04x%s", adc_val[1], + snprintf((char *)fmtstr, sizeof(fmtstr), "1: 0x%04x%s 3: 0x%04x%s", adc_val[1], overflow[1] ? "*" : " ", adc_val[3], overflow[3] ? "*" : " "); printf("%s\n", fmtstr); /* Determine if programmable limits on AIN1 were exceeded */ if (MXC_ADC_GetFlags() & (MXC_F_ADC_INTR_LO_LIMIT_IF | MXC_F_ADC_INTR_HI_LIMIT_IF)) { - snprintf((char *)fmtstr, sizeof((char *)fmtstr), " %s Limit on AIN0 ", + snprintf((char *)fmtstr, sizeof(fmtstr), " %s Limit on AIN0 ", (MXC_ADC_GetFlags() & MXC_F_ADC_INTR_LO_LIMIT_IF) ? "Low" : "High"); MXC_ADC_ClearFlags(MXC_F_ADC_INTR_LO_LIMIT_IF | MXC_F_ADC_INTR_HI_LIMIT_IF); } else { - snprintf((char *)fmtstr, sizeof((char *)fmtstr), " "); + snprintf((char *)fmtstr, sizeof(fmtstr), " "); } printf("%s\n", fmtstr);