> > > +const char *__attribute_const__ ib_reject_msg(int reason) > > +{ > > + size_t index = reason; > > + > > + return (index < ARRAY_SIZE(ib_rej_reason_strs) && > > + ib_rej_reason_strs[index]) ? > > + ib_rej_reason_strs[index] : "unrecognized reason"; > > +} > > +EXPORT_SYMBOL(ib_reject_msg); > > This looks a bit odd, why not something like: > > const char *__attribute_const__ ib_reject_msg(int reason) > { > if (reason >= ARRAY_SIZE(ib_rej_reason_strs) || > !ib_rej_reason_strs[reason]) > return "unrecognized reason"; > return ib_rej_reason_strs[reason]; > } > I copy/pasted from rdma_event_msg(). > > +const char *__attribute_const__ iw_reject_msg(int reason) > > +{ > > + size_t index = -reason; > > + > > + /* iWARP uses negative errnos */ > > + index = -index; > > + return (index < ARRAY_SIZE(iw_rej_reason_strs) && > > + iw_rej_reason_strs[index]) ? > > + iw_rej_reason_strs[index] : "unrecognized reason"; > > +} > > +EXPORT_SYMBOL(iw_reject_msg); > > Same here: > > const char *__attribute_const__ iw_reject_msg(int reason) > { > /* iWARP uses negative errnos */ > reason = -reason; > > if (reason >= ARRAY_SIZE(iw_rej_reason_strs) || > !iw_rej_reason_strs[reason]) > return "unrecognized reason"; > return iw_rej_reason_strs[reason]; > } > > Otherwise this looks good and very useful to me. I will refactor as you suggest. You proposed logic is slightly more readable to me... Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html