linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] audit: Remove condition which always evaluates to false
@ 2015-03-11 18:08 Pranith Kumar
  2015-03-13 21:35 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Pranith Kumar @ 2015-03-11 18:08 UTC (permalink / raw)
  To: Paul Moore, Eric Paris, moderated list:AUDIT SUBSYSTEM, open list

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>
---
 kernel/audit.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 72ab759..b1006cb 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -344,7 +344,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);
@@ -877,8 +877,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)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] audit: Remove condition which always evaluates to false
  2015-03-11 18:08 [PATCH] audit: Remove condition which always evaluates to false Pranith Kumar
@ 2015-03-13 21:35 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2015-03-13 21:35 UTC (permalink / raw)
  To: Pranith Kumar; +Cc: Eric Paris, moderated list:AUDIT SUBSYSTEM, open list

On Wed, Mar 11, 2015 at 2:08 PM, Pranith Kumar <bobby.prani@gmail.com> wrote:
> 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>
> ---
>  kernel/audit.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Applied, thanks!

> diff --git a/kernel/audit.c b/kernel/audit.c
> index 72ab759..b1006cb 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -344,7 +344,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);
> @@ -877,8 +877,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)
> --
> 1.9.1
>



-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-13 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-11 18:08 [PATCH] audit: Remove condition which always evaluates to false Pranith Kumar
2015-03-13 21:35 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).