From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH nvme-cli 2/4] fabrics: stringify discover output.
Date: Mon, 8 Aug 2016 11:41:15 +0300 [thread overview]
Message-ID: <151359dc-4247-8b08-fa3f-0841e1c29c05@grimberg.me> (raw)
In-Reply-To: <20160808065934.GB12598@lst.de>
>> Just so we have a nice readable output.
>>
>> Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
>> ---
>> fabrics.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
>> 1 file changed, 107 insertions(+), 8 deletions(-)
>>
>> diff --git a/fabrics.c b/fabrics.c
>> index 221e34e5e39b..9f99e6175428 100644
>> --- a/fabrics.c
>> +++ b/fabrics.c
>> @@ -63,6 +63,106 @@ static const match_table_t opt_tokens = {
>> { OPT_ERR, NULL },
>> };
>>
>> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
>
> should go into a header so that all of the tool has it available.
You're right, Moved to common.h
>> +static const char *cms_str(__u8 cm)
>> +{
>> + size_t idx = cm;
>> +
>> + return (idx < ARRAY_SIZE(cms) && cms[idx]) ?
>> + cms[idx] : "unrecognized";
>> +}
>
> How about a little helper instead of duplicating this pattern many
> times, e.g
>
> static const char *lookup_string(const char **strings, size_t array_size,
> size_t id)
> {
> if (idx < array_size && strings[idx])
> return strings[idx];
> return "unrecognized";
> }
It is nicer, thanks!
Added, just with a different name: arg_str()
>
> also makes me wonder why we even bother with the inline annotation
> for such slow path code.
Because it's really short and simply returns a string. I can lose it...
next prev parent reply other threads:[~2016-08-08 8:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-07 12:19 [PATCH nvme-cli 0/4] Some useful fabrics patches Sagi Grimberg
2016-08-07 12:19 ` [PATCH nvme-cli 1/4] fabrics: Allow ipv6 address resolution Sagi Grimberg
2016-08-08 6:55 ` Christoph Hellwig
2016-08-08 20:53 ` J Freyensee
2016-08-07 12:19 ` [PATCH nvme-cli 2/4] fabrics: stringify discover output Sagi Grimberg
2016-08-08 6:59 ` Christoph Hellwig
2016-08-08 8:41 ` Sagi Grimberg [this message]
2016-08-07 12:19 ` [PATCH nvme-cli 3/4] fabrics: Remove redundant build_options Sagi Grimberg
2016-08-08 7:01 ` Christoph Hellwig
2016-08-08 8:41 ` Sagi Grimberg
2016-08-07 12:19 ` [PATCH RFC nvme-cli 4/4] fabrics: Allow discover params to come from a conf file Sagi Grimberg
2016-08-08 7:03 ` Christoph Hellwig
2016-08-08 8:45 ` Sagi Grimberg
2016-08-08 21:13 ` J Freyensee
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=151359dc-4247-8b08-fa3f-0841e1c29c05@grimberg.me \
--to=sagi@grimberg.me \
/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;
as well as URLs for NNTP newsgroup(s).