Conversation
|
Changes for the issue #2912. |
1e6066d to
6dbe7b3
Compare
| { | ||
| struct table *t = table_init(); | ||
|
|
||
| if (t) { |
There was a problem hiding this comment.
Early return pattern is the preferred coding style, as it avoids deep indention levels:
if (!t)
return NULL;| printf("%ld%s", val->ld, add_pad ? "" : " "); | ||
| else if (type == FMT_UNSIGNED_LONG) | ||
| printf("%lu", val->lu); | ||
| printf("%lu%s", val->lu, add_pad ? "" : " "); |
There was a problem hiding this comment.
I think it would simpler to add a final printf for the padding. So just leave the above printfs as they are and after this block have something like:
if (add_pad)
puts(" ");|
|
||
| default: | ||
| fprintf(stderr, "Invalid format!\n"); | ||
| break; |
There was a problem hiding this comment.
same here Just add a final padding printf if it is needed.
| devname, genname, nvme_ns_get_serial(n), | ||
| nvme_ns_get_model(n), nvme_ns_get_nsid(n), usage, format, | ||
| nvme_ns_get_firmware(n)); | ||
| return; |
There was a problem hiding this comment.
I'd say when the table allocation fails just error out. no need for a fallback mode.
There was a problem hiding this comment.
No this is not for the allocation error but for the zns list plugin command. The print function used by the both commands but currently the generic table is used by only the list command. (Later I will do chnage the zns list command also to use the generic table.)
|
Looks good. I've tested quickly and for |
This combined table_init() and table_add_columns() functions. Signed-off-by: Tokunori Ikegami <[email protected]>
The value auto populated but change it for the existing tables. Signed-off-by: Tokunori Ikegami <[email protected]>
A space added between each columns but not necessary for end of line. Signed-off-by: Tokunori Ikegami <[email protected]>
Use the generic table code added instead of hard coded table. Signed-off-by: Tokunori Ikegami <[email protected]>
This changes as same with other switch case statements. Signed-off-by: Tokunori Ikegami <[email protected]>
Delete the padding flag by padding in the caller functions. Signed-off-by: Tokunori Ikegami <[email protected]>
6dbe7b3 to
68bfb16
Compare
|
Just fixed for the comments. Thank you. |
| struct table *table_init(void) | ||
| { | ||
| struct table *t; | ||
| struct table *t = malloc(sizeof(struct table)); |
There was a problem hiding this comment.
This function could just be return calloc(1, sizeof(struct table));. Maybe we should drop the function as there is no real value in it and use calloc directly where currently table_init is used. Or do I miss something?
There was a problem hiding this comment.
ah I see, table_free is doing some work and to keep the symetry table_init makes sense. But I think the name shouldbe table_create or so. It's not initializing anything, it's just allocation it.
| } | ||
|
|
||
| return t; | ||
|
|
Also changed the function to return calloc() instead. Signed-off-by: Tokunori Ikegami <[email protected]>
|
Again fixed the review comments. Thank you! |
|
Thanks! |
No description provided.