From ecfba8db1149ba8950016d30370569e5f0075090 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 8 Jul 2022 16:12:11 +0000 Subject: [PATCH] Use AID_MIN instead of 0 == AID_UNSPEC as foo loop start value where apropriate OK tb@ --- usr.sbin/bgpctl/output.c | 8 ++++---- usr.sbin/bgpctl/output_json.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index 3a8e38bb74e..db6796b89a8 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.23 2022/06/27 13:27:38 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.24 2022/07/08 16:12:11 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -138,7 +138,7 @@ show_neighbor_capa_mp(struct capabilities *capa) uint8_t i; printf(" Multiprotocol extensions: "); - for (i = 0, comma = 0; i < AID_MAX; i++) + for (i = AID_MIN, comma = 0; i < AID_MAX; i++) if (capa->mp[i]) { printf("%s%s", comma ? ", " : "", aid2str(i)); comma = 1; @@ -154,7 +154,7 @@ show_neighbor_capa_add_path(struct capabilities *capa) uint8_t i; printf(" Add-path: "); - for (i = 0, comma = 0; i < AID_MAX; i++) { + for (i = AID_MIN, comma = 0; i < AID_MAX; i++) { switch (capa->add_path[i]) { case 0: default: @@ -183,7 +183,7 @@ show_neighbor_capa_restart(struct capabilities *capa) printf(" Graceful Restart"); if (capa->grestart.timeout) printf(": Timeout: %d, ", capa->grestart.timeout); - for (i = 0, comma = 0; i < AID_MAX; i++) + for (i = AID_MIN, comma = 0; i < AID_MAX; i++) if (capa->grestart.flags[i] & CAPA_GR_PRESENT) { if (!comma && capa->grestart.flags[i] & CAPA_GR_RESTART) diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 7037dfd768b..8bc01381db7 100644 --- a/usr.sbin/bgpctl/output_json.c +++ b/usr.sbin/bgpctl/output_json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_json.c,v 1.18 2022/07/07 12:17:57 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.19 2022/07/08 16:12:11 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -43,7 +43,7 @@ json_neighbor_capabilities(struct capabilities *capa) int hascapamp = 0, hascapaap = 0; uint8_t i; - for (i = 0; i < AID_MAX; i++) { + for (i = AID_MIN; i < AID_MAX; i++) { if (capa->mp[i]) hascapamp = 1; if (capa->add_path[i]) @@ -60,7 +60,7 @@ json_neighbor_capabilities(struct capabilities *capa) if (hascapamp) { json_do_array("multiprotocol"); - for (i = 0; i < AID_MAX; i++) + for (i = AID_MIN; i < AID_MAX; i++) if (capa->mp[i]) json_do_printf("mp", "%s", aid2str(i)); json_do_end(); @@ -68,7 +68,7 @@ json_neighbor_capabilities(struct capabilities *capa) if (capa->grestart.restart) { int restarted = 0, present = 0; - for (i = 0; i < AID_MAX; i++) + for (i = AID_MIN; i < AID_MAX; i++) if (capa->grestart.flags[i] & CAPA_GR_PRESENT) { present = 1; if (capa->grestart.flags[i] & CAPA_GR_RESTART) @@ -84,7 +84,7 @@ json_neighbor_capabilities(struct capabilities *capa) if (present) { json_do_array("protocols"); - for (i = 0; i < AID_MAX; i++) + for (i = AID_MIN; i < AID_MAX; i++) if (capa->grestart.flags[i] & CAPA_GR_PRESENT) { json_do_object("family"); json_do_printf("family", "%s", @@ -101,7 +101,7 @@ json_neighbor_capabilities(struct capabilities *capa) } if (hascapaap) { json_do_array("add-path"); - for (i = 0; i < AID_MAX; i++) + for (i = AID_MIN; i < AID_MAX; i++) if (capa->add_path[i]) { json_do_object("add-path-elm"); json_do_printf("family", "%s", aid2str(i)); -- 2.20.1