Re: [PATCH 2/3] staging: lustre: fix pointer whitespace style

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux