diff options
author | Joel Kitching <kitching@google.com> | 2020-03-16 16:20:02 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-31 10:36:57 +0000 |
commit | 02f45f51a7e80bf7e62c3fa0926c3e30ccd7124d (patch) | |
tree | 655a4ea39d2f2485c369d6175476858d9fac88b8 /cgpt | |
parent | e3f71c97d05f5c659a0c2a2186dc62dd0586407f (diff) | |
download | vboot-02f45f51a7e80bf7e62c3fa0926c3e30ccd7124d.tar.gz |
vboot: stop using StrnAppend and Uint64ToString
Use snprintf instead. Remove utility_string library.
Also, prepare VbDisplayDebugInfo to handle 64-byte nvdata.
BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
TEST=boot with 16-byte nvdata, check <TAB> output (one line)
TEST=boot with 64-byte nvdata, check <TAB> output (five lines)
BRANCH=none
Change-Id: If6c4b3a4e9fa7b71cb2d8ca7ccd37e4f36b97fd6
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:2122061
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2104880
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'cgpt')
-rw-r--r-- | cgpt/cgpt_add.c | 79 |
1 files changed, 27 insertions, 52 deletions
diff --git a/cgpt/cgpt_add.c b/cgpt/cgpt_add.c index e2b0b32e..09a86ba9 100644 --- a/cgpt/cgpt_add.c +++ b/cgpt/cgpt_add.c @@ -3,72 +3,46 @@ * found in the LICENSE file. */ +#include <stdio.h> #include <string.h> #include "cgpt.h" #include "cgptlib_internal.h" #include "cgpt_params.h" -#include "utility.h" #include "vboot_host.h" -static const char* DumpCgptAddParams(const CgptAddParams *params) { - static char buf[256]; +static void PrintCgptAddParams(const CgptAddParams *params) { char tmp[64]; - buf[0] = 0; - snprintf(tmp, sizeof(tmp), "-i %d ", params->partition); - StrnAppend(buf, tmp, sizeof(buf)); - if (params->label) { - snprintf(tmp, sizeof(tmp), "-l %s ", params->label); - StrnAppend(buf, tmp, sizeof(buf)); - } - if (params->set_begin) { - snprintf(tmp, sizeof(tmp), "-b %llu ", (unsigned long long)params->begin); - StrnAppend(buf, tmp, sizeof(buf)); - } - if (params->set_size) { - snprintf(tmp, sizeof(tmp), "-s %llu ", (unsigned long long)params->size); - StrnAppend(buf, tmp, sizeof(buf)); - } + fprintf(stderr, "-i %d ", params->partition); + if (params->label) + fprintf(stderr, "-l %s ", params->label); + if (params->set_begin) + fprintf(stderr, "-b %llu ", (unsigned long long)params->begin); + if (params->set_size) + fprintf(stderr, "-s %llu ", (unsigned long long)params->size); if (params->set_type) { GuidToStr(¶ms->type_guid, tmp, sizeof(tmp)); - StrnAppend(buf, "-t ", sizeof(buf)); - StrnAppend(buf, tmp, sizeof(buf)); - StrnAppend(buf, " ", sizeof(buf)); + fprintf(stderr, "-t %s ", tmp); } if (params->set_unique) { GuidToStr(¶ms->unique_guid, tmp, sizeof(tmp)); - StrnAppend(buf, "-u ", sizeof(buf)); - StrnAppend(buf, tmp, sizeof(buf)); - StrnAppend(buf, " ", sizeof(buf)); - } - if (params->set_successful) { - snprintf(tmp, sizeof(tmp), "-S %d ", params->successful); - StrnAppend(buf, tmp, sizeof(buf)); + fprintf(stderr, "-u %s ", tmp); } - if (params->set_tries) { - snprintf(tmp, sizeof(tmp), "-T %d ", params->tries); - StrnAppend(buf, tmp, sizeof(buf)); - } - if (params->set_priority) { - snprintf(tmp, sizeof(tmp), "-P %d ", params->priority); - StrnAppend(buf, tmp, sizeof(buf)); - } - if (params->set_required) { - snprintf(tmp, sizeof(tmp), "-R %d ", params->required); - StrnAppend(buf, tmp, sizeof(buf)); - } - if (params->set_legacy_boot) { - snprintf(tmp, sizeof(tmp), "-B %d ", params->legacy_boot); - StrnAppend(buf, tmp, sizeof(buf)); - } - if (params->set_raw) { - snprintf(tmp, sizeof(tmp), "-A %#x ", params->raw_value); - StrnAppend(buf, tmp, sizeof(buf)); - } - - StrnAppend(buf, "\n", sizeof(buf)); - return buf; + if (params->set_successful) + fprintf(stderr, "-S %d ", params->successful); + if (params->set_tries) + fprintf(stderr, "-T %d ", params->tries); + if (params->set_priority) + fprintf(stderr, "-P %d ", params->priority); + if (params->set_required) + fprintf(stderr, "-R %d ", params->required); + if (params->set_legacy_boot) + fprintf(stderr, "-B %d ", params->legacy_boot); + if (params->set_raw) + fprintf(stderr, "-A %#x ", params->raw_value); + + fprintf(stderr, "\n"); } // This is the implementation-specific helper function. @@ -295,7 +269,8 @@ static int GptAdd(struct drive *drive, CgptAddParams *params, uint32_t index) { // If the modified entry is illegal, recover it and return error. memcpy(entry, &backup, sizeof(*entry)); Error("%s\n", GptErrorText(rv)); - Error(DumpCgptAddParams(params)); + Error(""); + PrintCgptAddParams(params); return -1; } |