ospfd: Fix compile warning with -Wformat-truncation

ospfd/ospf_sr.c: In function ‘show_sr_node.part.5’:
ospfd/ospf_sr.c:2745:32: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]
    snprintf(tmp, sizeof(tmp), "%u", i);
                                ^~
ospfd/ospf_sr.c:2745:31: note: directive argument in the range [0, 2147483646]
    snprintf(tmp, sizeof(tmp), "%u", i);

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2024-04-13 22:41:43 +03:00
parent 50e85abc25
commit f003ccf16b

View File

@ -2740,9 +2740,9 @@ static void show_sr_node(struct vty *vty, struct json_object *json,
if (srn->algo[i] == SR_ALGORITHM_UNSET)
continue;
json_obj = json_object_new_object();
char tmp[2];
char tmp[12];
snprintf(tmp, sizeof(tmp), "%u", i);
snprintf(tmp, sizeof(tmp), "%d", i);
json_object_string_add(json_obj, tmp,
srn->algo[i] == SR_ALGORITHM_SPF
? "SPF"