[ofa-general] [PATCH 2/2] libibmad: print warning when _do_madrpc fails with destination port information
Ira Weiny
weiny2 at llnl.gov
Fri Jun 27 09:12:24 PDT 2008
On Fri, 27 Jun 2008 18:08:11 +0300
Sasha Khapyorsky <sashak at voltaire.com> wrote:
> Hi Ira,
>
> On 16:09 Wed 25 Jun , Ira Weiny wrote:
> >
<snip>
> > 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?
Yea that looks like it would work. Looks more efficient as well... ;-)
Ira
>
> 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