Skip to content

Commit bbb6324

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 ad35010 commit bbb6324

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, __u8 opcode, int err)
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, 0, 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, 0, err);
549+
550+
va_end(ap);
540551
}
541552

542553
void nvme_show_io_cmd_err(const char *msg, __u8 opcode, int err)

nvme-print.h

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

163163
void nvme_show_status(int status);
164-
void nvme_show_err(int err, const char *msg);
164+
void nvme_show_err(int err, const char *fmt, ...);
165165
void nvme_show_io_cmd_err(const char *msg, __u8 opcode, int err);
166166
void nvme_show_admin_cmd_err(const char *msg, __u8 opcode, int err);
167167
void nvme_show_opcode_status(int status, bool admin, __u8 opcode);

0 commit comments

Comments
 (0)