This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=2d5b58849369c7d27be2f4271ff9e8d96a773288

commit 2d5b58849369c7d27be2f4271ff9e8d96a773288
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Oct 26 09:44:16 2018 +0200

    u-a: Switch verbose selection into an enum
    
    This makes the values and comparisons immediately clear.
---
 debian/changelog            |  1 +
 utils/update-alternatives.c | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1eba3f45f..b3c86a11e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -68,6 +68,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium
       like a boolean.
     - start-stop-daemon: Switch code to use new info() and debug() functions.
     - update-alternatives: Use enums for actions instead of strings.
+    - update-alternatives: Switch verbose selection into an enum.
   * Build system:
     - get-version: Use a format string with printf.
     - run-script: Use $() instead of deprecated ``.
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index c943f6e4f..61e07bc8f 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -90,12 +90,18 @@ struct action_name {
        { ACTION_DISPLAY,               "display" },
 };
 
+enum output_mode {
+       OUTPUT_QUIET = -1,
+       OUTPUT_NORMAL = 0,
+       OUTPUT_VERBOSE = 1,
+};
+
 /* Action to perform */
 static enum action action = ACTION_NONE;
 static const char *log_file = LOGDIR "/alternatives.log";
 /* Skip alternatives properly configured in auto mode (for --config) */
 static int opt_skip_auto = 0;
-static int opt_verbose = 0;
+static int opt_verbose = OUTPUT_NORMAL;
 static int opt_force = 0;
 
 /*
@@ -212,7 +218,7 @@ warning(char const *fmt, ...)
 {
        va_list args;
 
-       if (opt_verbose < 0)
+       if (opt_verbose < OUTPUT_NORMAL)
                return;
 
        fprintf(stderr, "%s: %s: ", PROGNAME, _("warning"));
@@ -241,7 +247,7 @@ verbose(char const *fmt, ...)
 {
        va_list args;
 
-       if (opt_verbose < 1)
+       if (opt_verbose < OUTPUT_VERBOSE)
                return;
 
        printf("%s: ", PROGNAME);
@@ -256,7 +262,7 @@ info(char const *fmt, ...)
 {
        va_list args;
 
-       if (opt_verbose < 0)
+       if (opt_verbose < OUTPUT_NORMAL)
                return;
 
        printf("%s: ", PROGNAME);
@@ -2630,9 +2636,9 @@ main(int argc, char **argv)
                        version();
                        exit(0);
                } else if (strcmp("--verbose", argv[i]) == 0) {
-                       opt_verbose++;
+                       opt_verbose = OUTPUT_VERBOSE;
                } else if (strcmp("--quiet", argv[i]) == 0) {
-                       opt_verbose--;
+                       opt_verbose = OUTPUT_QUIET;
                } else if (strcmp("--install", argv[i]) == 0) {
                        char *prio_str, *prio_end;
                        long prio;

-- 
Dpkg.Org's dpkg

Reply via email to