From: "Dilger, Andreas" <andreas.dilger@intel.com>
To: James Simmons <jsimmons@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"Drokin, Oleg" <oleg.drokin@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: Re: [lustre-devel] [PATCH 09/10] staging: lustre: libcfs: remove zero comparisons in headers
Date: Fri, 25 Nov 2016 23:49:16 +0000 [thread overview]
Message-ID: <0DBDC329-9FB2-4749-9EC3-5B81901BA6D5@intel.com> (raw)
In-Reply-To: <1479487724-20386-10-git-send-email-jsimmons@infradead.org>
On Nov 18, 2016, at 09:48, James Simmons <jsimmons@infradead.org> wrote:
>
> Remove the zero comparisions in the libcfs headers.
>
> Signed-off-by: James Simmons <jsimmons@infradead.org>
> ---
> .../lustre/include/linux/libcfs/libcfs_crypto.h | 2 +-
> .../lustre/include/linux/libcfs/libcfs_fail.h | 4 +-
> .../lustre/include/linux/libcfs/libcfs_hash.h | 32 ++++++++++----------
> 3 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
> index a0865e5..8f34c5d 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
> @@ -137,7 +137,7 @@ static inline unsigned char cfs_crypto_hash_alg(const char *algname)
> enum cfs_crypto_hash_alg hash_alg;
>
> for (hash_alg = 0; hash_alg < CFS_HASH_ALG_MAX; hash_alg++)
> - if (strcmp(hash_types[hash_alg].cht_name, algname) == 0)
> + if (!strcmp(hash_types[hash_alg].cht_name, algname))
I'd really rather keep the "== 0" comparison for strcmp(), because IMHO
!strcmp() reads like "the strings do not compare the same" and is confusing.
> static inline int
> cfs_hash_is_iterating(struct cfs_hash *hs)
> {
> /* someone is calling cfs_hash_for_each_* */
> - return hs->hs_iterating || hs->hs_iterators != 0;
> + return hs->hs_iterating || hs->hs_iterators;
Likewise, I'd rather keep comparisons == 0 or != 0 for cases where the
variable is an actual number instead of just a return code or a pointer.
I don't think we need to be totally dogmatic about removing every comparison
with 0 in all of the code, as that can reduce readability in some cases.
I know this patch has already landed, and it isn't the end of the world
either way, but just wanted to forestall similar changes being made through
the rest of the code.
Cheers, Andreas
next prev parent reply other threads:[~2016-11-25 23:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-18 16:48 [PATCH 00/10] checkpatch fixes and style cleanups for libcfs headers James Simmons
2016-11-18 16:48 ` [PATCH 01/10] staging: lustre: libcfs: fixup all header block comments James Simmons
2016-11-18 16:48 ` [PATCH 02/10] staging: lustre: libcfs: remove header's bare unsigned use James Simmons
2016-11-18 16:48 ` [PATCH 03/10] staging: lustre: libcfs: name parameters for function prototypes James Simmons
2016-11-18 16:48 ` [PATCH 04/10] staging: lustre: libcfs: remove blank line in header James Simmons
2016-11-18 16:48 ` [PATCH 05/10] staging: lustre: libcfs: correct spelling in libcfs_cpu.h James Simmons
2016-11-18 16:48 ` [PATCH 06/10] staging: lustre: libcfs: use bit macro in libcfs headers James Simmons
2016-11-18 16:48 ` [PATCH 07/10] staging: lustre: libcfs: remove whitespace in libcfs_fail.h James Simmons
2016-11-18 16:48 ` [PATCH 08/10] staging: lustre: libcfs: remove NULL comparisons in headers James Simmons
2016-11-25 12:17 ` Dan Carpenter
2016-11-18 16:48 ` [PATCH 09/10] staging: lustre: libcfs: remove zero " James Simmons
2016-11-25 23:49 ` Dilger, Andreas [this message]
2016-11-18 16:48 ` [PATCH 10/10] staging: lustre: libcfs: use uXX instead of __uXX types " James Simmons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0DBDC329-9FB2-4749-9EC3-5B81901BA6D5@intel.com \
--to=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®