Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbdHMPl2 (ORCPT ); Sun, 13 Aug 2017 11:41:28 -0400 Received: from h2.hallyn.com ([78.46.35.8]:50130 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbdHMPl0 (ORCPT ); Sun, 13 Aug 2017 11:41:26 -0400 Date: Sun, 13 Aug 2017 10:41:33 -0500 From: "Serge E. Hallyn" To: SF Markus Elfring Cc: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Alexey Dobriyan , Daniel Jurgens , Eric Paris , James Morris , Junil Lee , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts , LKML , kernel-janitors@vger.kernel.org Subject: Re: [PATCH 4/4] selinux: Adjust five checks for null pointers Message-ID: <20170813154133.GA4515@mail.hallyn.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1887 Lines: 62 Quoting SF Markus Elfring (elfring@users.sourceforge.net): > From: Markus Elfring > 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 > --- > 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