Skip to contentSkip to conversation

miscellaneous minor clang fixes

PATCH Applied Peter Maydell 2 participants 5 messages Dec 23, 2014 – Jan 12, 2015

lore
Share & tools
lore
#0 lore raw

cover miscellaneous minor clang fixes

This is a collection of three miscellaneous minor fixes for clang compile warnings, which I think could reasonably go via the -trivial tree. The map_exec patch has been on list and reviewed before; the other two are new.

Peter Maydell (2):
tests/hd-geo-test.c: Remove unused test_image variable migration/qemu-file.c: Don't shift left into sign bit

SeokYeon Hwang (1):
translate-all: Mark map_exec() with the 'unused' attribute

 migration/qemu-file.c | 2 +-
 tests/hd-geo-test.c   | 2 --
 translate-all.c       | 4 ++--
 3 files changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 tests/hd-geo-test.c: Remove unused test_image variable

Remove unused variable test_image; this silences a clang warning.

---
 tests/hd-geo-test.c | 2 --
 1 file changed, 2 deletions(-)
tests/hd-geo-test.c +0 -2
index 7cc8dff..00afc20 100644
@@ -22,8 +22,6 @@
 #include "qemu-common.h"
 #include "libqtest.h"
 
-static const char test_image[] = "/tmp/qtest.XXXXXX";
-
 static char *create_test_img(int secs)
 {
     char *template = strdup("/tmp/qtest.XXXXXX");
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 translate-all: Mark map_exec() with the 'unused' attribute

In reply to Peter Maydell

From: SeokYeon Hwang <[email protected]>

Mark map_exec() with the 'unused' attribute to avoid '-Wunused-function' warnings on clang 3.4 or later. This means we don't need to mark it 'inline', which is what we were previously using to suppress the warning (a trick which only works with gcc, not clang).

[PMM: tweaked comment message a little]
---
 translate-all.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
translate-all.c +2 -2
index c24cfe8..62b2efa 100644
@@ -276,14 +276,14 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr)
 }
 
 #ifdef _WIN32
-static inline void map_exec(void *addr, long size)
+static __attribute__((unused)) void map_exec(void *addr, long size)
 {
     DWORD old_protect;
     VirtualProtect(addr, size,
                    PAGE_EXECUTE_READWRITE, &old_protect);
 }
 #else
-static inline void map_exec(void *addr, long size)
+static __attribute__((unused)) void map_exec(void *addr, long size)
 {
     unsigned long start, end, page_size;
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/3 migration/qemu-file.c: Don't shift left into sign bit

In reply to Peter Maydell

Add a cast in qemu_get_be32() to avoid shifting left into the sign bit of a signed integer (which is undefined behaviour in C).

---
 migration/qemu-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/qemu-file.c +1 -1
index d2d4007..a7f2a34 100644
@@ -503,7 +503,7 @@ unsigned int qemu_get_be16(QEMUFile *f)
 unsigned int qemu_get_be32(QEMUFile *f)
 {
     unsigned int v;
-    v = qemu_get_byte(f) << 24;
+    v = (unsigned int)qemu_get_byte(f) << 24;
     v |= qemu_get_byte(f) << 16;
     v |= qemu_get_byte(f) << 8;
     v |= qemu_get_byte(f);
Signature · 1 line
1.9.1
#4 lore raw
In reply to Peter Maydell
Quoted 11 lines · Peter Maydell

This is a collection of three miscellaneous minor fixes for clang compile warnings, which I think could reasonably go via the -trivial tree. The map_exec patch has been on list and reviewed before; the other two are new.

Peter Maydell (2):
tests/hd-geo-test.c: Remove unused test_image variable migration/qemu-file.c: Don't shift left into sign bit

SeokYeon Hwang (1):
translate-all: Mark map_exec() with the 'unused' attribute

Applied all to -trivial, thank you!

/mjt