summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2012-03-19 12:47:18 -0700
committerGerrit <chrome-bot@google.com>2012-03-20 10:26:44 -0700
commit72e344d5cdc67e4eb129bb1308ce0e5cca503d2d (patch)
tree8dba5f6525994472b83f548a815e02033f9a51fd /host
parente62e316ecf34b17a65e7781335ed206d0ffbb679 (diff)
downloadvboot-72e344d5cdc67e4eb129bb1308ce0e5cca503d2d.tar.gz
Major refactoring of vbutil_kernel
This started out as a simple fix for a minor bug and turned into a nearly complete rewrite. Now that it's done I'm not sure it really matters. This version is a lot cleaner about handling command-line args, but isn't otherwise noticeably better. Sigh. BUG=none TEST=manual make make runtests Change-Id: I9c194e9c0e6418488635989ef666bc83c6e39816 Reviewed-on: https://gerrit.chromium.org/gerrit/18268 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'host')
-rw-r--r--host/lib/host_misc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c
index ad3b4ebd..77466864 100644
--- a/host/lib/host_misc.c
+++ b/host/lib/host_misc.c
@@ -24,9 +24,10 @@ char* StrCopy(char* dest, const char* src, int dest_size) {
}
-uint8_t* ReadFile(const char* filename, uint64_t* size) {
+uint8_t* ReadFile(const char* filename, uint64_t* sizeptr) {
FILE* f;
uint8_t* buf;
+ uint64_t size;
f = fopen(filename, "rb");
if (!f) {
@@ -35,16 +36,16 @@ uint8_t* ReadFile(const char* filename, uint64_t* size) {
}
fseek(f, 0, SEEK_END);
- *size = ftell(f);
+ size = ftell(f);
rewind(f);
- buf = malloc(*size);
+ buf = malloc(size);
if (!buf) {
fclose(f);
return NULL;
}
- if(1 != fread(buf, *size, 1, f)) {
+ if(1 != fread(buf, size, 1, f)) {
VBDEBUG(("Unable to read from file %s\n", filename));
fclose(f);
free(buf);
@@ -52,6 +53,8 @@ uint8_t* ReadFile(const char* filename, uint64_t* size) {
}
fclose(f);
+ if (sizeptr)
+ *sizeptr = size;
return buf;
}