Re: [PATCH] USB: xhci - fix comparison when checking for duplicate ports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dmitry,

On Wed, 23 Feb 2011 00:54:37 -0800 you wrote:
> 
> which happens because port_array[] is u8 so after integer promotion
> the value is between 0 - 255 (no sign extension happens) but we
> compare it with -1.
> 
> 
> As far as I can see this is a real issue, still compiled only at this
> time.
> 
<snip>
>  			 */
>  			if (xhci->port_array[i] != major_revision &&
> -				xhci->port_array[i] != (u8) -1) {
> +			    xhci->port_array[i] != XHCI_PORT_IGNORE) {
>  				if (xhci->port_array[i] == 0x03)
>  					xhci->num_usb3_ports--;
>  				else
>  					xhci->num_usb2_ports--;
> -				xhci->port_array[i] = (u8) -1;
> +				xhci->port_array[i] = XHCI_PORT_IGNORE;
>  			}

I think you're misreading it. The lines you've replaced are comparing
against "(u8) -1", which is the value -1 but cast to a u8. The result
is the same 0xFF that you've replaced it with.

Not that an explicit #define isn't better, but the patch should not be
described as fixing a bug when all it does is tidy up the code.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux