[klibc] [klibc:update-dash] [BUILTIN] Use error instead of warnx for fatal errors in printf

klibc-bot for Herbert Xu herbert at gondor.apana.org.au
Thu Jan 24 19:15:27 PST 2019


Commit-ID:  d2762f07df57add3d11f50d7d20c33557303c606
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=d2762f07df57add3d11f50d7d20c33557303c606
Author:     Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Mon, 27 Oct 2014 16:06:51 +0800
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000

[klibc] [BUILTIN] Use error instead of warnx for fatal errors in printf

This patch replaces uses of warnx where we abort with error since
the effect is the same.  The exit status however changes from 1 to
2.  Non-fatal errors where we continue are unchanged.

Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/dash/bltin/printf.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/usr/dash/bltin/printf.c b/usr/dash/bltin/printf.c
index b439a3bb..72f89883 100644
--- a/usr/dash/bltin/printf.c
+++ b/usr/dash/bltin/printf.c
@@ -134,10 +134,8 @@ int printfcmd(int argc, char *argv[])
 	argv = argptr;
 	format = *argv;
 
-	if (!format) {
-		warnx("usage: printf format [arg ...]");
-		goto err;
-	}
+	if (!format)
+		error("usage: printf format [arg ...]");
 
 	gargv = ++argv;
 
@@ -192,10 +190,8 @@ pc:
 			fmt += strspn(fmt, SKIP2);
 
 			ch = *fmt;
-			if (!ch) {
-				warnx("missing format character");
-				goto err;
-			}
+			if (!ch)
+				error("missing format character");
 			/* null terminate format string to we can use it
 			   as an argument to printf. */
 			nextch = fmt[1];
@@ -250,8 +246,7 @@ pc:
 			}
 #endif
 			default:
-				warnx("%s: invalid directive", start);
-				goto err;
+				error("%s: invalid directive", start);
 			}
 			*++fmt = nextch;
 		}
@@ -259,8 +254,6 @@ pc:
 
 out:
 	return rval;
-err:
-	return 1;
 }
 
 


More information about the klibc mailing list