audit: Remove condition which always evaluates to false
authorPranith Kumar <bobby.prani@gmail.com>
Wed, 11 Mar 2015 18:08:19 +0000 (14:08 -0400)
committerPaul Moore <pmoore@redhat.com>
Fri, 13 Mar 2015 21:32:52 +0000 (17:32 -0400)
After commit 3e1d0bb6224f019893d1c498cc3327559d183674 ("audit: Convert int limit
uses to u32"), by converting an int to u32, few conditions will always evaluate
to false.

These warnings were emitted during compilation:

kernel/audit.c: In function ‘audit_set_enabled’:
kernel/audit.c:347:2: warning: comparison of unsigned expression < 0 is always
false [-Wtype-limits]
  if (state < AUDIT_OFF || state > AUDIT_LOCKED)
  ^
  kernel/audit.c: In function ‘audit_receive_msg’:
  kernel/audit.c:880:9: warning: comparison of unsigned expression < 0 is
  always false [-Wtype-limits]
      if (s.backlog_wait_time < 0 ||

The following patch removes those unnecessary conditions.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Signed-off-by: Paul Moore <pmoore@redhat.com>
kernel/audit.c

index 52ee8eee0e073c0e1bf10d2b1a9bc448bcf36dbd..d5a1220c862047c2bb21aa6867532a46d670aa0d 100644 (file)
@@ -346,7 +346,7 @@ static int audit_set_backlog_wait_time(u32 timeout)
 static int audit_set_enabled(u32 state)
 {
        int rc;
-       if (state < AUDIT_OFF || state > AUDIT_LOCKED)
+       if (state > AUDIT_LOCKED)
                return -EINVAL;
 
        rc =  audit_do_config_change("audit_enabled", &audit_enabled, state);
@@ -888,8 +888,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                if (s.mask & AUDIT_STATUS_BACKLOG_WAIT_TIME) {
                        if (sizeof(s) > (size_t)nlh->nlmsg_len)
                                return -EINVAL;
-                       if (s.backlog_wait_time < 0 ||
-                           s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
+                       if (s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
                                return -EINVAL;
                        err = audit_set_backlog_wait_time(s.backlog_wait_time);
                        if (err < 0)