[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 139/147] meson: replace create-config with meson configure_fi
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 139/147] meson: replace create-config with meson configure_file |
Date: |
Tue, 11 Aug 2020 19:25:24 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 11/08/20 18:25, Philippe Mathieu-Daudé wrote:
> Alexander reported [*] a problem when ARRAY_SIZE(whitelist_rw) == 0 you
> access an undefined address:
But that's not accessing an undefined address, it's taking the address past
the last item---which should be okay. And I cannot reproduce it with:
#include <stdio.h>
const char *x[] = {};
int main()
{
printf("%p %p\n", x, &x[0]);
}
and -fsanitize=undefined, using either GCC 10 or clang 10 (it breaks horribly
with &x[1] so the testcase makes sense).
This should fix it, it should also be unnecessary but I guess I'm not going
to nitpick:
diff --git a/block.c b/block.c
index 67ca5433d5..2ba76b2c36 100644
--- a/block.c
+++ b/block.c
@@ -433,9 +433,11 @@ static int bdrv_format_is_whitelisted(const char
*format_name, bool read_only)
{
static const char *whitelist_rw[] = {
CONFIG_BDRV_RW_WHITELIST
+ NULL
};
static const char *whitelist_ro[] = {
CONFIG_BDRV_RO_WHITELIST
+ NULL
};
const char **p;
@@ -443,13 +445,13 @@ static int bdrv_format_is_whitelisted(const char
*format_name, bool read_only)
return 1; /* no whitelist, anything goes */
}
- for (p = whitelist_rw; p < &whitelist_rw[ARRAY_SIZE(whitelist_rw)]; p++) {
+ for (p = whitelist_rw; *p; p++) {
if (!strcmp(format_name, *p)) {
return 1;
}
}
if (read_only) {
- for (p = whitelist_ro; p < &whitelist_ro[ARRAY_SIZE(whitelist_ro)];
p++) {
+ for (p = whitelist_ro; *p; p++) {
if (!strcmp(format_name, *p)) {
return 1;
}
> The question is why CONFIG_BDRV_RW_WHITELIST & CONFIG_BDRV_RO_WHITELIST
> aren't generated by meson.build...
What do you mean? If you mean why they are in config-host.mak, it's because I
have
only done a very minimal conversion from config-host.mak to Meson options.
Paolo
- [PATCH 137/147] meson: convert check-block, (continued)
- [PATCH 137/147] meson: convert check-block, Paolo Bonzini, 2020/08/10
- [PATCH 140/147] meson: convert sample plugins, Paolo Bonzini, 2020/08/10
- [PATCH 141/147] meson: move SDL and SDL-image detection to meson, Paolo Bonzini, 2020/08/10
- [PATCH 138/147] rules.mak: drop unneeded macros, Paolo Bonzini, 2020/08/10
- [PATCH 139/147] meson: replace create-config with meson configure_file, Paolo Bonzini, 2020/08/10
- Re: [PATCH 139/147] meson: replace create-config with meson configure_file,
Paolo Bonzini <=
[PATCH 142/147] meson: convert VNC and dependent libraries to meson, Paolo Bonzini, 2020/08/10
[PATCH 143/147] meson: convert po/, Paolo Bonzini, 2020/08/10
[PATCH 146/147] cflags Signed-off-by: Paolo Bonzini <address@hidden>, Paolo Bonzini, 2020/08/10
[PATCH 147/147] meson: avoid unstable module warning with Meson 0.56.0 or newer, Paolo Bonzini, 2020/08/10
[PATCH 145/147] acceptance: use stable URLs for the Debian and Ubuntu installer, Paolo Bonzini, 2020/08/10
[PATCH 144/147] meson: update build-system documentation, Paolo Bonzini, 2020/08/10
Re: [PATCH 000/147] Meson integration for 5.2, Peter Maydell, 2020/08/10