Add missing terminating NULL to speed_options table.
[openssl.git] / apps / opt.c
index 3706739c0337607f2d238b2252bc0cedf206fbdd..3e2831cc1fbffa2693ddd029987179234ba602ef 100644 (file)
@@ -54,7 +54,7 @@
 #if !defined(OPENSSL_SYS_MSDOS)
 # include OPENSSL_UNISTD
 #endif
-#include <unistd.h>
+
 #include <stdlib.h>
 #include <errno.h>
 #include <ctype.h>
@@ -96,11 +96,11 @@ char *opt_progname(const char *argv0)
     /* Strip off trailing nonsense. */
     n = strlen(p);
     if (n > 4 &&
-        (strcmp(&p[n - 4], ".exe") == 0 || strcmp(&p[n - 4], ".EXE") == 0)
+        (strcmp(&p[n - 4], ".exe") == 0 || strcmp(&p[n - 4], ".EXE") == 0))
         n -= 4;
 #if defined(OPENSSL_SYS_NETWARE)
     if (n > 4 &&
-        (strcmp(&p[n - 4], ".nlm") == 0 || strcmp(&p[n - 4], ".NLM") == 0)
+        (strcmp(&p[n - 4], ".nlm") == 0 || strcmp(&p[n - 4], ".NLM") == 0))
         n -= 4;
 #endif
 
@@ -108,7 +108,7 @@ char *opt_progname(const char *argv0)
     if (n > sizeof prog - 1)
         n = sizeof prog - 1;
     for (q = prog, i = 0; i < n; i++, p++)
-        q++ = isupper(*p) ? tolower(*p) : *p;
+        *q++ = isupper(*p) ? tolower(*p) : *p;
     *q = '\0';
     return prog;
 }
@@ -171,7 +171,7 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
     for (; o->name; ++o) {
         const OPTIONS *next;
 #ifndef NDEBUG
-        int i;
+        int duplicated, i;
 #endif
 
         if (o->name == OPT_HELP_STR || o->name == OPT_MORE_STR)
@@ -188,11 +188,12 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
                || i == 'f' || i == 'F');
 
         /* Make sure there are no duplicates. */
-        for (next = o; (++next)->name;) {
+        for (next = o + 1; next->name; ++next) {
             /*
-             * do allow aliases: assert(o->retval != next->retval);
+             * Some compilers inline strcmp and the assert string is too long.
              */
-            assert(strcmp(o->name, next->name) != 0);
+            duplicated = strcmp(o->name, next->name) == 0;
+            assert(!duplicated);
         }
 #endif
         if (o->name[0] == '\0') {
@@ -794,7 +795,7 @@ void opt_help(const OPTIONS *list)
         }
 
         /* Pad out prefix */
-        memset(start, ' ', sizeof start - 1);
+        memset(start, ' ', sizeof(start) - 1);
         start[sizeof start - 1] = '\0';
 
         if (o->name == OPT_MORE_STR) {
@@ -820,7 +821,7 @@ void opt_help(const OPTIONS *list)
         if ((int)(p - start) >= MAX_OPT_HELP_WIDTH) {
             *p = '\0';
             BIO_printf(bio_err, "%s\n", start);
-            memset(start, ' ', sizeof start);
+            memset(start, ' ', sizeof(start));
         }
         start[width] = '\0';
         BIO_printf(bio_err, "%s  %s\n", start, help);