lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1410027543.2723.8.camel@joe-AO725>
Date:	Sat, 06 Sep 2014 11:19:03 -0700
From:	Joe Perches <joe@...ches.com>
To:	Spencer Baugh <sbaugh@...rew.cmu.edu>
Cc:	gregkh@...uxfoundation.org, Oleg Drokin <oleg.drokin@...el.com>,
	Niu Yawei <yawei.niu@...el.com>,
	Hongchao Zhang <hongchao.zhang@...el.com>,
	Alex Zhuravlev <alexey.zhuravlev@...el.com>,
	Masanari Iida <standby24x7@...il.com>,
	"open list:STAGING SUBSYSTEM" <devel@...verdev.osuosl.org>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/3] staging: lustre: fix pointer whitespace style

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";
	}
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ