]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
make argc macro a bit safer
authorTobias Oetiker <tobi@oetiker.ch>
Tue, 28 Jul 2015 15:38:13 +0000 (17:38 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Tue, 28 Jul 2015 15:38:13 +0000 (17:38 +0200)
src/optparse.c

index 911a56bef5610e08d385853855a25a29ca70bab8..f6fb7e777ebd1f3c99133ae8f6895804e5e55fc2 100644 (file)
@@ -5,7 +5,7 @@
     snprintf(options->errmsg, sizeof(options->errmsg), format, args);
 
 #define options_argv(i) \
-    (i) < options->argc ? options->argv[i] : 0;
+    ((i) < options->argc ? options->argv[i] : NULL)
 
 void optparse_init(struct optparse *options, int argc, char **argv)
 {
@@ -156,7 +156,7 @@ optstring_from_long(const struct optparse_long *longopts, char *optstring)
     for (int i = 0; !longopts_end(longopts, i); i++) {
         if (longopts[i].shortname) {
             *p++ = longopts[i].shortname;
-            for (int a = 0; a < longopts[i].argtype; a++)
+            for (unsigned int a = 0; a < longopts[i].argtype; a++)
                 *p++ = ':';
         }
     }
@@ -210,6 +210,7 @@ optparse_long(struct optparse *options,
               const struct optparse_long *longopts,
               int *longindex)
 {
+//    printf("%i < %i\n",options->optind,options->argc);
     char *option = options_argv(options->optind);
     if (option == NULL) {
         return -1;