lkml.org 
[lkml]   [2000]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: Result of compiling with `-W'
    On Thu, Jul 13, 2000 at 05:20:52PM +0100, Alan Cox wrote:
    > > /* Register devices */
    > > - if ((card->audio1_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
    > > + if ((signed long)(card->audio1_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
    >
    > Fix the type of card->foo_num to be signed instead - the fix is right.
    >

    I disagree here. If you enumerate things, you have zero or more
    of them. _Never_ owe you (as the kernel) somebody a soundcard ;-)

    So fix is:

    signed long ret = register_sound_dsp(&emu10k1_audio_fops, -1);
    if (ret < 0) {
    /* Error handling or jump to it */
    } else {
    card->audio1_num = ret;
    };

    This is _always_ the safe variant, when you like to indicate
    errors as negative values, but positive values as the "real"
    return values.

    Otherwise you have to check for "< 0" every time you look at the
    signed variable (if you are a clean coder ;-)).

    Regards

    Ingo Oeser
    --
    Feel the power of the penguin - run linux@your.pc
    <esc>:x

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:57    [W:0.032 / U:0.832 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site