* [Qemu-devel] [PATCH] qemu-nbd: Rename 'exp' variable clashing with math::exp() symbol
@ 2019-01-11 16:35 Philippe Mathieu-Daudé
2019-01-11 16:36 ` Philippe Mathieu-Daudé
2019-01-11 17:26 ` Eric Blake
0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-01-11 16:35 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eric Blake, qemu-block,
Vladimir Sementsov-Ogievskiy, Philippe Mathieu-Daudé
The use of a variable named 'exp' prevents includes to import <math.h>.
Rename it to avoid:
qemu-nbd.c:64:19: error: ‘exp’ redeclared as different kind of symbol
static NBDExport *exp;
^~~
In file included from /usr/include/features.h:428,
from /usr/include/bits/libc-header-start.h:33,
from /usr/include/stdint.h:26,
from /usr/lib/gcc/x86_64-redhat-linux/8/include/stdint.h:9,
from /source/qemu/include/qemu/osdep.h:80,
from /source/qemu/qemu-nbd.c:19:
/usr/include/bits/mathcalls.h:95:1: note: previous declaration of ‘exp’ was here
__MATHCALL_VEC (exp,, (_Mdouble_ __x));
^~~~~~~~~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
qemu-nbd.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 2807e13239..6ca02b6d87 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -61,7 +61,7 @@
#define MBR_SIZE 512
-static NBDExport *exp;
+static NBDExport *export;
static int verbose;
static char *srcpath;
static SocketAddress *saddr;
@@ -335,7 +335,7 @@ static int nbd_can_accept(void)
return state == RUNNING && nb_fds < shared;
}
-static void nbd_export_closed(NBDExport *exp)
+static void nbd_export_closed(NBDExport *export)
{
assert(state == TERMINATING);
state = TERMINATED;
@@ -1015,10 +1015,11 @@ int main(int argc, char **argv)
}
}
- exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_closed,
- writethrough, NULL, &error_fatal);
- nbd_export_set_name(exp, export_name);
- nbd_export_set_description(exp, export_description);
+ export = nbd_export_new(bs, dev_offset, fd_size, nbdflags,
+ nbd_export_closed, writethrough,
+ NULL, &error_fatal);
+ nbd_export_set_name(export, export_name);
+ nbd_export_set_description(export, export_description);
if (device) {
#if HAVE_NBD_DEVICE
@@ -1055,9 +1056,9 @@ int main(int argc, char **argv)
main_loop_wait(false);
if (state == TERMINATE) {
state = TERMINATING;
- nbd_export_close(exp);
- nbd_export_put(exp);
- exp = NULL;
+ nbd_export_close(export);
+ nbd_export_put(export);
+ export = NULL;
}
} while (state != TERMINATED);
--
2.17.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-nbd: Rename 'exp' variable clashing with math::exp() symbol
2019-01-11 16:35 [Qemu-devel] [PATCH] qemu-nbd: Rename 'exp' variable clashing with math::exp() symbol Philippe Mathieu-Daudé
@ 2019-01-11 16:36 ` Philippe Mathieu-Daudé
2019-01-11 17:26 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-01-11 16:36 UTC (permalink / raw)
To: QEMU Developers, QEMU Trivial
Cc: Paolo Bonzini, Eric Blake, Qemu-block, Vladimir Sementsov-Ogievskiy
Cc'ing qemu-trivial@nongnu.org
On Fri, Jan 11, 2019 at 5:35 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> The use of a variable named 'exp' prevents includes to import <math.h>.
>
> Rename it to avoid:
>
> qemu-nbd.c:64:19: error: ‘exp’ redeclared as different kind of symbol
> static NBDExport *exp;
> ^~~
> In file included from /usr/include/features.h:428,
> from /usr/include/bits/libc-header-start.h:33,
> from /usr/include/stdint.h:26,
> from /usr/lib/gcc/x86_64-redhat-linux/8/include/stdint.h:9,
> from /source/qemu/include/qemu/osdep.h:80,
> from /source/qemu/qemu-nbd.c:19:
> /usr/include/bits/mathcalls.h:95:1: note: previous declaration of ‘exp’ was here
> __MATHCALL_VEC (exp,, (_Mdouble_ __x));
> ^~~~~~~~~~~~~~
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> qemu-nbd.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 2807e13239..6ca02b6d87 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -61,7 +61,7 @@
>
> #define MBR_SIZE 512
>
> -static NBDExport *exp;
> +static NBDExport *export;
> static int verbose;
> static char *srcpath;
> static SocketAddress *saddr;
> @@ -335,7 +335,7 @@ static int nbd_can_accept(void)
> return state == RUNNING && nb_fds < shared;
> }
>
> -static void nbd_export_closed(NBDExport *exp)
> +static void nbd_export_closed(NBDExport *export)
> {
> assert(state == TERMINATING);
> state = TERMINATED;
> @@ -1015,10 +1015,11 @@ int main(int argc, char **argv)
> }
> }
>
> - exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_closed,
> - writethrough, NULL, &error_fatal);
> - nbd_export_set_name(exp, export_name);
> - nbd_export_set_description(exp, export_description);
> + export = nbd_export_new(bs, dev_offset, fd_size, nbdflags,
> + nbd_export_closed, writethrough,
> + NULL, &error_fatal);
> + nbd_export_set_name(export, export_name);
> + nbd_export_set_description(export, export_description);
>
> if (device) {
> #if HAVE_NBD_DEVICE
> @@ -1055,9 +1056,9 @@ int main(int argc, char **argv)
> main_loop_wait(false);
> if (state == TERMINATE) {
> state = TERMINATING;
> - nbd_export_close(exp);
> - nbd_export_put(exp);
> - exp = NULL;
> + nbd_export_close(export);
> + nbd_export_put(export);
> + export = NULL;
> }
> } while (state != TERMINATED);
>
> --
> 2.17.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-nbd: Rename 'exp' variable clashing with math::exp() symbol
2019-01-11 16:35 [Qemu-devel] [PATCH] qemu-nbd: Rename 'exp' variable clashing with math::exp() symbol Philippe Mathieu-Daudé
2019-01-11 16:36 ` Philippe Mathieu-Daudé
@ 2019-01-11 17:26 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2019-01-11 17:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, qemu-block, Vladimir Sementsov-Ogievskiy
[-- Attachment #1: Type: text/plain, Size: 2961 bytes --]
On 1/11/19 10:35 AM, Philippe Mathieu-Daudé wrote:
> The use of a variable named 'exp' prevents includes to import <math.h>.
>
> Rename it to avoid:
>
> qemu-nbd.c:64:19: error: ‘exp’ redeclared as different kind of symbol
> static NBDExport *exp;
> ^~~
> In file included from /usr/include/features.h:428,
> from /usr/include/bits/libc-header-start.h:33,
> from /usr/include/stdint.h:26,
> from /usr/lib/gcc/x86_64-redhat-linux/8/include/stdint.h:9,
> from /source/qemu/include/qemu/osdep.h:80,
> from /source/qemu/qemu-nbd.c:19:
> /usr/include/bits/mathcalls.h:95:1: note: previous declaration of ‘exp’ was here
> __MATHCALL_VEC (exp,, (_Mdouble_ __x));
> ^~~~~~~~~~~~~~
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> qemu-nbd.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
Why did you need to import math.h?
But it's reasonable enough. Will queue through my NBD tree; in part
because it has conflicts with other pending NBD patches (so
trivial-patches taking it would actually cost me more efforts than me
just fixing the conflicts).
Reviewed-by: Eric Blake <eblake@redhat.com>
> +++ b/qemu-nbd.c
> @@ -61,7 +61,7 @@
>
> #define MBR_SIZE 512
>
> -static NBDExport *exp;
> +static NBDExport *export;
This one is a definite problem (POSIX says you shouldn't name any static
variable the same as a standard function entry point, even if it happens
to lnik)...
> static int verbose;
> static char *srcpath;
> static SocketAddress *saddr;
> @@ -335,7 +335,7 @@ static int nbd_can_accept(void)
> return state == RUNNING && nb_fds < shared;
> }
>
> -static void nbd_export_closed(NBDExport *exp)
> +static void nbd_export_closed(NBDExport *export)
...this one just silences a -Wshadow but is permitted by strict C. We
have too many other -Wshadow violations in our code base, but I don't
mind getting rid of this one.
> @@ -1015,10 +1015,11 @@ int main(int argc, char **argv)
> }
> }
>
> - exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_closed,
> - writethrough, NULL, &error_fatal);
> - nbd_export_set_name(exp, export_name);
> - nbd_export_set_description(exp, export_description);
> + export = nbd_export_new(bs, dev_offset, fd_size, nbdflags,
> + nbd_export_closed, writethrough,
> + NULL, &error_fatal);
> + nbd_export_set_name(export, export_name);
> + nbd_export_set_description(export, export_description);
Here's where my pending to add 'qemu-nbd --bitmap' conflict; I don't
mind fixing it.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-11 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 16:35 [Qemu-devel] [PATCH] qemu-nbd: Rename 'exp' variable clashing with math::exp() symbol Philippe Mathieu-Daudé
2019-01-11 16:36 ` Philippe Mathieu-Daudé
2019-01-11 17:26 ` Eric Blake
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.