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 d822199..2ea9399 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:
 
                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);
                        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;
                        }
                                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;
                }
                        free(json);
                        break;
                }
@@ -408,7 +408,7 @@ static int cert_dump(const char *certfile) {
        }
 
        list_for_each_entry(cobj, &certchain, list) {
        }
 
        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);
        }
 
                cert_dump_blob(cobj->cert);
        }
 
index 85e5f95..7f61065 100644 (file)
@@ -209,13 +209,13 @@ int usign_v(const char *msgfile, const char *pubkeyfile,
 
        if (usign_f_sig(fingerprint, sigfile)) {
                if (!quiet)
 
        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)
                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;
                return 1;
        }
        usign_argv[usign_argc++] = USIGN_EXEC;