diff options
author | Randall Spangler <rspangler@chromium.org> | 2017-01-03 13:49:18 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-01-12 15:56:27 -0800 |
commit | 21015898b39aa8742057ed6e6423c308c8d0a15d (patch) | |
tree | 8221b6a48e13d8cdf15820cc92247167f8ac5fe0 /host | |
parent | df4eb2bb7be9d61bfe9bdf6c33f836f358b18cf6 (diff) | |
download | vboot-21015898b39aa8742057ed6e6423c308c8d0a15d.tar.gz |
firmware: replace VBDEBUG(()) macro with VB2_DEBUG()
The original VBDEBUG macro used doubly-nested parens to work with
MSVC, which didn't support varargs in macros. We now only use more
modern compilers, so replace it with the VB2_DEBUG macro and get rid
of the ugly and fragile double parens.
BUG=chromium:611535
BRANCH=none
TEST=make runtests; build_packages --board=reef chromeos-firmware
Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/425133
Reviewed-by: Shelley Chen <shchen@chromium.org>
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/crossystem.c | 11 | ||||
-rw-r--r-- | host/lib/file_keys.c | 2 | ||||
-rw-r--r-- | host/lib/host_misc.c | 8 | ||||
-rw-r--r-- | host/lib/signature_digest.c | 20 |
4 files changed, 21 insertions, 20 deletions
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c index 05126214..f1221834 100644 --- a/host/lib/crossystem.c +++ b/host/lib/crossystem.c @@ -791,12 +791,12 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize) ssize_t n; if (pipe(mosys_to_crossystem) < 0) { - VBDEBUG(("pipe() error\n")); + fprintf(stderr, "pipe() error\n"); return -1; } if ((pid = fork()) < 0) { - VBDEBUG(("fork() error\n")); + fprintf(stderr, "fork() error\n"); close(mosys_to_crossystem[0]); close(mosys_to_crossystem[1]); return -1; @@ -806,7 +806,7 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize) if (STDOUT_FILENO != mosys_to_crossystem[1]) { if (dup2(mosys_to_crossystem[1], STDOUT_FILENO) != STDOUT_FILENO) { - VBDEBUG(("stdout dup2() failed (mosys)\n")); + fprintf(stderr, "stdout dup2() failed (mosys)\n"); close(mosys_to_crossystem[1]); exit(1); } @@ -814,7 +814,7 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize) /* Execute mosys */ execv(InAndroid() ? MOSYS_ANDROID_PATH : MOSYS_CROS_PATH, argv); /* We shouldn't be here; exit now! */ - VBDEBUG(("execv() of mosys failed\n")); + fprintf(stderr, "execv() of mosys failed\n"); close(mosys_to_crossystem[1]); exit(1); } else { /* Parent */ @@ -832,9 +832,8 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize) } close(mosys_to_crossystem[0]); if (n < 0) - VBDEBUG(("read() error reading output from mosys\n")); + fprintf(stderr, "read() error on output from mosys\n"); if (waitpid(pid, &status, 0) < 0 || status) { - VBDEBUG(("waitpid() or mosys error\n")); fprintf(stderr, "waitpid() or mosys error\n"); return -1; } diff --git a/host/lib/file_keys.c b/host/lib/file_keys.c index 0aba6b86..7df7ceb2 100644 --- a/host/lib/file_keys.c +++ b/host/lib/file_keys.c @@ -29,7 +29,7 @@ int DigestFile(char *input_file, enum vb2_hash_algorithm alg, struct vb2_digest_context ctx; if( (input_fd = open(input_file, O_RDONLY)) == -1 ) { - VBDEBUG(("Couldn't open %s\n", input_file)); + fprintf(stderr, "Couldn't open %s\n", input_file); return VB2_ERROR_UNKNOWN; } vb2_digest_init(&ctx, alg); diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c index 611253b9..250ca99d 100644 --- a/host/lib/host_misc.c +++ b/host/lib/host_misc.c @@ -30,7 +30,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr) f = fopen(filename, "rb"); if (!f) { - VBDEBUG(("Unable to open file %s\n", filename)); + fprintf(stderr, "Unable to open file %s\n", filename); return NULL; } @@ -49,7 +49,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr) } if(1 != fread(buf, size, 1, f)) { - VBDEBUG(("Unable to read from file %s\n", filename)); + fprintf(stderr, "Unable to read from file %s\n", filename); fclose(f); free(buf); return NULL; @@ -103,12 +103,12 @@ int WriteFile(const char* filename, const void *data, uint64_t size) { FILE *f = fopen(filename, "wb"); if (!f) { - VBDEBUG(("Unable to open file %s\n", filename)); + fprintf(stderr, "Unable to open file %s\n", filename); return 1; } if (1 != fwrite(data, size, 1, f)) { - VBDEBUG(("Unable to write to file %s\n", filename)); + fprintf(stderr, "Unable to write to file %s\n", filename); fclose(f); unlink(filename); /* Delete any partial file */ return 1; diff --git a/host/lib/signature_digest.c b/host/lib/signature_digest.c index d56b05be..025a9ffe 100644 --- a/host/lib/signature_digest.c +++ b/host/lib/signature_digest.c @@ -42,7 +42,8 @@ uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len, uint8_t digest[VB2_SHA512_DIGEST_SIZE]; /* Longest digest */ if (algorithm >= VB2_ALG_COUNT) { - VBDEBUG(("SignatureDigest() called with invalid algorithm!\n")); + fprintf(stderr, "SignatureDigest(): " + "Called with invalid algorithm!\n"); } else if (VB2_SUCCESS == vb2_digest_buffer(buf, len, vb2_crypto_to_hash(algorithm), digest, sizeof(digest))) { @@ -60,7 +61,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, uint8_t* signature = NULL; uint8_t* signature_digest = SignatureDigest(buf, len, algorithm); if (!signature_digest) { - VBDEBUG(("SignatureBuf(): Couldn't get signature digest\n")); + fprintf(stderr, "SignatureBuf(): " + "Couldn't get signature digest\n"); return NULL; } @@ -70,7 +72,7 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, const uint8_t* digestinfo = NULL; if (VB2_SUCCESS != vb2_digest_info(hash_alg, &digestinfo, &digestinfo_size)) { - VBDEBUG(("SignatureBuf(): Couldn't get digest info\n")); + fprintf(stderr, "SignatureBuf(): Couldn't get digest info\n"); free(signature_digest); return NULL; } @@ -79,8 +81,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, key_fp = fopen(key_file, "r"); if (!key_fp) { - VBDEBUG(("SignatureBuf(): Couldn't open key file: %s\n", - key_file)); + fprintf(stderr, "SignatureBuf(): Couldn't open key file: %s\n", + key_file); free(signature_digest); return NULL; } @@ -88,8 +90,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, signature = (uint8_t *)malloc( vb2_rsa_sig_size(vb2_crypto_to_signature(algorithm))); else - VBDEBUG(("SignatureBuf(): Couldn't read private key from: %s\n", - key_file)); + fprintf(stderr, "SignatureBuf(): " + "Couldn't read private key from: %s\n", key_file); if (signature) { if (-1 == RSA_private_encrypt( signature_digest_len, /* Input length. */ @@ -97,8 +99,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, signature, /* Output signature. */ key, /* Key to use. */ RSA_PKCS1_PADDING)) /* Padding to use. */ - VBDEBUG(("SignatureBuf(): " - "RSA_private_encrypt() failed.\n")); + fprintf(stderr, "SignatureBuf(): " + "RSA_private_encrypt() failed.\n"); } fclose(key_fp); if (key) |