Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Broadcom Open-Sources Wireless Drivers

Name: Anonymous 2010-09-09 15:26

The ternary operator is dissapointed.


/*
Description: This function saturate input 32 bit number into a 16 bit number.
If input number is greater than 0x7fff then output is saturated to 0x7fff.
else if input number is less than 0xffff8000 then output is saturated to 0xffff8000
else output is same as input.
*/
int16 qm_sat32(int32 op)
{
    int16 result;
    if (op > (int32) 0x7fff) {
        result = 0x7fff;
    } else if (op < (int32) 0xffff8000) {
        result = (int16) (0x8000);
    } else {
        result = (int16) op;
    }
    return result;
}

Name: Anonymous 2010-09-13 18:27

>>39
That's why it is in UPPERCASE. Generally, uppercase is used for macros, and especially ones that might re-evaluate their arguments.
Someone who is too dumb to use these sorts of tools should stay away from them. That doesn't mean that they're bad.

>>40 is a tremendously stupid implementation and assumes that x2, low2, and high2 aren't already names in use elsewhere in the code. With -Wshadow (which, btw, can be a tremendous help in tracking down otherwise highly obscure problems sometimes) such code would have to unnecessarily be rewritten. Don't be hostile to your users for the sake of idiots' safety. That's what Java is for, not C.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List