From: Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Bart Van Assche
<bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>,
Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH RFC] IB/core, cma: Nice log-friendly string helpers
Date: Sun, 10 May 2015 13:45:16 +0300 [thread overview]
Message-ID: <554F36BC.5070009@dev.mellanox.co.il> (raw)
In-Reply-To: <554F32F3.1070308-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
On 5/10/2015 1:29 PM, Bart Van Assche wrote:
> On 05/10/15 12:04, Sagi Grimberg wrote:
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index 65994a1..d615e63 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -412,6 +412,32 @@ enum ib_event_type {
>> IB_EVENT_GID_CHANGE,
>> };
>>
>> +static const char * const ib_events[] = {
>> + "CQ_ERR",
>> + "QP_FATAL",
>> + "QP_REQ_ERR",
>> + "QP_ACCESS_ERR",
>> + "COMM_EST",
>> + "SQ_DRAINED",
>> + "PATH_MIG",
>> + "PATH_MIG_ERR",
>> + "DEVICE_FATAL",
>> + "PORT_ACTIVE",
>> + "PORT_ERR",
>> + "LID_CHANGE",
>> + "PKEY_CHANGE",
>> + "SM_CHANGE",
>> + "SRQ_ERR",
>> + "SRQ_LIMIT_REACHED",
>> + "QP_LAST_WQE_REACHED",
>> + "CLIENT_REREGISTER",
>> + "GID_CHANGE",
>> +};
>
Hey Bart,
> Array definitions should occur in a .c file instead of in a .h file to
> avoid duplication of the array.
OK, I'll move to verbs.c (and cma.c) thanks.
> Additionally, please consider to use
> designated initializers since that would make the correspondence between
> enum label and text string easier to verify.
Sure.
>
>> +#define IB_EVENT(event) \
>> + ((event) < ARRAY_SIZE(ib_events) ? \
>> + ib_events[(event)] : "UNRECOGNIZED_EVENT")
>> +
>
> Since a compiler is allowed to use a signed type to implement an enum,
> please cast "event" to an unsigned type before comparing it with the
> array size. Additionally, please consider to define IB_EVENT() as an
> inline function instead of a preprocessor macro.
>
I can do that, any specific reason why to use inline over macro here?
Sagi.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-05-10 10:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1431252274-27739-1-git-send-email-sagig@mellanox.com>
[not found] ` <1431252274-27739-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-10 10:29 ` [PATCH RFC] IB/core, cma: Nice log-friendly string helpers Bart Van Assche
[not found] ` <554F32F3.1070308-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-05-10 10:45 ` Sagi Grimberg [this message]
[not found] ` <554F36BC.5070009-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-05-11 7:50 ` Bart Van Assche
2015-05-10 12:04 ` Or Gerlitz
2015-05-10 10:36 Sagi Grimberg
[not found] ` <1431254186-23554-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-10 20:22 ` Or Gerlitz
[not found] <1431253542-14933-1-git-send-email-sagig@mellanox.com>
[not found] ` <1431253542-14933-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-11 13:44 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=554F36BC.5070009@dev.mellanox.co.il \
--to=sagig-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
--cc=bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org \
--cc=chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox