Soewono Effendi wrote:
> Hi all,
> 
> 
> I'm just curious if there is any particular reason to use the following code
> 
>          return !!*buf;
> 
> instead of the simple
> 
>       return (int) *buf;
> 

This would be a trick to return 0 or 1.
Take for example *buf equal to 3.
!*buf -> !3 -> !(true) -> false -> 0
!!*buf -> !0 -> 1

return !!*buf returns 1, while return (int) *buf returns 3;

> in function "uhci_hub_status_data", file: usb/host/uhci-hub.c
> 
> static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
> {
>       struct uhci_hcd *uhci = hcd_to_uhci(hcd);
>         unsigned int io_addr = uhci->io_addr;
>         int i, len = 1;
> 
>         *buf = 0;
>         for (i = 0; i < uhci->rh_numports; i++) {
>                  *buf |= ((inw(io_addr + USBPORTSC1 + i * 2) & 0xa) > 0 ? (1 << (i + 
>1)) : 0);
>                  len = (i + 1) / 8 + 1;
>          }
>  
>          return !!*buf;
> }
> 
> 
> Little notes in code will be helpful.
> 
> Best regards,
> sE
> 



-- 
Johann Deneux



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to