[PATCH RFC v2 1/3] rdma_cm: add rdma_reject_msg() helper function
Christoph Hellwig
hch at lst.de
Fri Oct 21 05:12:34 PDT 2016
> +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];
}
> +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.
More information about the Linux-nvme
mailing list