Fix sessiond needed checks
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 25 Jan 2012 14:37:39 +0000 (09:37 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 25 Jan 2012 14:37:39 +0000 (09:37 -0500)
- strncmp should compare up to and _include_ the \0 (was off by one).
  Instead of 2 for "-h", it should be 3. Use "sizeof("-h")" instead of
  hardcoding 3.
- strncmp logic was reversed for the --list-options check.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng/lttng.c

index a8cc2e72ff1ef1809d7941e5870ffde1418e9d88..57927d4f3d301f87ceb11a0ec85ea489b4e3f4bd 100644 (file)
@@ -387,9 +387,9 @@ static int check_args_no_sessiond(int argc, char **argv)
        int i;
 
        for (i = 0; i < argc; i++) {
-               if ((strncmp(argv[i], "-h", 2) == 0) ||
-                               strncmp(argv[i], "--h", 3) == 0 ||
-                               strncmp(argv[i], "--list-options", 14)) {
+               if ((strncmp(argv[i], "-h", sizeof("-h")) == 0) ||
+                               strncmp(argv[i], "--h", sizeof("--h")) == 0 ||
+                               strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0) {
                        return 1;
                }
        }
This page took 0.030471 seconds and 4 git commands to generate.