#26 Check return codes everywhere

version 2.2.x
open-fixed
libgiigic (3)
5
2007-02-26
2007-02-05
Markus Elfring
No

Some checks for return codes are missing.

Examples:
Would you like to add more error handling for return values from "fread" and "fclose" like in the function "ggiWidgetImageLoadPNM" and from "fprintf" in the function "gicContextWrite"?
http://ggi.svn.sourceforge.net/viewvc/ggi/widget/trunk/ggiwidget/image_funcs.c?revision=179&view=markup
http://ggi.cvs.sourceforge.net/ggi/ggi-libs/libgiigic/gic/context.c?revision=1.6&view=markup

Discussion

  • Logged In: YES
    user_id=51548
    Originator: NO

    These two items are done for -current.
    But in libgiigic, there are more places that need return checks.

    I guess, you wanna see the libgiigic fix pulled up to version 2.2.x branch, right?

     
    • assigned_to: nobody --> cegger
    • status: open --> open-fixed
     
  • Markus Elfring
    Markus Elfring
    2007-02-26

    Logged In: YES
    user_id=572001
    Originator: YES

    That would be nice.

    How much are you interested to look for all places in the source files that are candidates for further corrections?
    Would you like to try the tool "http://splint.org/"?

     
  • Logged In: YES
    user_id=51548
    Originator: NO

    I tried splint years ago. All the flags and include pathes makes splint crash.
    So I am waiting for a newer version than 3.1.1 for a long time.

     
  • Markus Elfring
    Markus Elfring
    2007-02-27

    Logged In: YES
    user_id=572001
    Originator: YES

    How do you think about a try to achieve complete error handling by manual code review?

     
  • Logged In: YES
    user_id=51548
    Originator: NO

    Yeah, grepping for fprintf() almost does it.

    Looks like you're already looking through the code.
    How about contributing some patches? :-)

     
  • Markus Elfring
    Markus Elfring
    2007-03-01

    Logged In: YES
    user_id=572001
    Originator: YES

    Have we got the same expectations about the reaction to error codes from file functions?

    Which design option do you prefer?
    - return errno;
    - exit(errno);
    - abort();
    - http://en.wikipedia.org/wiki/Exception_handling

     
  • Logged In: YES
    user_id=51548
    Originator: NO

    The global errno should be avoided where possible.
    Exceptions as in Java or Delphi are not directly supported in C.

    return an error code is the prefered way. Returning an error code alone does not do it.
    The caller of those functions must check them or returning an error code is useless, otherwise.

     
  • Markus Elfring
    Markus Elfring
    2007-03-02

    Logged In: YES
    user_id=572001
    Originator: YES

    Would the approach "http://cexcept.sourceforge.net/" be useful in your software?