Use AID_MIN instead of 0 == AID_UNSPEC as foo loop start value where apropriate
authorclaudio <claudio@openbsd.org>
Fri, 8 Jul 2022 16:12:11 +0000 (16:12 +0000)
committerclaudio <claudio@openbsd.org>
Fri, 8 Jul 2022 16:12:11 +0000 (16:12 +0000)
OK tb@

usr.sbin/bgpctl/output.c
usr.sbin/bgpctl/output_json.c

index 3a8e38b..db6796b 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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)
index 7037dfd..8bc0138 100644 (file)
@@ -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 <claudio@openbsd.org>
@@ -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));