clean_up: checking errno at exit does not make sense
authorSami Kerola <kerolasa@iki.fi>
Sat, 9 Apr 2011 15:38:54 +0000 (17:38 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sat, 9 Apr 2011 15:38:54 +0000 (17:38 +0200)
It seems that at least FreeBSD is setting errno when malloc is
successful. There is a change that other operating systems will
do similar things with same, or other system calls, and this will
invalidate the idea of checking errno at exit.

See also email list thread for further information.

http://lists.freebsd.org/pipermail/freebsd-questions/2011-April/229150.html

Reported-by: Roar Pettersen <rope1968@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>

src/dhcpd-pools.c
src/other.c

index 02669d2..00b7efc 100644 (file)
@@ -205,13 +205,6 @@ int main(int argc, char **argv)
        }
        free(tmp_ranges);
        output_analysis();
        }
        free(tmp_ranges);
        output_analysis();
-       /* After fopen in output ioctl does like /dev/null which
-        * cause ENOTTY, and clean_up will see that without this
-        * reset. At least linux does this, and possibly some
-        * other systems. There's a report from FreeBSD 8.0 which
-        * matches quite well with this symptom. */
-       if (errno == 25)
-               errno = 0;
 
        clean_up();
        return (EXIT_SUCCESS);
 
        clean_up();
        return (EXIT_SUCCESS);
index fe5f34c..d8f9ac4 100644 (file)
@@ -77,9 +77,6 @@ void clean_up(void)
 {
        int ret;
 
 {
        int ret;
 
-       if (errno) {
-               warn("clean_up: errno (%d) set but not checked in correct place.\nif this is repeatable send strace output as a bug report", errno);
-       }
        /* Just in case there something in buffers */
        ret = fflush(stdout);
        if (errno || ret) {
        /* Just in case there something in buffers */
        ret = fflush(stdout);
        if (errno || ret) {