Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1710567

Re: [PATCH 4/4] selinux: Adjust five checks for null pointers

From "Serge E. Hallyn" <serge@hallyn.com>
Newsgroups linux.kernel
Subject Re: [PATCH 4/4] selinux: Adjust five checks for null pointers
Date 2017-08-13 17:50 +0200
Message-ID <ue3jj-w9-3@gated-at.bofh.it> (permalink)
References <ue2nf-8n0-3@gated-at.bofh.it> <ue2wW-8qw-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Quoting SF Markus Elfring (elfring@users.sourceforge.net):
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 13 Aug 2017 16:16:05 +0200
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> The script “checkpatch.pl” pointed information out like the following.
> 
> Comparison to NULL could be written …

...  could be written all sorts of ways.  But what's the advantage of this?
Personally I find "x == NULL" easier to read, and AFAIK psychology backs me
up on the idea that negation is harder on the brain and worth avoiding when
possible.

> Thus fix affected source code places.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  security/selinux/ss/ebitmap.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
> index 697bd748760a..c778135989f5 100644
> --- a/security/selinux/ss/ebitmap.c
> +++ b/security/selinux/ss/ebitmap.c
> @@ -96,12 +96,12 @@ int ebitmap_netlbl_export(struct ebitmap *ebmap,
>  	unsigned int iter;
>  	int rc;
>  
> -	if (e_iter == NULL) {
> +	if (!e_iter) {
>  		*catmap = NULL;
>  		return 0;
>  	}
>  
> -	if (*catmap != NULL)
> +	if (*catmap)
>  		netlbl_catmap_free(*catmap);
>  	*catmap = NULL;
>  
> @@ -161,14 +161,14 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap,
>  			continue;
>  		}
>  
> -		if (e_iter == NULL ||
> +		if (!e_iter ||
>  		    offset >= e_iter->startbit + EBITMAP_SIZE) {
>  			e_prev = e_iter;
>  			e_iter = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC);
> -			if (e_iter == NULL)
> +			if (!e_iter)
>  				goto netlbl_import_failure;
>  			e_iter->startbit = offset - (offset % EBITMAP_SIZE);
> -			if (e_prev == NULL)
> +			if (!e_prev)
>  				ebmap->node = e_iter;
>  			else
>  				e_prev->next = e_iter;
> -- 
> 2.14.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] SELinux: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-13 16:50 +0200
  [PATCH 1/4] selinux: Delete eight unnecessary variable assignments SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-13 16:50 +0200
    Re: [PATCH 1/4] selinux: Delete eight unnecessary variable  assignments "Serge E. Hallyn" <serge@hallyn.com> - 2017-08-13 18:30 +0200
    Re: [PATCH 1/4] selinux: Delete eight unnecessary variable  assignments "Serge E. Hallyn" <serge@hallyn.com> - 2017-08-13 18:30 +0200
  [PATCH 2/4] selinux: Adjust jump targets in ebitmap_read() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-13 16:50 +0200
    Re: [PATCH 2/4] selinux: Adjust jump targets in ebitmap_read() "Serge E. Hallyn" <serge@hallyn.com> - 2017-08-13 18:30 +0200
  [PATCH 3/4] selinux: Delete an unnecessary return statement in  ebitmap_destroy() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-13 16:50 +0200
  [PATCH 4/4] selinux: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-13 17:00 +0200
    Re: [PATCH 4/4] selinux: Adjust five checks for null pointers "Serge E. Hallyn" <serge@hallyn.com> - 2017-08-13 17:50 +0200
    Re: [PATCH 4/4] selinux: Adjust five checks for null pointers Yanhao Mo <yanhaocs@gmail.com> - 2017-08-14 13:10 +0200
  Re: [PATCH 0/4] SELinux: Fine-tuning for some function implementations Paul Moore <paul@paul-moore.com> - 2017-08-14 23:10 +0200

csiph-web