Olaf Hering
2012-Sep-20 13:19 UTC
[Libguestfs] [PATCH] rename local variable to avoid clash with match macro
match will expand to guestfs___match, rename the local variable to avoid clash. Signed-off-by: Olaf Hering <olaf at aepfle.de> diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index 06ff96d..c30ad5a 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -1128,14 +1128,14 @@ map_md_devices(guestfs_h *g, Hash_table **map) mdadm_app_free); if (!*map) g->abort_cb(); - for (char **match = matches; *match != NULL; match++) { + for (char **_match = matches; *_match != NULL; _match++) { /* Get device name and uuid for each array */ - char *dev_path = safe_asprintf(g, "%s/devicename", *match); + char *dev_path = safe_asprintf(g, "%s/devicename", *_match); char *dev = guestfs_aug_get(g, dev_path); free(dev_path); if (!dev) goto error; - char *uuid_path = safe_asprintf(g, "%s/uuid", *match); + char *uuid_path = safe_asprintf(g, "%s/uuid", *_match); char *uuid = guestfs_aug_get(g, uuid_path); free(uuid_path); if (!uuid) { -- 1.7.12
Richard W.M. Jones
2012-Sep-20 20:11 UTC
[Libguestfs] [PATCH] rename local variable to avoid clash with match macro
On Thu, Sep 20, 2012 at 03:19:43PM +0200, Olaf Hering wrote:> match will expand to guestfs___match, rename the local variable to avoid clash.This is an interesting bug. I suspect that 'match' was being expanded, and the name 'guestfs___match' was simply used as a local variable. Worrying ... I have applied this, but I named the new variable 'm' instead of '_match'. Although it would be fine as far as C99 is concerned (since the first letter is not capitalized), we tend not to use _identifiers. Thanks, Rich.> Signed-off-by: Olaf Hering <olaf at aepfle.de> > > diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c > index 06ff96d..c30ad5a 100644 > --- a/src/inspect-fs-unix.c > +++ b/src/inspect-fs-unix.c > @@ -1128,14 +1128,14 @@ map_md_devices(guestfs_h *g, Hash_table **map) > mdadm_app_free); > if (!*map) g->abort_cb(); > > - for (char **match = matches; *match != NULL; match++) { > + for (char **_match = matches; *_match != NULL; _match++) { > /* Get device name and uuid for each array */ > - char *dev_path = safe_asprintf(g, "%s/devicename", *match); > + char *dev_path = safe_asprintf(g, "%s/devicename", *_match); > char *dev = guestfs_aug_get(g, dev_path); > free(dev_path); > if (!dev) goto error; > > - char *uuid_path = safe_asprintf(g, "%s/uuid", *match); > + char *uuid_path = safe_asprintf(g, "%s/uuid", *_match); > char *uuid = guestfs_aug_get(g, uuid_path); > free(uuid_path); > if (!uuid) { > -- > 1.7.12 > > _______________________________________________ > Libguestfs mailing list > Libguestfs at redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org