All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH RESEND v2 0/2] linux-user: fix bugs reported by Clang Static Analyzer
@ 2018-06-04 15:37 Philippe Mathieu-Daudé
  2018-06-04 15:37 ` [Qemu-devel] [PATCH RESEND v2 1/2] linux-user: Export use is_error(), use it to avoid warnings Philippe Mathieu-Daudé
  2018-06-04 15:37 ` [Qemu-devel] [PATCH RESEND v2 2/2] linux-user: Use is_error() to avoid warnings and make the code clearer Philippe Mathieu-Daudé
  0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-04 15:37 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Philippe Mathieu-Daudé, qemu-devel, Riku Voipio

This is a resend of v1 resend ... not sure what happened previously, MTA sent:

  550 8-bit characters not allowed in subject (see RFC 2822, sections 3.6.5, 2.2.1)

v1 here:
  http://lists.nongnu.org/archive/html/qemu-devel/2017-07/msg07453.html

Philippe Mathieu-Daudé (2):
  linux-user: Export use is_error(), use it to avoid warnings
  linux-user: Use is_error() to avoid warnings and make the code clearer

 linux-user/qemu.h     |  5 +++++
 linux-user/flatload.c | 15 +++++++++------
 linux-user/syscall.c  |  5 -----
 3 files changed, 14 insertions(+), 11 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH RESEND v2 1/2] linux-user: Export use is_error(), use it to avoid warnings
  2018-06-04 15:37 [Qemu-devel] [PATCH RESEND v2 0/2] linux-user: fix bugs reported by Clang Static Analyzer Philippe Mathieu-Daudé
@ 2018-06-04 15:37 ` Philippe Mathieu-Daudé
  2018-06-04 15:37 ` [Qemu-devel] [PATCH RESEND v2 2/2] linux-user: Use is_error() to avoid warnings and make the code clearer Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-04 15:37 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Philippe Mathieu-Daudé, qemu-devel, Riku Voipio

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>
---
 linux-user/qemu.h    | 5 +++++
 linux-user/syscall.c | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index c55c8e294b..4eeffe3c76 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -618,6 +618,11 @@ static inline void *lock_user_string(abi_ulong guest_addr)
 
 #include <pthread.h>
 
+static inline int is_error(abi_long ret)
+{
+    return (abi_ulong)ret >= (abi_ulong)(-4096);
+}
+
 /* Include target-specific struct and function definitions;
  * they may need access to the target-independent structures
  * above, so include them last.
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d02c16bbc6..5e122dbdda 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -906,11 +906,6 @@ static inline abi_long get_errno(abi_long ret)
         return ret;
 }
 
-static inline int is_error(abi_long ret)
-{
-    return (abi_ulong)ret >= (abi_ulong)(-4096);
-}
-
 const char *target_strerror(int err)
 {
     if (err == TARGET_ERESTARTSYS) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH RESEND v2 2/2] linux-user: Use is_error() to avoid warnings and make the code clearer
  2018-06-04 15:37 [Qemu-devel] [PATCH RESEND v2 0/2] linux-user: fix bugs reported by Clang Static Analyzer Philippe Mathieu-Daudé
  2018-06-04 15:37 ` [Qemu-devel] [PATCH RESEND v2 1/2] linux-user: Export use is_error(), use it to avoid warnings Philippe Mathieu-Daudé
@ 2018-06-04 15:37 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-04 15:37 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Philippe Mathieu-Daudé, qemu-devel, Riku Voipio

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>
---
 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.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-04 15:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 15:37 [Qemu-devel] [PATCH RESEND v2 0/2] linux-user: fix bugs reported by Clang Static Analyzer Philippe Mathieu-Daudé
2018-06-04 15:37 ` [Qemu-devel] [PATCH RESEND v2 1/2] linux-user: Export use is_error(), use it to avoid warnings Philippe Mathieu-Daudé
2018-06-04 15:37 ` [Qemu-devel] [PATCH RESEND v2 2/2] linux-user: Use is_error() to avoid warnings and make the code clearer Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.