Module Name:    src
Committed By:   rillig
Date:           Sun Oct 10 19:07:19 UTC 2021

Modified Files:
        src/bin/echo: Makefile echo.c

Log Message:
echo: clean up, increase WARNS to 6

Lint can handle __COPYRIGHT and __RCSID, so there is no need to hide
them anymore.

Use proper type 'bool' for nflag, ensure correct types via lint's strict
bool mode.

Remove unnecessary call to exit(0); returning from main is equivalent
since C99.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/bin/echo/Makefile
cvs rdiff -u -r1.20 -r1.21 src/bin/echo/echo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/echo/Makefile
diff -u src/bin/echo/Makefile:1.8 src/bin/echo/Makefile:1.9
--- src/bin/echo/Makefile:1.8	Sun Jul 20 22:36:53 1997
+++ src/bin/echo/Makefile	Sun Oct 10 19:07:19 2021
@@ -1,6 +1,9 @@
-#	$NetBSD: Makefile,v 1.8 1997/07/20 22:36:53 christos Exp $
+#	$NetBSD: Makefile,v 1.9 2021/10/10 19:07:19 rillig Exp $
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
 
 PROG=	echo
 
+WARNS=		6
+LINTFLAGS+=	-T -w
+
 .include <bsd.prog.mk>

Index: src/bin/echo/echo.c
diff -u src/bin/echo/echo.c:1.20 src/bin/echo/echo.c:1.21
--- src/bin/echo/echo.c:1.20	Wed May 19 22:12:36 2021
+++ src/bin/echo/echo.c	Sun Oct 10 19:07:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: echo.c,v 1.20 2021/05/19 22:12:36 kre Exp $	*/
+/* $NetBSD: echo.c,v 1.21 2021/10/10 19:07:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -30,22 +30,19 @@
  */
 
 #include <sys/cdefs.h>
-#ifndef lint
 __COPYRIGHT(
 "@(#) Copyright (c) 1989, 1993\
  The Regents of the University of California.  All rights reserved.");
-#endif /* not lint */
 
-#ifndef lint
 #if 0
 static char sccsid[] = "@(#)echo.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: echo.c,v 1.20 2021/05/19 22:12:36 kre Exp $");
+__RCSID("$NetBSD: echo.c,v 1.21 2021/10/10 19:07:19 rillig Exp $");
 #endif
-#endif /* not lint */
 
 #include <err.h>
 #include <locale.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -54,29 +51,24 @@ __RCSID("$NetBSD: echo.c,v 1.20 2021/05/
 int
 main(int argc, char *argv[])
 {
-	int nflag;
+	bool nflag;
 
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, "");
 
 	/* This utility may NOT do getopt(3) option parsing. */
-	if (*++argv && !strcmp(*argv, "-n")) {
+	nflag = *++argv != NULL && strcmp(*argv, "-n") == 0;
+	if (nflag)
 		++argv;
-		nflag = 1;
-	}
-	else
-		nflag = 0;
 
-	while (*argv) {
+	while (*argv != NULL) {
 		(void)printf("%s", *argv);
-		if (*++argv)
+		if (*++argv != NULL)
 			(void)putchar(' ');
 	}
-	if (nflag == 0)
+	if (!nflag)
 		(void)putchar('\n');
 	fflush(stdout);
 	if (ferror(stdout))
 		err(1, "write error");
-	exit(0);
-	/* NOTREACHED */
 }

Reply via email to