Linux wireless drivers development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: linux-wireless@vger.kernel.org
Subject: NFC: smatch stuff: min_t() casting
Date: Fri, 16 Dec 2011 23:26:38 +0300	[thread overview]
Message-ID: <20111216202638.GC18570@elgon.mountain> (raw)

Hi Sam,

Smatch complains about the min_t() casting here.

net/nfc/llcp/sock.c +80 llcp_sock_bind(44)
	warn: min_t truncates here '(llcp_addr.service_name_len)' (4294967295 vs 9223372036854775807)

    78          llcp_sock->local = local;
    79          llcp_sock->nfc_protocol = llcp_addr.nfc_protocol;
    80          llcp_sock->service_name_len = min_t(unsigned int,
    81                          llcp_addr.service_name_len, NFC_LLCP_MAX_SERVICE_NAME);
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
Smatch complains that .service_name_len is a size_t (64 bits on 64 bit
architectures).  The cast to unsigned int takes the minimum of the
truncated value.

    82          llcp_sock->service_name = kmemdup(llcp_addr.service_name,
    83                                  llcp_sock->service_name_len, GFP_KERNEL);


These two functions are the same way.

net/nfc/llcp/sock.c +461 llcp_sock_connect(71)
	warn: min_t truncates here '(addr->service_name_len)' (4294967295 vs 9223372036854775807)
net/nfc/llcp/sock.c +521 llcp_sock_recvmsg(36) warn:
	min_t truncates here '(len)' (4294967295 vs 9223372036854775807)

It's not really an issue, but it's slightly untidy.

regards,
dan carpenter

                 reply	other threads:[~2011-12-16 20:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20111216202638.GC18570@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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