Skip to content

Commit

Permalink
nvme-print-stdout: add print_array function
Browse files Browse the repository at this point in the history
To reduce the repeated print code for arrays.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t authored and igaw committed Sep 9, 2024
1 parent 93a075b commit 838f21e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -5319,3 +5319,16 @@ struct print_ops *nvme_get_stdout_print_ops(nvme_print_flags_t flags)
stdout_print_ops.flags = flags;
return &stdout_print_ops;
}

void print_array(char *name, __u8 *data, int size)
{
int i;

if (!name || !data || !size)
return;

printf("%s: 0x", name);
for (i = 0; i < size; i++)
printf("%02X", data[size - i - 1]);
printf("\n");
}
1 change: 1 addition & 0 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,5 @@ bool nvme_is_fabrics_reg(int offset);
bool nvme_registers_cmbloc_support(__u32 cmbsz);
bool nvme_registers_pmrctl_ready(__u32 pmrctl);
const char *nvme_degrees_string(long t);
void print_array(char *name, __u8 *data, int size);
#endif /* NVME_PRINT_H */

0 comments on commit 838f21e

Please sign in to comment.