* [PATCH] nvme-cli: minor cleanup for sibmit_io()
@ 2019-01-29 7:12 Chaitanya Kulkarni
2019-01-29 14:50 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Chaitanya Kulkarni @ 2019-01-29 7:12 UTC (permalink / raw)
This is a cleanup patch which adds errno based error messages when
write() failure, this also fixes minor typo and removes unnecessary
braces.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
nvme.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/nvme.c b/nvme.c
index 7cf65a9..b6f8478 100644
--- a/nvme.c
+++ b/nvme.c
@@ -4314,7 +4314,7 @@ static int submit_io(int opcode, char *command, const char *desc,
dsmgmt |= ((__u32)cfg.dspec) << 16;
}
- if (strlen(cfg.data)){
+ if (strlen(cfg.data)) {
dfd = open(cfg.data, flags, mode);
if (dfd < 0) {
perror(cfg.data);
@@ -4323,7 +4323,7 @@ static int submit_io(int opcode, char *command, const char *desc,
}
mfd = dfd;
}
- if (strlen(cfg.metadata)){
+ if (strlen(cfg.metadata)) {
mfd = open(cfg.metadata, flags, mode);
if (mfd < 0) {
perror(cfg.metadata);
@@ -4345,9 +4345,8 @@ static int submit_io(int opcode, char *command, const char *desc,
if (cfg.data_size < buffer_size) {
fprintf(stderr, "Rounding data size to fit block count (%lld bytes)\n",
buffer_size);
- } else {
+ } else
buffer_size = cfg.data_size;
- }
if (posix_memalign(&buffer, getpagesize(), buffer_size)) {
fprintf(stderr, "can not allocate io payload\n");
@@ -4416,11 +4415,13 @@ static int submit_io(int opcode, char *command, const char *desc,
printf("%s:%s(%04x)\n", command, nvme_status_to_string(err), err);
else {
if (!(opcode & 1) && write(dfd, (void *)buffer, cfg.data_size) < 0) {
- fprintf(stderr, "failed to write buffer to output file\n");
+ fprintf(stderr, "write: %s: failed to write buffer to output file\n",
+ strerror(errno));
err = EINVAL;
} else if (!(opcode & 1) && cfg.metadata_size &&
write(mfd, (void *)mbuffer, cfg.metadata_size) < 0) {
- fprintf(stderr, "failed to write meta-data buffer to output file\n");
+ fprintf(stderr, "write: %s: failed to write meta-data buffer to output file\n",
+ strerror(errno));
err = EINVAL;
} else
fprintf(stderr, "%s: Success\n", command);
--
2.20.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] nvme-cli: minor cleanup for sibmit_io()
2019-01-29 7:12 [PATCH] nvme-cli: minor cleanup for sibmit_io() Chaitanya Kulkarni
@ 2019-01-29 14:50 ` Bart Van Assche
2019-01-29 15:46 ` Keith Busch
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2019-01-29 14:50 UTC (permalink / raw)
On 1/28/19 11:12 PM, Chaitanya Kulkarni wrote:
> - } else {
> + } else
> buffer_size = cfg.data_size;
> - }
Does nvme-cli follow the kernel coding style? The kernel coding style
guide explicitly mentions that braces should be balanced. So this patch
changes codes that conforms to that style guide into code that does not
conform.
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH] nvme-cli: minor cleanup for sibmit_io()
2019-01-29 14:50 ` Bart Van Assche
@ 2019-01-29 15:46 ` Keith Busch
0 siblings, 0 replies; 3+ messages in thread
From: Keith Busch @ 2019-01-29 15:46 UTC (permalink / raw)
On Tue, Jan 29, 2019@06:50:56AM -0800, Bart Van Assche wrote:
> On 1/28/19 11:12 PM, Chaitanya Kulkarni wrote:
> > - } else {
> > + } else
> > buffer_size = cfg.data_size;
> > - }
>
> Does nvme-cli follow the kernel coding style? The kernel coding style guide
> explicitly mentions that braces should be balanced. So this patch changes
> codes that conforms to that style guide into code that does not conform.
Yes, kernel is the coding style we try to adhere to for this project. Most
of the changes here are in that direction, so I'll just fix up this one
on the commit.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-29 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-29 7:12 [PATCH] nvme-cli: minor cleanup for sibmit_io() Chaitanya Kulkarni
2019-01-29 14:50 ` Bart Van Assche
2019-01-29 15:46 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox