[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/26] cutils: squelch compiler warnings with custom paths
From: |
Paolo Bonzini |
Subject: |
[PULL 19/26] cutils: squelch compiler warnings with custom paths |
Date: |
Fri, 6 Oct 2023 13:14:05 +0200 |
Setting --bindir= to an absolute path that is shorter than the
prefix causes GCC to complain about array accesses out of bounds.
The code however is safe, so disable the warning and explain why
we are doing so.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/cutils.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/util/cutils.c b/util/cutils.c
index 25373198adc..3856e304c52 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1012,8 +1012,17 @@ int qemu_pstrcmp0(const char **str1, const char **str2)
static inline bool starts_with_prefix(const char *dir)
{
size_t prefix_len = strlen(CONFIG_PREFIX);
+ /*
+ * dir[prefix_len] is only accessed if the length of dir is
+ * >= prefix_len, so no out of bounds access is possible.
+ */
+#pragma GCC diagnostic push
+#if !defined(__clang__) || __has_warning("-Warray-bounds=")
+#pragma GCC diagnostic ignored "-Warray-bounds="
+#endif
return !memcmp(dir, CONFIG_PREFIX, prefix_len) &&
(!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len]));
+#pragma GCC diagnostic pop
}
/* Return the next path component in dir, and store its length in *p_len. */
--
2.41.0
- [PULL 03/26] util/log: re-allow switching away from stderr log file, (continued)
- [PULL 03/26] util/log: re-allow switching away from stderr log file, Paolo Bonzini, 2023/10/06
- [PULL 02/26] sysemu/kvm: Restrict hvf_get_supported_cpuid() to x86 targets, Paolo Bonzini, 2023/10/06
- [PULL 09/26] tcg: Correct invalid mentions of 'softmmu' by 'system-mode', Paolo Bonzini, 2023/10/06
- [PULL 10/26] accel: Rename accel_softmmu* -> accel_system*, Paolo Bonzini, 2023/10/06
- [PULL 12/26] semihosting: Rename softmmu_FOO_user() -> uaccess_FOO_user(), Paolo Bonzini, 2023/10/06
- [PULL 07/26] cpu: Correct invalid mentions of 'softmmu' by 'system-mode', Paolo Bonzini, 2023/10/06
- [PULL 16/26] meson: Rename target_softmmu_arch -> target_system_arch, Paolo Bonzini, 2023/10/06
- [PULL 11/26] gdbstub: Rename 'softmmu' -> 'system', Paolo Bonzini, 2023/10/06
- [PULL 06/26] travis-ci: Correct invalid mentions of 'softmmu' by 'system', Paolo Bonzini, 2023/10/06
- [PULL 17/26] system: Rename softmmu/ directory as system/, Paolo Bonzini, 2023/10/06
- [PULL 19/26] cutils: squelch compiler warnings with custom paths,
Paolo Bonzini <=
- [PULL 20/26] audio: error hints need a trailing \n, Paolo Bonzini, 2023/10/06
- [PULL 18/26] configure: change $softmmu to $system, Paolo Bonzini, 2023/10/06
- [PULL 13/26] target/i386: Rename i386_softmmu_kvm_ss -> i386_kvm_ss, Paolo Bonzini, 2023/10/06
- [PULL 15/26] meson: Rename softmmu_mods -> system_mods, Paolo Bonzini, 2023/10/06
- [PULL 21/26] audio: disable default backends if -audio/-audiodev is used, Paolo Bonzini, 2023/10/06
- [PULL 23/26] audio: extend -audio to allow creating a default backend, Paolo Bonzini, 2023/10/06
- [PULL 24/26] audio: do not use first -audiodev as default audio device, Paolo Bonzini, 2023/10/06
- [PULL 14/26] hw/virtio/meson: Rename softmmu_virtio_ss -> system_virtio_ss, Paolo Bonzini, 2023/10/06
- [PULL 22/26] audio: extract audio_define_default, Paolo Bonzini, 2023/10/06
- [PULL 25/26] audio: reintroduce default audio backend for VNC, Paolo Bonzini, 2023/10/06