Re: [PATCH v2] iscsi: Report connection state on sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bart Van Assche <bvanassche@xxxxxxx> 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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux