From 78ca909980ee6e632ce929fcf238655a425c7db6 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Fri, 1 Sep 2017 01:02:32 +0100 Subject: [PATCH] systemctl: remove compiler warning (#6717) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 913c1916 changed _ACTION_INVALID to negative, changing the enum to a signed type. Take care to avoid comparing it with an unsigned type. ../src/systemctl/systemctl.c: In function ‘start_unit’: ../src/systemctl/systemctl.c:3107:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] assert(arg_action < ELEMENTSOF(action_table)); --- src/systemctl/systemctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index a533132abb..328b69454d 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -3104,7 +3104,7 @@ static int start_unit(int argc, char *argv[], void *userdata) { one_name = NULL; } } else { - assert(arg_action < ELEMENTSOF(action_table)); + assert(arg_action >= 0 && arg_action < _ACTION_MAX); assert(action_table[arg_action].target); assert(action_table[arg_action].mode); @@ -8177,7 +8177,7 @@ _pure_ static int action_to_runlevel(void) { [ACTION_RESCUE] = '1' }; - assert(arg_action < _ACTION_MAX); + assert(arg_action >= 0 && arg_action < _ACTION_MAX); return table[arg_action]; }