Skip to content

Commit df11a0e

Browse files
ikegami-tigaw
authored andcommitted
nvme-print-stdout: Change hexadecimal value 0x prefix to use %#x
Also channge 64bit value to use %#"PRIx64" instead of 0x%"PRIx64". Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 7b4b50f commit df11a0e

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

nvme-print-stdout.c

+27-27
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ static void stdout_fdp_usage(struct nvme_fdp_ruhu_log *log, size_t len)
878878
for (int i = 0; i < nruh; i++) {
879879
struct nvme_fdp_ruhu_desc *ruhu = &log->ruhus[i];
880880

881-
printf("Reclaim Unit Handle %d Attributes: 0x%"PRIx8" (%s)\n", i, ruhu->ruha,
881+
printf("Reclaim Unit Handle %d Attributes: %#"PRIx8" (%s)\n", i, ruhu->ruha,
882882
ruhu->ruha == 0x0 ? "Unused" : (
883883
ruhu->ruha == 0x1 ? "Host Specified" : (
884884
ruhu->ruha == 0x2 ? "Controller Specified" : "Unknown")));
@@ -909,13 +909,13 @@ static void stdout_fdp_events(struct nvme_fdp_events_log *log)
909909
tm = localtime(&ts);
910910

911911
printf("Event[%u]\n", i);
912-
printf(" Event Type: 0x%"PRIx8" (%s)\n", event->type,
912+
printf(" Event Type: %#"PRIx8" (%s)\n", event->type,
913913
nvme_fdp_event_to_string(event->type));
914914
printf(" Event Timestamp: %"PRIu64" (%s)\n", int48_to_long(event->ts.timestamp),
915915
strftime(buffer, sizeof(buffer), "%c %Z", tm) ? buffer : "-");
916916

917917
if (event->flags & NVME_FDP_EVENT_F_PIV)
918-
printf(" Placement Identifier (PID): 0x%"PRIx16"\n",
918+
printf(" Placement Identifier (PID): %#"PRIx16"\n",
919919
le16_to_cpu(event->pid));
920920

921921
if (event->flags & NVME_FDP_EVENT_F_NSIDV)
@@ -929,7 +929,7 @@ static void stdout_fdp_events(struct nvme_fdp_events_log *log)
929929
printf(" Number of LBAs Moved (NLBAM): %"PRIu16"\n", le16_to_cpu(mr->nlbam));
930930

931931
if (mr->flags & NVME_FDP_EVENT_REALLOC_F_LBAV)
932-
printf(" Logical Block Address (LBA): 0x%"PRIx64"\n",
932+
printf(" Logical Block Address (LBA): %#"PRIx64"\n",
933933
le64_to_cpu(mr->lba));
934934
}
935935

@@ -1247,7 +1247,7 @@ static void stdout_registers_cmbloc(__u32 cmbloc, __u32 cmbsz)
12471247
return;
12481248
}
12491249
printf("\tOffset (OFST): ");
1250-
printf("0x%x (See cmbsz.szu for granularity)\n", (cmbloc & 0xfffff000) >> 12);
1250+
printf("%#x (See cmbsz.szu for granularity)\n", (cmbloc & 0xfffff000) >> 12);
12511251

12521252
printf("\tCMB Queue Dword Alignment (CQDA): %d\n",
12531253
(cmbloc & 0x00000100) >> 8);
@@ -1267,7 +1267,7 @@ static void stdout_registers_cmbloc(__u32 cmbloc, __u32 cmbsz)
12671267
printf("\tCMB Queue Mixed Memory Support (CQMMS): %s\n",
12681268
enforced[(cmbloc & 0x00000008) >> 3]);
12691269

1270-
printf("\tBase Indicator Register (BIR): 0x%x\n\n",
1270+
printf("\tBase Indicator Register (BIR): %#x\n\n",
12711271
(cmbloc & 0x00000007));
12721272
}
12731273

@@ -1589,10 +1589,10 @@ static void stdout_single_property(int offset, uint64_t value64)
15891589

15901590
if (!human) {
15911591
if (nvme_is_64bit_reg(offset))
1592-
printf("property: 0x%02x (%s), value: %"PRIx64"\n",
1592+
printf("property: %#02x (%s), value: %#"PRIx64"\n",
15931593
offset, nvme_register_to_string(offset), value64);
15941594
else
1595-
printf("property: 0x%02x (%s), value: %x\n", offset,
1595+
printf("property: %#02x (%s), value: %#x\n", offset,
15961596
nvme_register_to_string(offset), value32);
15971597
return;
15981598
}
@@ -1627,7 +1627,7 @@ static void stdout_single_property(int offset, uint64_t value64)
16271627
stdout_registers_crto(value32);
16281628
break;
16291629
default:
1630-
printf("unknown property: 0x%02x (%s), value: %"PRIx64"\n",
1630+
printf("unknown property: %#02x (%s), value: %"PRIx64"\n",
16311631
offset, nvme_register_to_string(offset), value64);
16321632
break;
16331633
}
@@ -3246,12 +3246,12 @@ static void stdout_zns_id_ns(struct nvme_zns_id_ns *ns,
32463246

32473247
for (i = 0; i <= id_ns->nlbaf; i++) {
32483248
if (human)
3249-
printf("LBA Format Extension %2d : Zone Size: 0x%"PRIx64" LBAs - "
3249+
printf("LBA Format Extension %2d : Zone Size: %#"PRIx64" LBAs - "
32503250
"Zone Descriptor Extension Size: %-1d bytes%s\n",
32513251
i, le64_to_cpu(ns->lbafe[i].zsze), ns->lbafe[i].zdes << 6,
32523252
i == lbaf ? " (in use)" : "");
32533253
else
3254-
printf("lbafe %2d: zsze:0x%"PRIx64" zdes:%u%s\n", i,
3254+
printf("lbafe %2d: zsze:%#"PRIx64" zdes:%u%s\n", i,
32553255
(uint64_t)le64_to_cpu(ns->lbafe[i].zsze),
32563256
ns->lbafe[i].zdes, i == lbaf ? " (in use)" : "");
32573257
}
@@ -3442,18 +3442,18 @@ static void stdout_list_secondary_ctrl(const struct nvme_secondary_ctrl_list *sc
34423442
for (i = 0; i < entries; i++) {
34433443
printf(" SCEntry[%-3d]:\n", i);
34443444
printf("................\n");
3445-
printf(" SCID : Secondary Controller Identifier : 0x%.04x\n",
3445+
printf(" SCID : Secondary Controller Identifier : %#.04x\n",
34463446
le16_to_cpu(sc_entry[i].scid));
3447-
printf(" PCID : Primary Controller Identifier : 0x%.04x\n",
3447+
printf(" PCID : Primary Controller Identifier : %#.04x\n",
34483448
le16_to_cpu(sc_entry[i].pcid));
3449-
printf(" SCS : Secondary Controller State : 0x%.04x (%s)\n",
3449+
printf(" SCS : Secondary Controller State : %#.04x (%s)\n",
34503450
sc_entry[i].scs,
34513451
state_desc[sc_entry[i].scs & 0x1]);
3452-
printf(" VFN : Virtual Function Number : 0x%.04x\n",
3452+
printf(" VFN : Virtual Function Number : %#.04x\n",
34533453
le16_to_cpu(sc_entry[i].vfn));
3454-
printf(" NVQ : Num VQ Flex Resources Assigned : 0x%.04x\n",
3454+
printf(" NVQ : Num VQ Flex Resources Assigned : %#.04x\n",
34553455
le16_to_cpu(sc_entry[i].nvq));
3456-
printf(" NVI : Num VI Flex Resources Assigned : 0x%.04x\n",
3456+
printf(" NVI : Num VI Flex Resources Assigned : %#.04x\n",
34573457
le16_to_cpu(sc_entry[i].nvi));
34583458
}
34593459
}
@@ -3463,7 +3463,7 @@ static void stdout_id_ns_granularity_list(const struct nvme_id_ns_granularity_li
34633463
int i;
34643464

34653465
printf("Identify Namespace Granularity List:\n");
3466-
printf(" ATTR : Namespace Granularity Attributes: 0x%x\n",
3466+
printf(" ATTR : Namespace Granularity Attributes: %#x\n",
34673467
glist->attributes);
34683468
printf(" NUMD : Number of Descriptors : %d\n",
34693469
glist->num_descriptors);
@@ -3472,9 +3472,9 @@ static void stdout_id_ns_granularity_list(const struct nvme_id_ns_granularity_li
34723472
for (i = 0; i <= glist->num_descriptors; i++) {
34733473
printf("\n Entry[%2d] :\n", i);
34743474
printf("................\n");
3475-
printf(" NSG : Namespace Size Granularity : 0x%"PRIx64"\n",
3475+
printf(" NSG : Namespace Size Granularity : %#"PRIx64"\n",
34763476
le64_to_cpu(glist->entry[i].nszegran));
3477-
printf(" NCG : Namespace Capacity Granularity : 0x%"PRIx64"\n",
3477+
printf(" NCG : Namespace Capacity Granularity : %#"PRIx64"\n",
34783478
le64_to_cpu(glist->entry[i].ncapgran));
34793479
}
34803480
}
@@ -3511,7 +3511,7 @@ static void stdout_id_uuid_list(const struct nvme_id_uuid_list *uuid_list)
35113511
}
35123512
printf(" Entry[%3d]\n", i+1);
35133513
printf(".................\n");
3514-
printf("association : 0x%x %s\n", identifier_association, association);
3514+
printf("association : %#x %s\n", identifier_association, association);
35153515
printf("UUID : %s", util_uuid_to_string(uuid));
35163516
if (memcmp(uuid_list->entry[i].uuid, invalid_uuid,
35173517
sizeof(zero_uuid)) == 0)
@@ -3825,7 +3825,7 @@ static void stdout_supported_log(struct nvme_supported_log_pages *support_log,
38253825
for (lid = 0; lid < 256; lid++) {
38263826
support = le32_to_cpu(support_log->lid_support[lid]);
38273827
if (support & 0x1) {
3828-
printf("LID 0x%x - %s\n", lid, nvme_log_to_string(lid));
3828+
printf("LID %#x - %s\n", lid, nvme_log_to_string(lid));
38293829
if (human)
38303830
stdout_support_log_human(support, lid);
38313831
}
@@ -4223,9 +4223,9 @@ static void stdout_host_mem_buffer(struct nvme_host_mem_buf_attrs *hmb)
42234223
{
42244224
printf("\tHost Memory Descriptor List Entry Count (HMDLEC): %u\n",
42254225
le32_to_cpu(hmb->hmdlec));
4226-
printf("\tHost Memory Descriptor List Address (HMDLAU): 0x%x\n",
4226+
printf("\tHost Memory Descriptor List Address (HMDLAU): %#x\n",
42274227
le32_to_cpu(hmb->hmdlau));
4228-
printf("\tHost Memory Descriptor List Address (HMDLAL): 0x%x\n",
4228+
printf("\tHost Memory Descriptor List Address (HMDLAL): %#x\n",
42294229
le32_to_cpu(hmb->hmdlal));
42304230
printf("\tHost Memory Buffer Size (HSIZE): %u\n",
42314231
le32_to_cpu(hmb->hsize));
@@ -4387,7 +4387,7 @@ static void stdout_host_metadata(enum nvme_features_id fid,
43874387
strncpy(val, (char *)desc->val, min(sizeof(val) - 1, len));
43884388

43894389
printf("\tElement[%-3d]:\n", i);
4390-
printf("\t\tType : 0x%02x (%s)\n", desc->type,
4390+
printf("\t\tType : %#02x (%s)\n", desc->type,
43914391
nvme_host_metadata_type_to_string(fid, desc->type));
43924392
printf("\t\tRevision : %d\n", desc->rev);
43934393
printf("\t\tLength : %d\n", len);
@@ -4636,7 +4636,7 @@ static void stdout_lba_status(struct nvme_lba_status *list,
46364636
for (idx = 0; idx < list->nlsd; idx++) {
46374637
struct nvme_lba_status_desc *e = &list->descs[idx];
46384638

4639-
printf("{ DSLBA: 0x%016"PRIx64", NLB: 0x%08x, Status: 0x%02x }\n",
4639+
printf("{ DSLBA: %#016"PRIx64", NLB: %#08x, Status: %#02x }\n",
46404640
le64_to_cpu(e->dslba), le32_to_cpu(e->nlb),
46414641
e->status);
46424642
}
@@ -5101,7 +5101,7 @@ static void stdout_discovery_log(struct nvmf_discovery_log *log, int numrec)
51015101
nvmf_qptype_str(e->tsas.rdma.qptype));
51025102
printf("rdma_cms: %s\n",
51035103
nvmf_cms_str(e->tsas.rdma.cms));
5104-
printf("rdma_pkey: 0x%04x\n",
5104+
printf("rdma_pkey: %#04x\n",
51055105
le16_to_cpu(e->tsas.rdma.pkey));
51065106
break;
51075107
case NVMF_TRTYPE_TCP:

0 commit comments

Comments
 (0)