public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
To: "hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org"
	<hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>,
	"dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
	<dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "honli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
	<honli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH rdma-core 3/3] srp_daemon: Use consistent format when printing LID
Date: Thu, 13 Apr 2017 15:29:55 +0000	[thread overview]
Message-ID: <1492097392.3298.6.camel@sandisk.com> (raw)
In-Reply-To: <f6f32353-bdcc-6dfa-bf52-1b03ebab1eee-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>

On Thu, 2017-04-13 at 10:48 -0400, Hal Rosenstock wrote:
> %d is not good as LIDs above 32K print as negative numbers.
> %#x seems to be the right choice here; %u was used by IB
> management tools for unicast LID printing.

Hello Hal,

Although the patch itself looks fine to me: LIDs are converted from network
to host format using be16toh(). That function returns an unsigned 16-bit
number. These numbers are converted to type "int" before pr_err() is called.
The type "int" is at least 32 bits on all architectures supported by Linux.
So how could using %d result in a negative number being printed?

> diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c
> index 59a6137..4d8476e 100644
> --- a/srp_daemon/srp_daemon.c
> +++ b/srp_daemon/srp_daemon.c
> @@ -632,7 +632,7 @@ recv:
>  			ret = umad_status(in_mad);
>  			if (ret) {
>  				pr_err(
> -					"bad MAD status (%u) from lid %d\n",
> +					"bad MAD status (%u) from lid %#x\n",
>  					ret, (uint16_t) be16toh(out_mad->hdr.addr.lid));
>  				return -ret;

If you have to repost this patch, please remove the (uint16_t) cast since it's
superfluous.

Thanks,

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-04-13 15:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13 14:48 [PATCH rdma-core 3/3] srp_daemon: Use consistent format when printing LID Hal Rosenstock
     [not found] ` <f6f32353-bdcc-6dfa-bf52-1b03ebab1eee-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2017-04-13 15:29   ` Bart Van Assche [this message]
     [not found]     ` <1492097392.3298.6.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-04-13 15:44       ` Hal Rosenstock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492097392.3298.6.camel@sandisk.com \
    --to=bart.vanassche-xdaiopvojttbdgjk7y7tuq@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
    --cc=honli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox