[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 1/3] block: Fix bdrv_iterate_format
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 1/3] block: Fix bdrv_iterate_format() sorting |
Date: |
Wed, 12 Oct 2016 16:31:44 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
On 10/12/2016 03:49 PM, Max Reitz wrote:
> bdrv_iterate_format() did not actually sort the formats by name but by
> "pointer interpreted as string". That is probably not what we intended
> to do, so fix it (by changing qsort_strcmp() so it matches the example
> from qsort()'s manual page).
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
I'm a bit surprised that code sanitizers like Coverity or ASAN aren't
(yet?) able to flag this.
Reviewed-by: Eric Blake <address@hidden>
>
> diff --git a/block.c b/block.c
> index bb1f1ec..e46e4b2 100644
> --- a/block.c
> +++ b/block.c
> @@ -2789,7 +2789,7 @@ const char *bdrv_get_format_name(BlockDriverState *bs)
>
> static int qsort_strcmp(const void *a, const void *b)
> {
> - return strcmp(a, b);
> + return strcmp(*(char *const *)a, *(char *const *)b);
> }
>
> void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH 0/3] iotests: Skip 162 if there is no SSH support, Max Reitz, 2016/10/12
- [Qemu-block] [PATCH 1/3] block: Fix bdrv_iterate_format() sorting, Max Reitz, 2016/10/12
- Re: [Qemu-block] [Qemu-devel] [PATCH 1/3] block: Fix bdrv_iterate_format() sorting,
Eric Blake <=
- [Qemu-block] [PATCH 2/3] block: Emit modules in bdrv_iterate_format(), Max Reitz, 2016/10/12
- [Qemu-block] [PATCH 3/3] iotests: Skip test 162 if there is no SSH support, Max Reitz, 2016/10/12
- Re: [Qemu-block] [Qemu-devel] [PATCH 0/3] iotests: Skip 162 if there is no SSH support, no-reply, 2016/10/12
- Re: [Qemu-block] [PATCH 0/3] iotests: Skip 162 if there is no SSH support, Max Reitz, 2016/10/28