The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Spencer Baugh <sbaugh@andrew.cmu.edu>
Cc: gregkh@linuxfoundation.org, Oleg Drokin <oleg.drokin@intel.com>,
	Niu Yawei <yawei.niu@intel.com>,
	Hongchao Zhang <hongchao.zhang@intel.com>,
	Alex Zhuravlev <alexey.zhuravlev@intel.com>,
	Masanari Iida <standby24x7@gmail.com>,
	"open list:STAGING SUBSYSTEM" <devel@driverdev.osuosl.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] staging: lustre: fix pointer whitespace style
Date: Sat, 06 Sep 2014 11:19:03 -0700	[thread overview]
Message-ID: <1410027543.2723.8.camel@joe-AO725> (raw)
In-Reply-To: <1410025111-31422-2-git-send-email-sbaugh@andrew.cmu.edu>

On Sat, 2014-09-06 at 13:38 -0400, Spencer Baugh wrote:
> Fix errors reported by checkpatch of this kind:
[]
> diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
[]
> @@ -103,9 +103,9 @@ enum lustre_imp_state {
>  };
>  
>  /** Returns test string representation of numeric import state \a state */
> -static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
> +static inline char *ptlrpc_import_state_name(enum lustre_imp_state state)
>  {
> -	static char* import_state_names[] = {
> +	static char *import_state_names[] = {
>  		"<UNKNOWN>", "CLOSED",  "NEW", "DISCONN",
>  		"CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
>  		"RECOVER", "FULL", "EVICTED",

This likely shouldn't be static inline, but an actual
function somewhere.

The return should probably be const char *.

Indexing a string array with an enum is generally unsafe.

I think it better to use a switch/case like:

const char *ptlrpc_import_state_name(enum lustre_imp_state state)
{
	switch (state) {
	case LUSTRE_IMP_CLOSED:
		return "CLOSED";
	case LUSTRE_IMP_NEW:
		return "NEW";
	case LUSTRE_IMP_DISCON:
		return "DISCONN";
	case LUSTRE_IMP_CONNECTING:
		return "CONNECTING";
	case LUSTRE_IMP_REPLAY:
		return "REPLAY";
	case LUSTRE_IMP_REPLAY_LOCKS:
		return "REPLAY_LOCKS";
	case LUSTRE_IMP_REPLAY_WAIT:
		return "REPLAY_WAIT";
	case LUSTRE_IMP_RECOVER:
		return "RECOVER";
	case LUSTRE_IMP_FULL:
		return "FULL";
	case LUSTRE_IMP_EVICTED:
		return "EVICTED";
	default:
		return "UNKNOWN";
	}
}



  reply	other threads:[~2014-09-06 18:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-06 17:38 [PATCH 1/3] staging: lustre: fix function definition style Spencer Baugh
2014-09-06 17:38 ` [PATCH 2/3] staging: lustre: fix pointer whitespace style Spencer Baugh
2014-09-06 18:19   ` Joe Perches [this message]
2014-09-08 10:32     ` Dan Carpenter
2014-09-08 11:37       ` Joe Perches
2014-09-06 17:38 ` [PATCH 3/3] staging: lustre: remove trailing whitespace Spencer Baugh
2014-09-08 19:40 ` [PATCH 1/3] staging: lustre: fix function definition style Greg KH

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=1410027543.2723.8.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=alexey.zhuravlev@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hongchao.zhang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=sbaugh@andrew.cmu.edu \
    --cc=standby24x7@gmail.com \
    --cc=yawei.niu@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