Skip to content

Commit 03006b9

Browse files
calebsanderigaw
authored andcommitted
nvme: avoid unnecessary dup() + close() in io_mgmt_send()
_cleanup_fd_ doesn't close STD{IN,OUT,ERR}_FILENO, so don't bother creating a duplicate fd. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Fixes: 7e1f679 ("nvme: use cleanup helper to close file descriptor")
1 parent 4e61659 commit 03006b9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

nvme.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ static int io_mgmt_send(int argc, char **argv, struct command *cmd, struct plugi
20712071
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
20722072
_cleanup_free_ void *buf = NULL;
20732073
int err = -1;
2074-
_cleanup_fd_ int dfd = -1;
2074+
_cleanup_fd_ int dfd = STDIN_FILENO;
20752075

20762076
struct config {
20772077
__u16 mos;
@@ -2116,8 +2116,7 @@ static int io_mgmt_send(int argc, char **argv, struct command *cmd, struct plugi
21162116
nvme_show_perror(cfg.file);
21172117
return -errno;
21182118
}
2119-
} else
2120-
dfd = dup(STDIN_FILENO);
2119+
}
21212120

21222121
err = read(dfd, buf, cfg.data_len);
21232122
if (err < 0) {

0 commit comments

Comments
 (0)