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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to