Linux wireless drivers development
 help / color / mirror / Atom feed
* NFC: smatch stuff: min_t() casting
@ 2011-12-16 20:26 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2011-12-16 20:26 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-wireless

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-16 20:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-16 20:26 NFC: smatch stuff: min_t() casting Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox