[ofa-general] [PATCH 2/2] libibmad: print warning when _do_madrpc fails with destination port information
Sasha Khapyorsky
sashak at voltaire.com
Fri Jun 27 08:08:11 PDT 2008
Hi Ira,
On 16:09 Wed 25 Jun , Ira Weiny wrote:
>
> >From ec5c867213d58a2a297a2ca817b50266f55a35bd Mon Sep 17 00:00:00 2001
> From: Ira K. Weiny <weiny2 at llnl.gov>
> Date: Tue, 24 Jun 2008 14:43:24 -0700
> Subject: [PATCH] libibmad: print warning containing destination port when _do_madrpc fails
>
>
> Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
Applied. Thanks.
> >From 31c73fc09fab80e599559e5de501708dc0f0899e Mon Sep 17 00:00:00 2001
> From: Ira K. Weiny <weiny2 at llnl.gov>
> Date: Wed, 25 Jun 2008 15:08:13 -0700
> Subject: [PATCH] libibmad: update portid2str to use inet_ntop and drpath2str functions for gid
>
> and drpath printing respectively
>
> Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
Applied this with change Hal mentioned and removing unsuned 'i' variable.
Thanks.
Also do you think that intermidiate buffer could be removed here with
something like below?
Sasha
diff --git a/libibmad/src/portid.c b/libibmad/src/portid.c
index 1c0e38a..c6b5135 100644
--- a/libibmad/src/portid.c
+++ b/libibmad/src/portid.c
@@ -66,23 +66,22 @@ char *
portid2str(ib_portid_t *portid)
{
static char buf[1024] = "local";
- char drpath[512];
- char *s = buf;
+ int n = 0;
if (portid->lid > 0) {
- s += sprintf(s, "Lid %d", portid->lid);
+ n += sprintf(buf + n, "Lid %d", portid->lid);
if (portid->grh_present) {
char gid[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
if (inet_ntop(AF_INET6, portid->gid, gid, sizeof(gid)))
- s += sprintf(s, " Gid %s", gid);
+ n += sprintf(buf + n, " Gid %s", gid);
}
if (portid->drpath.cnt)
- s += sprintf(s, " ");
+ n += sprintf(buf + n, " ");
else
return buf;
}
- s += sprintf(s, "DR path %s",
- drpath2str(&(portid->drpath), drpath, sizeof(drpath)));
+ n += sprintf(buf + n, "DR path ");
+ drpath2str(&(portid->drpath), buf + n, sizeof(buf) - n);
return buf;
}
More information about the general
mailing list