From 6811edb82791b1cc18889062a226522b7cdd74a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Sun, 26 Dec 2021 22:11:51 +0100 Subject: [PATCH] lspci: Replace unsigned long long type by u64 and %llx format by PCI_U64_FMT_X pciutils already provides and uses u64 type together with PCI_U64_FMT_X format macro for printing hex value of this type. So use u64 and PCI_U64_FMT_X also on other few remaining places. This change fixes printing hexadecimal 64-bit numbers by lspci on Window systems independently of used compiler (MinGW or MSVC). --- ls-caps.c | 2 +- ls-ecaps.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ls-caps.c b/ls-caps.c index 79b61cd..b0caa50 100644 --- a/ls-caps.c +++ b/ls-caps.c @@ -578,7 +578,7 @@ cap_ht(struct device *d, int where, int cmd) break; offl = get_conf_long(d, where + PCI_HT_MSIM_ADDR_LO); offh = get_conf_long(d, where + PCI_HT_MSIM_ADDR_HI); - printf("\t\tMapping Address Base: %016llx\n", ((unsigned long long)offh << 32) | (offl & ~0xfffff)); + printf("\t\tMapping Address Base: %016" PCI_U64_FMT_X "\n", ((u64)offh << 32) | (offl & ~0xfffff)); } break; case PCI_HT_CMD_TYP_DR: diff --git a/ls-ecaps.c b/ls-ecaps.c index 1cea315..bd29c99 100644 --- a/ls-ecaps.c +++ b/ls-ecaps.c @@ -68,12 +68,12 @@ cap_ltr(struct device *d, int where) snoop = get_conf_word(d, where + PCI_LTR_MAX_SNOOP); scale = cap_ltr_scale((snoop >> PCI_LTR_SCALE_SHIFT) & PCI_LTR_SCALE_MASK); printf("\t\tMax snoop latency: %lldns\n", - ((unsigned long long)snoop & PCI_LTR_VALUE_MASK) * scale); + ((u64)snoop & PCI_LTR_VALUE_MASK) * scale); nosnoop = get_conf_word(d, where + PCI_LTR_MAX_NOSNOOP); scale = cap_ltr_scale((nosnoop >> PCI_LTR_SCALE_SHIFT) & PCI_LTR_SCALE_MASK); printf("\t\tMax no snoop latency: %lldns\n", - ((unsigned long long)nosnoop & PCI_LTR_VALUE_MASK) * scale); + ((u64)nosnoop & PCI_LTR_VALUE_MASK) * scale); } static void @@ -826,7 +826,7 @@ cap_l1pm(struct device *d, int where) if (scale > 5) printf(" LTR1.2_Threshold="); else - printf(" LTR1.2_Threshold=%lldns", BITS(val, 16, 10) * (unsigned long long) cap_ltr_scale(scale)); + printf(" LTR1.2_Threshold=%lldns", BITS(val, 16, 10) * (u64) cap_ltr_scale(scale)); } printf("\n"); } -- 2.39.2