From: Nathan Chancellor <natechancellor@gmail.com>
To: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: -Wswitch Clang warnings in drivers/scsi
Date: Thu, 4 Oct 2018 11:30:47 -0700 [thread overview]
Message-ID: <20181004183047.GA1885@flashbox> (raw)
Hi SCSI folks,
In an effort to get the kernel building warning free with Clang, we've
come across an interesting occurrence in a few scsi drivers:
drivers/scsi/hpsa.c:6533:7: warning: overflow converting case value to switch condition type (2148024833 to 18446744071562609153) [-Wswitch]
case CCISS_GETPCIINFO:
^
./include/uapi/linux/cciss_ioctl.h:65:26: note: expanded from macro 'CCISS_GETPCIINFO'
#define CCISS_GETPCIINFO _IOR(CCISS_IOC_MAGIC, 1, cciss_pci_info_struct)
^
./include/uapi/asm-generic/ioctl.h:86:28: note: expanded from macro '_IOR'
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
^
./include/uapi/asm-generic/ioctl.h:70:2: note: expanded from macro '_IOC'
(((dir) << _IOC_DIRSHIFT) | \
^
I see this warning in drivers/scsi/hpsa.c and drivers/scsi/smartpqi/smartpqi_init.c
on an arm64 allyesconfig build and it has also been reported in a couple of files in
drivers/scsi/cxlflash.
As the warning states, there is an overflow because the switch statement's value is of
type int but the switch value is greater than INT_MAX. I did a brief sweep of the tree
and it seems that all uses of _IOC in switch statement values either are small enough
to fit into size int or the value is of size unsigned int.
I am unsure of the implications of using a smaller _IOC value or converting all ioctls
to expect a cmd of type unsigned int (especially since that has userspace implications)
but I didn't see any negative ioctl commands. Some clarity and insight would be
appreciated.
Thank you for your time,
Nathan
next reply other threads:[~2018-10-04 18:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-04 18:30 Nathan Chancellor [this message]
2018-10-04 18:34 ` -Wswitch Clang warnings in drivers/scsi Bart Van Assche
2018-10-04 18:45 ` Nathan Chancellor
2018-10-04 21:16 ` Nick Desaulniers
2018-10-05 6:57 ` Nathan Chancellor
2018-10-08 18:12 ` Nick Desaulniers
2018-10-08 18:47 ` Bart Van Assche
2018-10-08 18:47 ` Bart Van Assche
2018-10-19 6:51 ` Nathan Chancellor
2018-10-19 13:55 ` Bart Van Assche
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=20181004183047.GA1885@flashbox \
--to=natechancellor@gmail.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.