Skip to content

Commit

Permalink
logging: fix error handling for ioctl passthru wrappers
Browse files Browse the repository at this point in the history
libnvme fixed the error handling for the passthru commands. Update the
nvme-cli version accordingly.

Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
igaw committed Apr 9, 2024
1 parent a82d948 commit a2b1aec
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions util/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <inttypes.h>

#include <errno.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
Expand Down Expand Up @@ -104,8 +105,14 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
nvme_show_latency(start, end);
}

if (err >= 0 && result)
*result = cmd->result;
if (err >= 0) {
if (result)
*result = cmd->result;
if (cmd->result) {
errno = EPROTO;
err = -1;
}
}

return err;
}
Expand All @@ -131,8 +138,14 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
nvme_show_latency(start, end);
}

if (err >= 0 && result)
*result = cmd->result;
if (err >= 0) {
if (result)
*result = cmd->result;
if (cmd->result) {
errno = EPROTO;
err = -1;
}
}

return err;
}

0 comments on commit a2b1aec

Please sign in to comment.