Skip to content

Commit 94d4b04

Browse files
committed
nvme-print: change nvme_show_err parameter msg to fmt
To handle fmt with the variable length arguments. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent cf08758 commit 94d4b04

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

nvme-print.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,20 @@ static void nvme_show_cmd_err(const char *msg, bool admin,
534534
nvme_show_status(err);
535535
}
536536

537-
void nvme_show_err(int err, const char *msg)
537+
void nvme_show_err(int err, const char *fmt, ...)
538538
{
539-
nvme_show_cmd_err(msg, false, NULL, err);
539+
va_list ap;
540+
541+
_cleanup_free_ char *msg = NULL;
542+
543+
va_start(ap, fmt);
544+
545+
if (vasprintf(&msg, fmt, ap) < 0)
546+
msg = NULL;
547+
548+
nvme_show_cmd_err(msg ? msg : alloc_error, false, NULL, err);
549+
550+
va_end(ap);
540551
}
541552

542553
void nvme_show_io_cmd_err(const char *msg, struct nvme_passthru_cmd *cmd,

nvme-print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ struct print_ops *nvme_get_stdout_print_ops(nvme_print_flags_t flags);
159159
struct print_ops *nvme_get_binary_print_ops(nvme_print_flags_t flags);
160160

161161
void nvme_show_status(int status);
162-
void nvme_show_err(int err, const char *msg);
162+
void nvme_show_err(int err, const char *fmt, ...);
163163
void nvme_show_io_cmd_err(const char *msg, struct nvme_passthru_cmd *cmd,
164164
int err);
165165
void nvme_show_admin_cmd_err(const char *msg, struct nvme_passthru_cmd *cmd,

0 commit comments

Comments
 (0)