RE: [PATCH] scsi: aic7xxx: Fix unintended sign extension issue

2018-10-25 Thread David Laight
From: James Bottomley > Sent: 25 October 2018 16:33 > > On Thu, 2018-10-25 at 16:13 +0100, Colin King wrote: > > From: Colin Ian King > > > > In the expression "ahc_inb(ahc, port+3) << 24", the initial value is > > a u8, but is promoted to a signed int, then sign-extended to > > uint64_t. > > Wh

Re: [PATCH] scsi: aic7xxx: Fix unintended sign extension issue

2018-10-25 Thread James Bottomley
On Thu, 2018-10-25 at 16:13 +0100, Colin King wrote: > From: Colin Ian King > > In the expression "ahc_inb(ahc, port+3) << 24", the initial value is > a u8, but is promoted to a signed int, then sign-extended to > uint64_t. Why is this, that's highly non intuitive? The compiler is supposed to p

Re: [PATCH] scsi: aic7xxx: Fix unintended sign extension issue

2018-10-25 Thread Joe Perches
On Thu, 2018-10-25 at 16:13 +0100, Colin King wrote: > From: Colin Ian King > > In the expression "ahc_inb(ahc, port+3) << 24", the initial value is a > u8, but is promoted to a signed int, then sign-extended to uint64_t. If > the value read from the port has the upper bit set then the sign > ex

[PATCH] scsi: aic7xxx: Fix unintended sign extension issue

2018-10-25 Thread Colin King
From: Colin Ian King In the expression "ahc_inb(ahc, port+3) << 24", the initial value is a u8, but is promoted to a signed int, then sign-extended to uint64_t. If the value read from the port has the upper bit set then the sign extension will set all the upper bits of the expression which is pr