]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: using argv as a string name is categorically wrong
authorDonald Sharp <sharpd@nvidia.com>
Tue, 22 Jun 2021 16:44:24 +0000 (12:44 -0400)
committermergify-bot <noreply@mergify.io>
Sun, 25 Jul 2021 12:44:04 +0000 (12:44 +0000)
We are passing around the system id using the variable name
of `argv`.  Let's name the variable correctly and pass it around
correctly named.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 1d88e63a4e3d29cec6f49602e3263f13a8de3d1e)

isisd/isis_vty_fabricd.c
isisd/isisd.c
isisd/isisd.h

index a19fcc240f5a911a48e9a31fac26014bd6e544a0..2c1b6e932fed8feebf70cd42b2cd8a773afc6a5c 100644 (file)
@@ -187,7 +187,7 @@ DEFUN (show_lsp_flooding,
                vty_out(vty, "Area %s:\n",
                        area->area_tag ? area->area_tag : "null");
                if (lspid) {
-                       lsp = lsp_for_arg(head, lspid, isis);
+                       lsp = lsp_for_sysid(head, lspid, isis);
                        if (lsp)
                                lsp_print_flooding(vty, lsp, isis);
                        continue;
index 133486cf95609a9eb0810f6d3ff76db6bf299187..43efa0164daf5fecb801e90c45e268c0d941773c 100644 (file)
@@ -2154,8 +2154,8 @@ DEFUN(show_isis_summary, show_isis_summary_cmd,
        return CMD_SUCCESS;
 }
 
-struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv,
-                            struct isis *isis)
+struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str,
+                              struct isis *isis)
 {
        char sysid[255] = {0};
        uint8_t number[3] = {0};
@@ -2164,11 +2164,11 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv,
        struct isis_dynhn *dynhn;
        struct isis_lsp *lsp = NULL;
 
-       if (!argv)
+       if (!sysid_str)
                return NULL;
 
        /*
-        * extract fragment and pseudo id from the string argv
+        * extract fragment and pseudo id from the string sysid_str
         * in the forms:
         * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
         * (b) <systemid/hostname>.<pseudo-id> or
@@ -2176,10 +2176,10 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv,
         * Where systemid is in the form:
         * xxxx.xxxx.xxxx
         */
-       strlcpy(sysid, argv, sizeof(sysid));
+       strlcpy(sysid, sysid_str, sizeof(sysid));
 
-       if (strlen(argv) > 3) {
-               pos = argv + strlen(argv) - 3;
+       if (strlen(sysid_str) > 3) {
+               pos = sysid_str + strlen(sysid_str) - 3;
                if (strncmp(pos, "-", 1) == 0) {
                        memcpy(number, ++pos, 2);
                        lspid[ISIS_SYS_ID_LEN + 1] =
@@ -2192,14 +2192,13 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv,
                        memcpy(number, ++pos, 2);
                        lspid[ISIS_SYS_ID_LEN] =
                                (uint8_t)strtol((char *)number, NULL, 16);
-                       sysid[pos - argv - 1] = '\0';
+                       sysid[pos - sysid_str - 1] = '\0';
                }
        }
 
        /*
-        * Try to find the lsp-id if the argv
-        * string is in
-        * the form
+        * Try to find the lsp-id if the sysid_str
+        * is in the form
         * hostname.<pseudo-id>-<fragment>
         */
        if (sysid2buff(lspid, sysid)) {
@@ -2217,15 +2216,15 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv,
 
 void show_isis_database_lspdb(struct vty *vty, struct isis_area *area,
                              int level, struct lspdb_head *lspdb,
-                             const char *argv, int ui_level)
+                             const char *sysid_str, int ui_level)
 {
        struct isis_lsp *lsp;
        int lsp_count;
 
        if (lspdb_count(lspdb) > 0) {
-               lsp = lsp_for_arg(lspdb, argv, area->isis);
+               lsp = lsp_for_sysid(lspdb, sysid_str, area->isis);
 
-               if (lsp != NULL || argv == NULL) {
+               if (lsp != NULL || sysid_str == NULL) {
                        vty_out(vty, "IS-IS Level-%d link-state database:\n",
                                level + 1);
 
@@ -2241,7 +2240,7 @@ void show_isis_database_lspdb(struct vty *vty, struct isis_area *area,
                        else
                                lsp_print(lsp, vty, area->dynhostname,
                                          area->isis);
-               } else if (argv == NULL) {
+               } else if (sysid_str == NULL) {
                        lsp_count =
                                lsp_print_all(vty, lspdb, ui_level,
                                              area->dynhostname, area->isis);
@@ -2251,7 +2250,7 @@ void show_isis_database_lspdb(struct vty *vty, struct isis_area *area,
        }
 }
 
-static void show_isis_database_common(struct vty *vty, const char *argv,
+static void show_isis_database_common(struct vty *vty, const char *sysid_str,
                                      int ui_level, struct isis *isis)
 {
        struct listnode *node;
@@ -2267,7 +2266,7 @@ static void show_isis_database_common(struct vty *vty, const char *argv,
 
                for (level = 0; level < ISIS_LEVELS; level++)
                        show_isis_database_lspdb(vty, area, level,
-                                                &area->lspdb[level], argv,
+                                                &area->lspdb[level], sysid_str,
                                                 ui_level);
        }
 }
@@ -2287,8 +2286,8 @@ static void show_isis_database_common(struct vty *vty, const char *argv,
  * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
  * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
  */
-static int show_isis_database(struct vty *vty, const char *argv, int ui_level,
-                             const char *vrf_name, bool all_vrf)
+static int show_isis_database(struct vty *vty, const char *sysid_str,
+                             int ui_level, const char *vrf_name, bool all_vrf)
 {
        struct listnode *node;
        struct isis *isis;
@@ -2296,14 +2295,15 @@ static int show_isis_database(struct vty *vty, const char *argv, int ui_level,
        if (vrf_name) {
                if (all_vrf) {
                        for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
-                               show_isis_database_common(vty, argv, ui_level,
-                                                         isis);
+                               show_isis_database_common(vty, sysid_str,
+                                                         ui_level, isis);
 
                        return CMD_SUCCESS;
                }
                isis = isis_lookup_by_vrfname(vrf_name);
                if (isis)
-                       show_isis_database_common(vty, argv, ui_level, isis);
+                       show_isis_database_common(vty, sysid_str, ui_level,
+                                                 isis);
        }
 
        return CMD_SUCCESS;
index f815969b92936ca3c97181e50f08ffa7760ff785..64fbf78a07377a51e73c7642b042c0fe9d2727d0 100644 (file)
@@ -273,8 +273,8 @@ void isis_area_destroy(struct isis_area *area);
 void isis_filter_update(struct access_list *access);
 void isis_prefix_list_update(struct prefix_list *plist);
 void print_debug(struct vty *, int, int);
-struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv,
-                            struct isis *isis);
+struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str,
+                              struct isis *isis);
 
 void isis_area_invalidate_routes(struct isis_area *area, int levels);
 void isis_area_verify_routes(struct isis_area *area);