OSDN Git Service

scsi: st: osst: Remove negative constant left-shifts
authorIustin Pop <iustin@k1024.org>
Fri, 22 Feb 2019 00:20:03 +0000 (01:20 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 27 Feb 2019 14:10:16 +0000 (09:10 -0500)
commit6f46f718fcbe7b80ac95e4f4e1bade6efbcff84e
treeefec70cd0a6b86782511270426eced9cad412f79
parent5c17f87abb1a86eb4d2a108477e56389622cf195
scsi: st: osst: Remove negative constant left-shifts

Negative constant left-shift is undefined behaviour in the C standard, and
as such newer versions of clang (at least) warn against it. GCC supports it
for a long time, but it would be better to remove it and rely on defined
behaviour.

My understanding is "~(-1 << N)" in 2's complement is intended to generate
a bit pattern of zeroes ending with N '1' bits. The same can be achieved by
"(1 << N) - 1" in a well-defined way, so switch to it to remove the
warning.

Tested: building a kernel with generic SCSI tape, and checking basic
operations (mt status, mt eject) on a real LTO unit. Cannot test the osst
driver.

Signed-off-by: Iustin Pop <iustin@k1024.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/osst.c
drivers/scsi/st.c