From aa5386f1cbd710df08a356e850de7583267d622a Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Thu, 2 Apr 2020 10:57:43 +0200 Subject: [PATCH] canfdtest: print_frame(): add missing cast to uint8_t to avoid overruns While there, use cast in compare_frame(), too. Signed-off-by: Marc Kleine-Budde --- canfdtest.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/canfdtest.c b/canfdtest.c index 366ab08..8828504 100644 --- a/canfdtest.c +++ b/canfdtest.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -86,7 +87,7 @@ static void print_frame(const struct can_frame *frame, int inc) } else { printf("[%d]", frame->can_dlc); for (i = 0; i < frame->can_dlc; i++) - printf(" %02x", frame->data[i] + inc); + printf(" %02x", (uint8_t)(frame->data[i] + inc)); } printf("\n"); } @@ -113,7 +114,7 @@ static void compare_frame(struct can_frame *exp, struct can_frame *rec, int inc) running = 0; } else { for (i = 0; i < rec->can_dlc; i++) { - if (rec->data[i] != ((exp->data[i] + inc) & 0xff)) { + if (rec->data[i] != (uint8_t)(exp->data[i] + inc)) { printf("Databyte %x mismatch!\n", i); print_compare(exp, rec, inc);