[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/8] linux-user: Use is_error() to avoid warnings and
From: |
Laurent Vivier |
Subject: |
[Qemu-devel] [PULL 2/8] linux-user: Use is_error() to avoid warnings and make the code clearer |
Date: |
Tue, 12 Jun 2018 12:58:25 +0200 |
From: Philippe Mathieu-Daudé <address@hidden>
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é <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/flatload.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index a35a560904..10c529910f 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -224,8 +224,9 @@ static int decompress_exec(
ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos);
if (ret <= 0)
break;
- if (ret >= (unsigned long) -4096)
+ if (is_error(ret)) {
break;
+ }
len -= ret;
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",
(unsigned) r, curid, id);
goto failed;
- } else if ( ! p[id].loaded &&
- load_flat_shared_library(id, p) > (unsigned long) -4096) {
+ } else if (!p[id].loaded && is_error(load_flat_shared_library(id, p)))
{
fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id);
goto failed;
}
@@ -523,9 +523,10 @@ static int load_flat_file(struct linux_binprm * bprm,
fpos = 0;
result = bprm->file->f_op->read(bprm->file,
(char *) textpos, text_len, &fpos);
- if (result < (unsigned long) -4096)
+ if (!is_error(result)) {
result = decompress_exec(bprm, text_len, (char *)
datapos,
data_len + (relocs * sizeof(unsigned
long)), 0);
+ }
}
else
#endif
@@ -693,8 +694,9 @@ static int load_flat_shared_library(int id, struct lib_info
*libs)
res = prepare_binprm(&bprm);
- if (res <= (unsigned long)-4096)
+ if (!is_error(res)) {
res = load_flat_file(&bprm, libs, id, NULL);
+ }
if (bprm.file) {
allow_write_access(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);
- if (res > (unsigned long)-4096)
+ if (is_error(res)) {
return res;
+ }
/* Update data segment pointers for all libraries */
for (i=0; i<MAX_SHARED_LIBS; i++) {
--
2.14.4
- [Qemu-devel] [PULL 0/8] Linux user for 3.0 patches, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 1/8] linux-user: Export use is_error(), use it to avoid warnings, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 3/8] linux-user: disable qemu-bridge-helper and socket_scm_helper build, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 4/8] qemu-binfmt-conf.sh: ignore the OS/ABI field, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 5/8] linux-user/alpha: Fix epoll syscalls, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 8/8] linux-user/sparc64: Add inotify_rm_watch and tee syscalls, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 2/8] linux-user: Use is_error() to avoid warnings and make the code clearer,
Laurent Vivier <=
- [Qemu-devel] [PULL 7/8] linux-user/microblaze: Fix typo in accept4 syscall, Laurent Vivier, 2018/06/12
- [Qemu-devel] [PULL 6/8] linux-user/hppa: Fix typo in mknodat syscall, Laurent Vivier, 2018/06/12
- Re: [Qemu-devel] [PULL 0/8] Linux user for 3.0 patches, no-reply, 2018/06/12
- Re: [Qemu-devel] [PULL 0/8] Linux user for 3.0 patches, Peter Maydell, 2018/06/14