miscellaneous minor clang fixes
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
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
@@ -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
PATCH 2/3 translate-all: Mark map_exec() with the 'unused' attribute
In reply to Peter MaydellFrom: 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).
--- translate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
translate-all.c +2 -2
@@ -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
PATCH 3/3 migration/qemu-file.c: Don't shift left into sign bit
In reply to Peter MaydellAdd 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
@@ -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
Michael Tokarev
AppliedQuoted 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_execpatch has been on list and reviewed before; the other two are new.Peter Maydell (2):
tests/hd-geo-test.c: Remove unusedtest_imagevariablemigration/qemu-file.c: Don't shift left into sign bitSeokYeon Hwang (1):
translate-all: Markmap_exec()with the 'unused' attribute
Applied all to -trivial, thank you!
/mjt