Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/echo With -Wall compiling this was giving:



details:   https://anonhg.NetBSD.org/src/rev/a80eb4e2eb2e
branches:  trunk
changeset: 1025533:a80eb4e2eb2e
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Nov 10 17:35:45 2021 +0000

description:
With -Wall compiling this was giving:

        echo.c: In function 'main':
        echo.c:74:1: warning: control reaches end of non-void function

This raises 2 issues.

First, why with WARNS set to 6, which should include just about
everything, was this not causing problems with everyday builds?
Surely falling off the end of a non-void function without returning
a specific value is one of the more basic errors that should be fixed.
(Whatever the name of the function).   Is there a missing -Wxxx option?

And second, does C99 really promise:
        Remove unnecessary call to exit(0); returning from main is equivalent
        since C99.
in the sense that simply falling out of main() is exit(0)?  Or is it
simply saying that the return value of main() is the exit status (which
has been true for much longer than since c99)?

diffstat:

 bin/echo/echo.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r 1818639edb45 -r a80eb4e2eb2e bin/echo/echo.c
--- a/bin/echo/echo.c   Wed Nov 10 17:23:46 2021 +0000
+++ b/bin/echo/echo.c   Wed Nov 10 17:35:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: echo.c,v 1.21 2021/10/10 19:07:19 rillig Exp $     */
+/* $NetBSD: echo.c,v 1.22 2021/11/10 17:35:45 kre Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)echo.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: echo.c,v 1.21 2021/10/10 19:07:19 rillig Exp $");
+__RCSID("$NetBSD: echo.c,v 1.22 2021/11/10 17:35:45 kre Exp $");
 #endif
 
 #include <err.h>
@@ -71,4 +71,5 @@
        fflush(stdout);
        if (ferror(stdout))
                err(1, "write error");
+       return 0;
 }



Home | Main Index | Thread Index | Old Index