[OpenWrt-Devel] [PATCH ucert 01/13] stdout/stderr improvements

Matthias Schiffer mschiffer at universe-factory.net
Sat May 16 17:13:51 EDT 2020


- Print error messages to stderr
- fprintf(stdout, ...) is just printf(...)

Signed-off-by: Matthias Schiffer <mschiffer at universe-factory.net>
---
 ucert.c      | 6 +++---
 usign-exec.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ucert.c b/ucert.c
index d822199eb7f8..2ea939947d72 100644
--- a/ucert.c
+++ b/ucert.c
@@ -381,7 +381,7 @@ static void cert_dump_blob(struct blob_attr *cert[CERT_ATTR_MAX]) {
 
 		switch(cert_policy[i].type) {
 		case BLOB_ATTR_BINARY:
-			fprintf(stdout, "signature:\n---\n%s---\n", (char *) blob_data(v));
+			printf("signature:\n---\n%s---\n", (char *) blob_data(v));
 			break;
 		case BLOB_ATTR_NESTED:
 			json = blobmsg_format_json_indent(blob_data(v), false, 0);
@@ -389,7 +389,7 @@ static void cert_dump_blob(struct blob_attr *cert[CERT_ATTR_MAX]) {
 				DPRINTF("cannot parse payload\n");
 				continue;
 			}
-			fprintf(stdout, "payload:\n---\n%s\n---\n", json);
+			printf("payload:\n---\n%s\n---\n", json);
 			free(json);
 			break;
 		}
@@ -408,7 +408,7 @@ static int cert_dump(const char *certfile) {
 	}
 
 	list_for_each_entry(cobj, &certchain, list) {
-		fprintf(stdout, "=== CHAIN ELEMENT %02u ===\n", ++count);
+		printf("=== CHAIN ELEMENT %02u ===\n", ++count);
 		cert_dump_blob(cobj->cert);
 	}
 
diff --git a/usign-exec.c b/usign-exec.c
index 85e5f956ee1f..7f6106580b16 100644
--- a/usign-exec.c
+++ b/usign-exec.c
@@ -209,13 +209,13 @@ int usign_v(const char *msgfile, const char *pubkeyfile,
 
 	if (usign_f_sig(fingerprint, sigfile)) {
 		if (!quiet)
-			fprintf(stdout, "cannot get signing key fingerprint\n");
+			fprintf(stderr, "cannot get signing key fingerprint\n");
 		return 1;
 	}
 
 	if (pubkeydir && _usign_key_is_revoked(fingerprint, pubkeydir)) {
 		if (!quiet)
-			fprintf(stdout, "key %s has been revoked!\n", fingerprint);
+			fprintf(stderr, "key %s has been revoked!\n", fingerprint);
 		return 1;
 	}
 	usign_argv[usign_argc++] = USIGN_EXEC;
-- 
2.26.2


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list