From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: open-iscsi@googlegroups.com, lduncan@suse.com, cleech@redhat.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
kernel@collabora.com, Khazhismel Kumykov <khazhy@google.com>,
Junho Ryu <jayr@google.com>
Subject: Re: [PATCH v2] iscsi: Report connection state on sysfs
Date: Thu, 05 Mar 2020 14:20:50 -0500 [thread overview]
Message-ID: <854kv2bobx.fsf@collabora.com> (raw)
In-Reply-To: <bc70bd6d-6d13-4d1c-8559-140411e361d9@acm.org> (Bart Van Assche's message of "Thu, 5 Mar 2020 08:56:26 -0800")
Bart Van Assche <bvanassche@acm.org> writes:
> On 3/5/20 7:35 AM, Gabriel Krisman Bertazi wrote:
>> +static const struct {
>> + int value;
>> + char *name;
>> +} connection_state_names[] = {
>> + {ISCSI_CONN_UP, "up"},
>> + {ISCSI_CONN_DOWN, "down"},
>> + {ISCSI_CONN_FAILED, "failed"}
>> +};
>> +
>> +static const char *connection_state_name(int state)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(connection_state_names); i++) {
>> + if (connection_state_names[i].value == state)
>> + return connection_state_names[i].name;
>> + }
>> + return NULL;
>> +}
>> +
>> +static ssize_t show_conn_state(struct device *dev,
>> + struct device_attribute *attr, char *buf)
>> +{
>> + struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent);
>> +
>> + return sprintf(buf, "%s\n", connection_state_name(conn->state));
>> +}
>> +static ISCSI_CLASS_ATTR(conn, state, S_IRUGO, show_conn_state,
>> + NULL);
>
> What has been changed in v2 compared to v1? Please always include a
> changelog when posting a new version.
>
> Additionally, it seems like the comment I posted on v1 has not been
> addressed?
Hi Bart,
v2 no longer has the dependency for specific values for the state, as
you requested. It follows the pattern in similar places in the iscsi
code. Why would designated initializers be better than my solution?
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2020-03-05 19:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 15:35 [PATCH v2] iscsi: Report connection state on sysfs Gabriel Krisman Bertazi
2020-03-05 16:56 ` Bart Van Assche
2020-03-05 19:20 ` Gabriel Krisman Bertazi [this message]
2020-03-05 21:16 ` Bart Van Assche
2020-03-06 19:59 ` Gabriel Krisman Bertazi
2020-03-07 0:48 ` Bart Van Assche
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=854kv2bobx.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=bvanassche@acm.org \
--cc=cleech@redhat.com \
--cc=jayr@google.com \
--cc=kernel@collabora.com \
--cc=khazhy@google.com \
--cc=lduncan@suse.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=open-iscsi@googlegroups.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.