Re: [PATCH] security_sk_free void return fixup

From: *** Streefland (spam_at_altium.nl)
Date: 06/16/04

  • Next message: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: Linux 2.6.7"
    To: linux-kernel@vger.kernel.org
    Date:	Wed, 16 Jun 2004 12:11:41 -0000
    
    

    Linus Torvalds <torvalds@osdl.org> wrote:
    | I'm going to remove this warning from sparse. Apparently it is valid C99,
    | and somebody (I think Richard Henderson) made the excellent point that it
    | allows for type-independent code where you do something like
    |
    | mytype myfunc1(xxx);
    |
    | mytype myfunc2(xxx)
    | {
    | ...
    | return myfunc1(...);
    | }
    |
    | and it just works regardless of what type it is.

    It may work in gcc, but it is invalid according to ISO C99. First
    sentence from section 6.8.6.4:

      A return statement with an expression shall not appear in a
      function whose return type is void.

    Now, a function call is obviously an expression.

    | sparse will obviously warn about expressions with non-void types being
    | returned from a void function, but the case where the expression exists
    | and has the right type should be ok.
    |
    | I'm not sure it's wonderful C in general, but I certainly can't claim it
    | is actively offensive, and since gcc accepts it and we have these things
    | in the kernel, why complain?

    Gcc warns about this with the -pedantic option:

      $ gcc-3.3 -pedantic -c return.c
      return.c: In function `myfunc2':
      return.c:5: warning: `return' with a value, in function returning void

    -- 
    *** Streefland                      ////                      Altium BV
    ***.streefland@altium.nl           (@ @)          http://www.altium.com
    --------------------------------oOO--(_)--OOo---------------------------
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: Linux 2.6.7"