Fix: Clamp verbosity value read from config file
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 548cc43095b633bb09528085dfb878a5e99578f6..6a918ec56a73926621a20119eb3e3686d0f3d998 100644 (file)
@@ -4240,13 +4240,15 @@ static int set_option(int opt, const char *arg, const char *optname)
        case 'v':
                /* Verbose level can increase using multiple -v */
                if (arg) {
+                       /* Value obtained from config file */
                        lttng_opt_verbose = config_parse_value(arg);
                } else {
-                       /* Only 3 level of verbosity (-vvv). */
-                       if (lttng_opt_verbose < 3) {
-                               lttng_opt_verbose += 1;
-                       }
+                       /* -v used on command line */
+                       lttng_opt_verbose++;
                }
+               /* Clamp value to [0, 3] */
+               lttng_opt_verbose = lttng_opt_verbose < 0 ? 0 :
+                       (lttng_opt_verbose <= 3 ? lttng_opt_verbose : 3);
                break;
        case 'Z':
                if (arg) {
This page took 0.023968 seconds and 4 git commands to generate.