On Sat, Jul 14, 2007 at 08:42:34PM +0100, Denis Vlasenko wrote: >On Wednesday 11 July 2007 23:13, Bernhard Fischer wrote: >> >I know but i'm pretty sure that in all places in busybox where this test >> >was used >> >[ !=0 ] it errored out, i double checked it, but nonetheless maybe its a >> >good idea >> >to change it to [ < 0 ] to be more coherent with the original ioctl call. >> >So attached is a fixed patch. >> >> checking for != 0 is imho not a good idea as opposed to <0. The idea is >> sound in my POV, i didn't have a chance to review it, though > >This was quite puzzling for me. Try to guess which is smallest (on i386)? >* if (f() != 0) >* if (f() < 0) >* if (f() == -1) > >Third one is smallest! gcc just does "inc eax; j[n]z label"; which is just 3 >bytes:
The third one is relying on implementation (un-)defined behaviour. #2 is a safe bet, albeit a little bit bigger, but it's the correct thing to do, imo. _______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
