]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
Add warning message when MAX_FIELDS reached
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 30 Jun 2008 18:57:13 +0000 (11:57 -0700)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 30 Jun 2008 18:57:13 +0000 (11:57 -0700)
Don't just silently drop.

misc/lnstat.c

index b04e6cebfdf7b0733c14bafa9db6aabf62fa21cb..32ab6a488dd3d808cea166542efb3df00de16dd4 100644 (file)
@@ -122,8 +122,13 @@ static int map_field_params(struct lnstat_file *lnstat_files,
                                        fps->params[j].print.width =
                                                        FIELD_WIDTH_DEFAULT;
                                
-                               if (++j >= MAX_FIELDS - 1)
+                               if (++j >= MAX_FIELDS - 1) {
+                                       fprintf(stderr,
+                                               "WARN: MAX_FIELDS (%d) reached,"
+                                               " truncating number of keys\n",
+                                               MAX_FIELDS);
                                        goto full;
+                               }
                        }
                }
        full:
@@ -272,8 +277,13 @@ int main(int argc, char **argv)
                                for (tok = strtok(tmp, ",");
                                     tok;
                                     tok = strtok(NULL, ",")) {
-                                       if (fp.num >= MAX_FIELDS)
+                                       if (fp.num >= MAX_FIELDS) {
+                                               fprintf(stderr, 
+                                                       "WARN: too many keys"
+                                                       " requested: (%d max)\n",
+                                                       MAX_FIELDS);
                                                break;
+                                       }
                                        fp.params[fp.num++].name = tok;
                                }
                                break;