diff options
author | Gabe Black <gabeblack@chromium.org> | 2013-07-01 04:57:37 -0700 |
---|---|---|
committer | Patrick Georgi <patrick@georgi-clan.de> | 2013-08-15 20:10:39 +0200 |
commit | 0c605a5a6cf0b5a7bdaa6068168581dc8fb24d22 (patch) | |
tree | 3c975a327806f6a2f1fdeea66708cc5c74b6aa20 /payloads | |
parent | f31eacca62bb9fda9ed05be941a336163f1ce146 (diff) |
CBFS: Change the signature of cbfs_decompress.
Instead of returning 0 on success and -1 on error, return the decompressed
size of the data on success and 0 on error. The decompressed size is useful
information to have that was being thrown away in that function.
Change-Id: If787201aa61456b1e47feaf3a0071c753fa299a3
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Reviewed-on: http://review.coreboot.org/3578
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/include/cbfs_core.h | 2 | ||||
-rw-r--r-- | payloads/libpayload/libcbfs/cbfs.c | 4 | ||||
-rw-r--r-- | payloads/libpayload/libcbfs/cbfs_core.c | 9 |
3 files changed, 6 insertions, 9 deletions
diff --git a/payloads/libpayload/include/cbfs_core.h b/payloads/libpayload/include/cbfs_core.h index 2dc1992bc7..8be7212210 100644 --- a/payloads/libpayload/include/cbfs_core.h +++ b/payloads/libpayload/include/cbfs_core.h @@ -217,7 +217,7 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name); void *cbfs_get_file_content(struct cbfs_media *media, const char *name, int type); -/* returns 0 on success, -1 on failure */ +/* returns decompressed size on success, 0 on failure */ int cbfs_decompress(int algo, void *src, void *dst, int len); /* returns a pointer to CBFS master header, or CBFS_HEADER_INVALID_ADDRESS diff --git a/payloads/libpayload/libcbfs/cbfs.c b/payloads/libpayload/libcbfs/cbfs.c index 2fb91bf2d2..6243473170 100644 --- a/payloads/libpayload/libcbfs/cbfs.c +++ b/payloads/libpayload/libcbfs/cbfs.c @@ -120,7 +120,7 @@ void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor, if (! dest) return src; - if (cbfs_decompress(ntohl(orom->compression), + if (!cbfs_decompress(ntohl(orom->compression), src, dest, ntohl(orom->len))) @@ -146,7 +146,7 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name) stage->entry); memset((void *) (uint32_t) stage->load, 0, stage->memlen); - if (cbfs_decompress(stage->compression, + if (!cbfs_decompress(stage->compression, ((unsigned char *) stage) + sizeof(struct cbfs_stage), (void *) (uint32_t) stage->load, diff --git a/payloads/libpayload/libcbfs/cbfs_core.c b/payloads/libpayload/libcbfs/cbfs_core.c index 48a4b3aaca..1945813bb5 100644 --- a/payloads/libpayload/libcbfs/cbfs_core.c +++ b/payloads/libpayload/libcbfs/cbfs_core.c @@ -196,19 +196,16 @@ int cbfs_decompress(int algo, void *src, void *dst, int len) switch (algo) { case CBFS_COMPRESS_NONE: memcpy(dst, src, len); - return 0; + return len; #ifdef CBFS_CORE_WITH_LZMA case CBFS_COMPRESS_LZMA: - if (ulzma(src, dst) != 0) { - return 0; - } - return -1; + return ulzma(src, dst); #endif default: ERROR("tried to decompress %d bytes with algorithm #%x," "but that algorithm id is unsupported.\n", len, algo); - return -1; + return 0; } } |