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

klibc-bot for Herbert Xu herbert at gondor.apana.org.au
Sat Mar 28 14:48:30 PDT 2020


Commit-ID:  e9dff9389660fcfca586051edc7aba890f74882e
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=e9dff9389660fcfca586051edc7aba890f74882e
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: Sat, 28 Mar 2020 21:42:54 +0000

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

[ dash commit bc8321eabffa23293d16d6758034203a8c7bffda ]

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