cbfs: Add macro CBFS_LOAD_ERROR for returning failure in case of cbfs_load_*
For all cbfs_load_* functions, use CBFS_LOAD_ERROR macro instead of (void *)-1 BUG=chrome-os-partner:32684 BRANCH=None TEST=Compiles successfully Change-Id: I85aa890866b91e38614bd0eb324e072104573006 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/221674 Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
parent
49487e5af4
commit
3d5b47e836
2 changed files with 7 additions and 5 deletions
|
|
@ -52,6 +52,8 @@
|
|||
|
||||
#include <cbfs_core.h>
|
||||
|
||||
#define CBFS_LOAD_ERROR ((void *)-1)
|
||||
|
||||
int cbfs_execute_stage(struct cbfs_media *media, const char *name);
|
||||
void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor,
|
||||
uint16_t device, void * dest);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ void *cbfs_load_stage_by_offset(struct cbfs_media *media, ssize_t offset)
|
|||
offset, file.len, file.type, file.offset);
|
||||
if (cbfs_read(media, &stage, offset, sizeof(stage)) != sizeof(stage)) {
|
||||
ERROR("ERROR: failed to read stage header\n");
|
||||
return (void *)-1;
|
||||
return CBFS_LOAD_ERROR;
|
||||
}
|
||||
|
||||
LOG("loading stage @ 0x%llx (%d bytes), entry @ 0x%llx\n",
|
||||
|
|
@ -190,18 +190,18 @@ void *cbfs_load_stage_by_offset(struct cbfs_media *media, ssize_t offset)
|
|||
if (cbfs_read(media, (void *)(uintptr_t)stage.load,
|
||||
offset + sizeof(stage), stage.len) != stage.len) {
|
||||
ERROR("ERROR: Reading stage failed.\n");
|
||||
return (void *)-1;
|
||||
return CBFS_LOAD_ERROR;
|
||||
}
|
||||
} else {
|
||||
void *data = media->map(media, offset + sizeof(stage),
|
||||
stage.len);
|
||||
if (data == CBFS_MEDIA_INVALID_MAP_ADDRESS) {
|
||||
ERROR("ERROR: Mapping stage failed.\n");
|
||||
return (void *)-1;
|
||||
return CBFS_LOAD_ERROR;
|
||||
}
|
||||
if (cbfs_decompress(stage.compression, data,
|
||||
(void *)(uintptr_t)stage.load, stage.len))
|
||||
return (void *)-1;
|
||||
return CBFS_LOAD_ERROR;
|
||||
media->unmap(media, data);
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ void *cbfs_load_stage(struct cbfs_media *media, const char *name)
|
|||
|
||||
offset = cbfs_locate_file(media, &file, name);
|
||||
if (offset < 0 || file.type != CBFS_TYPE_STAGE)
|
||||
return (void *)-1;
|
||||
return CBFS_LOAD_ERROR;
|
||||
|
||||
return cbfs_load_stage_by_offset(media, offset);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue