Menu

#1 Check return codes everywhere

open
nobody
None
5
2007-02-27
2007-02-27
No

Some checks for return codes are missing.

Examples:
Would you like to add more error handling for return values from "fprintf" like in the function "ushare_set_port" and from "fclose" in the function "parse_config_file"?
http://hg.geexbox.org/ushare/file/a0f1a8c849c4/src/cfgparser.c

Discussion

  • Markus Elfring

    Markus Elfring - 2007-02-27

    Logged In: YES
    user_id=572001
    Originator: YES

    Another example:
    How do you think about to add checks for "malloc" and "strdup" in the functions "get_file_memory" and "http_open"?
    http://hg.geexbox.org/ushare/file/a0f1a8c849c4/src/http.c

     
  • Benjamin Zores

    Benjamin Zores - 2007-08-25

    Logged In: YES
    user_id=1370042
    Originator: NO

    Patches are always welcomed.
    But such tests (for malloc/strdup) are mostly useless: they take more cpu cycles and anyhow, if malloc() fails (due to lack of RAM), your whole system is about to crash, so ushare should be the worse of your preoccupation by then.

     
  • Markus Elfring

    Markus Elfring - 2007-08-25

    Logged In: YES
    user_id=572001
    Originator: YES

    1. I suggest to avoid unchecked function calls.
    Would you like to detect every error situation as early as possible?

    2. How do you think about the reaction "exit(errno)" or "abort()"?

    3. Can the tool "http://splint.org/" help to find any remaining issues?

    4. Would you like to reduce the efforts for error code checking by an exception class hierarchy?
    http://dietmar-kuehl.de/mirror/c++-faq/exceptions.html#faq-17.1
    http://cexcept.sourceforge.net/

     

Log in to post a comment.