mirror of https://github.com/xemu-project/xemu.git
linux-user: Use is_error() to avoid warnings and make the code clearer
This fixes: linux-user/flatload.c:740:9: warning: Loss of sign in implicit conversion if (res > (unsigned long)-4096) ^~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180604153722.24956-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
1129dd7121
commit
71987b125b
|
@ -224,8 +224,9 @@ static int decompress_exec(
|
||||||
ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos);
|
ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
break;
|
break;
|
||||||
if (ret >= (unsigned long) -4096)
|
if (is_error(ret)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
len -= ret;
|
len -= ret;
|
||||||
|
|
||||||
strm.next_in = buf;
|
strm.next_in = buf;
|
||||||
|
@ -283,8 +284,7 @@ calc_reloc(abi_ulong r, struct lib_info *p, int curid, int internalp)
|
||||||
"in same module (%d != %d)\n",
|
"in same module (%d != %d)\n",
|
||||||
(unsigned) r, curid, id);
|
(unsigned) r, curid, id);
|
||||||
goto failed;
|
goto failed;
|
||||||
} else if ( ! p[id].loaded &&
|
} else if (!p[id].loaded && is_error(load_flat_shared_library(id, p))) {
|
||||||
load_flat_shared_library(id, p) > (unsigned long) -4096) {
|
|
||||||
fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id);
|
fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -523,9 +523,10 @@ static int load_flat_file(struct linux_binprm * bprm,
|
||||||
fpos = 0;
|
fpos = 0;
|
||||||
result = bprm->file->f_op->read(bprm->file,
|
result = bprm->file->f_op->read(bprm->file,
|
||||||
(char *) textpos, text_len, &fpos);
|
(char *) textpos, text_len, &fpos);
|
||||||
if (result < (unsigned long) -4096)
|
if (!is_error(result)) {
|
||||||
result = decompress_exec(bprm, text_len, (char *) datapos,
|
result = decompress_exec(bprm, text_len, (char *) datapos,
|
||||||
data_len + (relocs * sizeof(unsigned long)), 0);
|
data_len + (relocs * sizeof(unsigned long)), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -693,8 +694,9 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
|
||||||
|
|
||||||
res = prepare_binprm(&bprm);
|
res = prepare_binprm(&bprm);
|
||||||
|
|
||||||
if (res <= (unsigned long)-4096)
|
if (!is_error(res)) {
|
||||||
res = load_flat_file(&bprm, libs, id, NULL);
|
res = load_flat_file(&bprm, libs, id, NULL);
|
||||||
|
}
|
||||||
if (bprm.file) {
|
if (bprm.file) {
|
||||||
allow_write_access(bprm.file);
|
allow_write_access(bprm.file);
|
||||||
fput(bprm.file);
|
fput(bprm.file);
|
||||||
|
@ -737,8 +739,9 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
|
||||||
|
|
||||||
|
|
||||||
res = load_flat_file(bprm, libinfo, 0, &stack_len);
|
res = load_flat_file(bprm, libinfo, 0, &stack_len);
|
||||||
if (res > (unsigned long)-4096)
|
if (is_error(res)) {
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update data segment pointers for all libraries */
|
/* Update data segment pointers for all libraries */
|
||||||
for (i=0; i<MAX_SHARED_LIBS; i++) {
|
for (i=0; i<MAX_SHARED_LIBS; i++) {
|
||||||
|
|
Loading…
Reference in New Issue