[ofa-general] Re: [PATCH] infiniband-diags: eliminate compiler warnings
Sasha Khapyorsky
sashak at voltaire.com
Fri Sep 26 15:44:13 PDT 2008
Hi Jack,
On 16:59 Wed 24 Sep , Jack Morgenstein wrote:
> infiniband: eliminate compiler warnings on x86_64
>
> The printf's below generated warnings of the form:
> warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'long long unsigned int'
> on 64-bit systems -- due to the influence of the <>ull constants. Casting solves this.
>
> Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>
> ---
>
> Please fix for upcoming OFED 1.4 release candidate.
>
> Index: infiniband-diags/src/ibping.c
> ===================================================================
> --- infiniband-diags.orig/src/ibping.c 2008-09-21 17:09:26.000000000 +0300
> +++ infiniband-diags/src/ibping.c 2008-09-24 16:38:16.000000000 +0300
> @@ -174,7 +174,7 @@ report(int sig)
> printf("\n--- %s (%s) ibping statistics ---\n", last_host, portid2str(&portid));
> printf("%" PRIu64 " packets transmitted, %" PRIu64 " received, %" PRIu64 "%% packet loss, time %" PRIu64 " ms\n",
> ntrans, replied,
> - (lost != 0) ? lost * 100ull / ntrans : 0ull, total_time / 1000ull);
> + (uint64_t) ((lost != 0) ? lost * 100ull / ntrans : 0ull), (uint64_t) (total_time / 1000ull));
I think instead of casting just removing 'ull' should solve the issue.
Something like:
diff --git a/infiniband-diags/src/ibping.c b/infiniband-diags/src/ibping.c
index e847f42..bc3bc84 100644
--- a/infiniband-diags/src/ibping.c
+++ b/infiniband-diags/src/ibping.c
@@ -174,7 +174,7 @@ report(int sig)
printf("\n--- %s (%s) ibping statistics ---\n", last_host, portid2str(&portid));
printf("%" PRIu64 " packets transmitted, %" PRIu64 " received, %" PRIu64 "%% packet loss, time %" PRIu64 " ms\n",
ntrans, replied,
- (lost != 0) ? lost * 100ull / ntrans : 0ull, total_time / 1000ull);
+ (lost != 0) ? lost * 100 / ntrans : 0, total_time / 1000);
printf("rtt min/avg/max = %" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03" PRIu64 " ms\n",
minrtt == ~0ull ? 0 : minrtt/1000,
minrtt == ~0ull ? 0 : minrtt%1000,
Does it work for you?
Sasha
More information about the general
mailing list