#70 Check return codes everywhere

open
None
5
2007-03-01
2007-03-01
No

Some checks for return codes are missing.

Examples:
Would you like to add more error handling for return values from "malloc" in functions like "parse_arg" and "main"?
http://sanchez-gtm.cvs.sourceforge.net/sanchez-gtm/gtm/sr_unix/cli_parse.c?revision=1.6&view=markup
http://sanchez-gtm.cvs.sourceforge.net/sanchez-gtm/gtm/sr_unix_gnp/gtcm_gnp_server.c?revision=1.5&view=markup

Discussion

  • Steven Estes

    Steven Estes - 2007-03-01

    Logged In: YES
    user_id=97877
    Originator: NO

    Markus,

    If you take a look in mdefsp.h you will see a define for "malloc" to "gtm_malloc" which is a C module included in the distribution. The return code is checked there (and is the only module doing "real" malloc() calls). If gtm_malloc returns, the allocation is successful so no return code check needs to be done for these cases. There are likely other system calls that should be checked though so if you want to go on a hunt, we would encourage that. Most typical lack we run across is "close()" which can fail on UNIX systems when disk space is over committed. Thanks for your interest.

    Steve

     
  • Markus Elfring

    Markus Elfring - 2007-03-01

    Logged In: YES
    user_id=572001
    Originator: YES

    Would you like to add checks for error codes from the calls "(f)close" and "(f)printf"?
    How are you going to deal with any remaining unchecked function calls?

     
  • Markus Elfring

    Markus Elfring - 2007-03-01
    • assigned_to: nobody --> estess
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks