stdout/stderr improvements
authorMatthias Schiffer <mschiffer@universe-factory.net>
Sat, 16 May 2020 11:26:55 +0000 (13:26 +0200)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Sat, 16 May 2020 11:30:26 +0000 (13:30 +0200)
- Print error messages to stderr
- fprintf(stdout, ...) is just printf(...)

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
ucert.c
usign-exec.c

diff --git a/ucert.c b/ucert.c
index d822199eb7f8b8db7a67845d3f2a4642d711020f..2ea939947d726a3add0762fe35e23028f36af76c 100644 (file)
--- 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);
        }
 
index 85e5f956ee1f0627ad10ca87f2236d3411393108..7f6106580b166ca110f0f0e10bce0ff54a7f9cd6 100644 (file)
@@ -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;