diff --git a/devicemodel/core/sw_load_common.c b/devicemodel/core/sw_load_common.c index d06fbd43b..7e7b823cf 100644 --- a/devicemodel/core/sw_load_common.c +++ b/devicemodel/core/sw_load_common.c @@ -121,8 +121,8 @@ acrn_parse_bootargs(char *arg) with_bootargs = 1; printf("SW_LOAD: get bootargs %s\n", bootargs); return 0; - } else - return -1; + } + return -1; } char* @@ -222,8 +222,6 @@ acrn_create_e820_table(struct vmctx *ctx, struct e820_entry *e820) uint32_t removed = 0, k; memcpy(e820, e820_default_entries, sizeof(e820_default_entries)); - - assert(ctx->lowmem > e820[LOWRAM_E820_ENTRY].baseaddr); e820[LOWRAM_E820_ENTRY].length = ctx->lowmem - e820[LOWRAM_E820_ENTRY].baseaddr; diff --git a/devicemodel/core/sw_load_elf.c b/devicemodel/core/sw_load_elf.c index a3b8778ad..708fd902f 100644 --- a/devicemodel/core/sw_load_elf.c +++ b/devicemodel/core/sw_load_elf.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -95,19 +94,19 @@ struct multiboot_info { int acrn_parse_elf(char *arg) { + int err = -1; size_t len = strnlen(arg, STR_LEN); size_t elfsz; if (len < STR_LEN) { strncpy(elf_path, arg, len + 1); - assert(check_image(elf_path, 0, &elfsz) == 0); - - elf_file_name = elf_path; - - printf("SW_LOAD: get elf path %s\n", elf_path); - return 0; - } else - return -1; + if (check_image(elf_path, 0, &elfsz) == 0) { + elf_file_name = elf_path; + printf("SW_LOAD: get elf path %s\n", elf_path); + err = 0; + } + } + return err; } static int load_elf32(struct vmctx *ctx, FILE *fp, void *buf) diff --git a/devicemodel/core/sw_load_ovmf.c b/devicemodel/core/sw_load_ovmf.c index 6d35f57dc..bd04447ff 100644 --- a/devicemodel/core/sw_load_ovmf.c +++ b/devicemodel/core/sw_load_ovmf.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "dm.h" #include "vmmapi.h" @@ -72,20 +71,19 @@ ovmf_image_size(void) int acrn_parse_ovmf(char *arg) { - int error; + int error = -1; size_t len = strnlen(arg, STR_LEN); if (len < STR_LEN) { strncpy(ovmf_path, arg, len + 1); - error = check_image(ovmf_path, 2 * MB, &ovmf_size); - assert(!error); - - ovmf_file_name = ovmf_path; - printf("SW_LOAD: get ovmf path %s, size 0x%lx\n", - ovmf_path, ovmf_size); - return 0; - } else - return -1; + if (check_image(ovmf_path, 2 * MB, &ovmf_size) == 0) { + ovmf_file_name = ovmf_path; + printf("SW_LOAD: get ovmf path %s, size 0x%lx\n", + ovmf_path, ovmf_size); + error = 0; + } + } + return error; } static int @@ -149,7 +147,8 @@ acrn_sw_load_ovmf(struct vmctx *ctx) e820 = paddr_guest2host(ctx, OVMF_E820_BASE, e820_default_entries[LOWRAM_E820_ENTRY].baseaddr - OVMF_E820_BASE); - assert(e820 != NULL); + if (e820 == NULL) + return -1; strncpy(e820->signature, "820", sizeof(e820->signature)); e820->nentries = acrn_create_e820_table(ctx, e820->map); diff --git a/devicemodel/core/sw_load_vsbl.c b/devicemodel/core/sw_load_vsbl.c index 2cf819857..ba9a44c0b 100644 --- a/devicemodel/core/sw_load_vsbl.c +++ b/devicemodel/core/sw_load_vsbl.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "dm.h" @@ -125,21 +124,19 @@ vsbl_set_bdf(int bnum, int snum, int fnum) int acrn_parse_guest_part_info(char *arg) { - int error; + int error = -1; size_t len = strnlen(arg, STR_LEN); if (len < STR_LEN) { strncpy(guest_part_info_path, arg, len + 1); - error = check_image(guest_part_info_path, 0, &guest_part_info_size); - assert(!error); - - with_guest_part_info = true; - - printf("SW_LOAD: get partition blob path %s\n", - guest_part_info_path); - return 0; - } else - return -1; + if (check_image(guest_part_info_path, 0, &guest_part_info_size) == 0) { + with_guest_part_info = true; + printf("SW_LOAD: get partition blob path %s\n", + guest_part_info_path); + error = 0; + } + } + return error; } static int @@ -194,21 +191,18 @@ acrn_prepare_guest_part_info(struct vmctx *ctx) int acrn_parse_vsbl(char *arg) { - int error; + int error = -1; size_t len = strnlen(arg, STR_LEN); if (len < STR_LEN) { strncpy(vsbl_path, arg, len + 1); - error = check_image(vsbl_path, 8 * MB, &vsbl_size); - assert(!error); - - vsbl_file_name = vsbl_path; - - printf("SW_LOAD: get vsbl path %s\n", - vsbl_path); - return 0; - } else - return -1; + if (check_image(vsbl_path, 8 * MB, &vsbl_size) == 0) { + vsbl_file_name = vsbl_path; + printf("SW_LOAD: get vsbl path %s\n", vsbl_path); + error = 0; + } + } + return error; } static int