[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently |
Date: |
Fri, 29 May 2009 10:42:38 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
Jean-Christophe Dubois schrieb:
> qemu_malloc, qemu_free and friends are not used consistently in the qemu
> source code.
>
> This is a first attempt to use these oveloaded functions consistently all
> over
> the place instead of the default glibc versions.
>
> Signed-off-by: Jean-Christophe DUBOIS <address@hidden>
[...]
> diff -rNu qemu.org/qemu-io.c qemu/qemu-io.c
> --- qemu.org/qemu-io.c 2009-05-16 17:57:27.000000000 +0200
> +++ qemu/qemu-io.c 2009-05-18 23:48:23.000000000 +0200
> @@ -311,14 +311,14 @@
> }
>
> if (Pflag) {
> - void* cmp_buf = malloc(pattern_count);
> + void* cmp_buf = qemu_malloc(pattern_count);
> memset(cmp_buf, pattern, pattern_count);
> if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) {
> printf("Pattern verification failed at offset %lld, "
> "%d bytes\n",
> (long long) offset + pattern_offset,
> pattern_count);
> }
> - free(cmp_buf);
> + qemu_free(cmp_buf);
> }
>
> if (qflag)
> @@ -465,14 +465,14 @@
> }
>
> if (Pflag) {
> - void* cmp_buf = malloc(count);
> + void* cmp_buf = qemu_malloc(count);
> memset(cmp_buf, pattern, count);
> if (memcmp(buf, cmp_buf, count)) {
> printf("Pattern verification failed at offset %lld, "
> "%d bytes\n",
> (long long) offset, count);
> }
> - free(cmp_buf);
> + qemu_free(cmp_buf);
> }
>
> if (qflag)
Since recently qemu_malloc behaves differently from malloc with size =
0. This isn't allowed any more with qemu_malloc. So you need to check
for pattern_count == 0 and either print an error message or malloc a
different size, e.g. 1. I'm sure we don't want qemu-io to abort() in
such a case.
Or we could start over with a lengthy discussion about fixing qemu_malloc...
Kevin
- [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Jean-Christophe Dubois, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently,
Kevin Wolf <=
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Anthony Liguori, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Kevin Wolf, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Kevin Wolf, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Kevin Wolf, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Anthony Liguori, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Kevin Wolf, 2009/05/29