mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
fix for issue #369
adding cast preventing int/unsigned comparison (-Wsign-compare warning in lib.c)
This commit is contained in:
@@ -572,13 +572,13 @@ static int snprintf_error_data(char *buf, size_t len, uint8_t err,
|
|||||||
if (count){
|
if (count){
|
||||||
/* Fix for potential buffer overflow https://lgtm.com/rules/1505913226124/ */
|
/* Fix for potential buffer overflow https://lgtm.com/rules/1505913226124/ */
|
||||||
tmp_n = snprintf(buf + n, len - n, ",");
|
tmp_n = snprintf(buf + n, len - n, ",");
|
||||||
if (tmp_n < 0 || tmp_n >= len - n){
|
if (tmp_n < 0 || (size_t)tmp_n >= len - n){
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
n += tmp_n;
|
n += tmp_n;
|
||||||
}
|
}
|
||||||
tmp_n = snprintf(buf + n, len - n, "%s", arr[i]);
|
tmp_n = snprintf(buf + n, len - n, "%s", arr[i]);
|
||||||
if (tmp_n < 0 || tmp_n >= len - n){
|
if (tmp_n < 0 || (size_t)tmp_n >= len - n){
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
n += tmp_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){
|
if (classes){
|
||||||
/* Fix for potential buffer overflow https://lgtm.com/rules/1505913226124/ */
|
/* Fix for potential buffer overflow https://lgtm.com/rules/1505913226124/ */
|
||||||
tmp_n = snprintf(buf + n, len - n, "%s", sep);
|
tmp_n = snprintf(buf + n, len - n, "%s", sep);
|
||||||
if (tmp_n < 0 || tmp_n >= len - n){
|
if (tmp_n < 0 || (size_t)tmp_n >= len - n){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n += tmp_n;
|
n += tmp_n;
|
||||||
}
|
}
|
||||||
tmp_n = snprintf(buf + n, len - n, "%s", error_classes[i]);
|
tmp_n = snprintf(buf + n, len - n, "%s", error_classes[i]);
|
||||||
if (tmp_n < 0 || tmp_n >= len - n){
|
if (tmp_n < 0 || (size_t)tmp_n >= len - n){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n += tmp_n;
|
n += tmp_n;
|
||||||
|
|||||||
Reference in New Issue
Block a user