Re: Stray nulls when reading from AF_UNIX sockets

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Miller <davem@...>
Cc: <anders.blomdell@...>, <linux-kernel@...>
Date: Friday, September 7, 2007 - 7:52 am

On Sep 6 2007 12:23, David Miller wrote:

Not only that. With x?x:z, x is evaluated twice,
while with x?:z, x is only evaluated once. That's for stuff when you 
want to, say [dumb example follows],

size_t my_read(..) {
    return read(..) ? : -1
}

and the only other way would be to use a temporary,

size_t my_read(..) {
	size_t x = read(..);
	return x ? x : -1;
}

gcc should be smart enough to also do optimization in the second case..


	Jan
-- 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Stray nulls when reading from AF_UNIX sockets, Anders Blomdell, (Thu Sep 6, 11:48 am)
Re: Stray nulls when reading from AF_UNIX sockets, David Miller, (Thu Sep 6, 3:23 pm)
Re: Stray nulls when reading from AF_UNIX sockets, Jan Engelhardt, (Fri Sep 7, 7:52 am)
Re: Stray nulls when reading from AF_UNIX sockets, Randy Dunlap, (Thu Sep 6, 12:09 pm)