From 5e25642ba7ddb2aab0b81dd54dc0c23f3411fb9b Mon Sep 17 00:00:00 2001 From: "Francisco J. Solis" Date: Sat, 2 Jul 2022 19:05:06 -0500 Subject: [PATCH] fix: fix comparison types by casting A cast was introduced to fix comparison types. Now, both sides of the inequality contain signed types and issue #369 should be solved. --- lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib.c b/lib.c index 81fe64b..12662ae 100644 --- a/lib.c +++ b/lib.c @@ -572,13 +572,13 @@ static int snprintf_error_data(char *buf, size_t len, uint8_t err, if (count){ /* Fix for potential buffer overflow https://lgtm.com/rules/1505913226124/ */ tmp_n = snprintf(buf + n, len - n, ","); - if (tmp_n < 0 || tmp_n >= len - n){ + if (tmp_n < 0 || tmp_n >= (int)len - n){ return n; } n += tmp_n; } tmp_n = snprintf(buf + n, len - n, "%s", arr[i]); - if (tmp_n < 0 || tmp_n >= len - n){ + if (tmp_n < 0 || tmp_n >= (int)len - n){ return n; } n += tmp_n; @@ -658,13 +658,13 @@ void snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *c if (classes){ /* Fix for potential buffer overflow https://lgtm.com/rules/1505913226124/ */ tmp_n = snprintf(buf + n, len - n, "%s", sep); - if (tmp_n < 0 || tmp_n >= len - n){ + if (tmp_n < 0 || tmp_n >= (int)len - n){ return; } n += tmp_n; } tmp_n = snprintf(buf + n, len - n, "%s", error_classes[i]); - if (tmp_n < 0 || tmp_n >= len - n){ + if (tmp_n < 0 || tmp_n >= (int)len - n){ return; } n += tmp_n;