[PATCH 1/6] Remove pointless N < 0 checks

Thomas Haller thaller at redhat.com
Tue Aug 26 03:00:23 PDT 2014


On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote:
> route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is
> always false [-Wtautological-compare]
>               if (id < 0 || id > RTNL_TC_STATS_MAX)
> 
> Signed-off-by: Thomas Graf <tgraf at suug.ch>
> ---
>  lib/handlers.c | 8 ++++----
>  lib/route/tc.c | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/handlers.c b/lib/handlers.c
> index a6a97bb..9cf5a96 100644
> --- a/lib/handlers.c
> +++ b/lib/handlers.c
> @@ -203,7 +203,7 @@ struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind)
>  	int i;
>  	struct nl_cb *cb;
>  
> -	if (kind < 0 || kind > NL_CB_KIND_MAX)
> +	if (kind > NL_CB_KIND_MAX)
>  		return NULL;


Isn't the signedness of enums implementation defined?

For NetworkManager we did instead:
http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=a2a36d845066a5e3ad1b6d2953993a1a433340ff



Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20140826/f2114fce/attachment-0001.sig>


More information about the libnl mailing list