Re: how can this code compile?

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Tue, 20 Mar 2007, Oliver Neukum wrote:

> Hi,
> 
> from urb.c::usb_kill_urb():
> 
> 	if (!(urb && urb->dev && urb->dev->bus))
> 		return;
> 
> Is this safe from a compiler point of view?

Of course it is.

> Might a compiler actually evaluate the inner expression and then invert
> the result?

You mean, evaluate "(urb && urb->dev && urb->dev->bus)"?  Yes indeed, it
might.  But in the course of evaluating that inner expression, the
execution would stop as soon as it found that urb was NULL.  That's
guaranteed by the C language.

Alan Stern


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.