>> and don't really object, I'm just curious. > I guess it's just a matter of taste. I have been known to do it both > ways. Have you checked to see which generates smaller object code? Identical object code for both... (I also tried it with a few other options, including -march=native (which uses cmov), -O2, reversing the order of the arguments to min(), etc.) == min.c == #include <string.h> /* Copied from include/linux/kernel.h */ #define min(x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; }) size_t foo(char const *s) { size_t len = strlen(s); if (len > 126) len = 126; return len; } size_t bar(char const *s) { return min(strlen(s), (size_t)126); } === min.s (gcc-4.3 -Os -fomit-frame-pointer) === .file "min.c" .text .globl bar .type bar, @function bar: pushl %edi xorl %eax, %eax subl $4, %esp orl $-1, %ecx movl 12(%esp), %edi repnz scasb notl %ecx leal -1(%ecx), %eax cmpl $126, %eax jbe .L2 movl $126, %eax .L2: popl %edx popl %edi ret .size bar, .-bar .globl foo .type foo, @function foo: pushl %edi xorl %eax, %eax subl $4, %esp orl $-1, %ecx movl 12(%esp), %edi repnz scasb notl %ecx leal -1(%ecx), %eax cmpl $126, %eax jbe .L5 movl $126, %eax .L5: popl %ecx popl %edi ret .size foo, .-foo .ident "GCC: (Debian 4.3.4-1) 4.3.4" .section .note.GNU-stack,"",@progbits === min.s (gcc-4.4 -Os -fomit-frame-pointer) === .file "min.c" .text .globl bar .type bar, @function bar: pushl %edi movl 8(%esp), %edi xorl %eax, %eax orl $-1, %ecx repnz scasb notl %ecx leal -1(%ecx), %eax cmpl $126, %eax jbe .L2 movl $126, %eax .L2: popl %edi ret .size bar, .-bar .globl foo .type foo, @function foo: pushl %edi movl 8(%esp), %edi xorl %eax, %eax orl $-1, %ecx repnz scasb notl %ecx leal -1(%ecx), %eax cmpl $126, %eax jbe .L6 movl $126, %eax .L6: popl %edi ret .size foo, .-foo .ident "GCC: (Debian 4.4.1-2) 4.4.1" .section .note.GNU-stack,"",@progbits === END === -- 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