On 03/08/2011 09:29 AM, Michal Privoznik wrote: > This function should return pointer to const, because we don't want > to change command option value. Therfore we can ensure const-correcntess. s/Therfore/Therefore/; s/correcntess/correctness/ > +++ b/tools/virsh.c > @@ -255,7 +255,7 @@ static vshCmdOpt *vshCommandOpt(const vshCmd *cmd, const char *name); > static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *found); > static unsigned long vshCommandOptUL(const vshCmd *cmd, const char *name, > int *found); > -static char *vshCommandOptString(const vshCmd *cmd, const char *name, > +static const char *vshCommandOptString(const vshCmd *cmd, const char *name, > int *found); Indentation. Most of this patch looks mechanical, and since it still compilers, that means you pretty much did it correctly. > @@ -9529,8 +9536,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) > dir = vshCommandOptString(cmd, "dir", &found); > if (!found) { > uid_t uid = geteuid(); > - dir = virGetUserDirectory(uid); > - dir_malloced = !!dir; > + dir = dir_malloced = virGetUserDirectory(uid); > } > if (!dir) > dir = "/"; > @@ -9541,7 +9547,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) > } > > if (dir_malloced) > - VIR_FREE(dir); > + VIR_FREE(dir_malloced); Fails the useless-if-before-free 'make syntax-check' now that dir_malloced is a (possibly-NULL) pointer rather than a bool. ACK with those nits fixed, so I'm pushing with this squashed in: diff --git i/tools/virsh.c w/tools/virsh.c index 6ad4089..f7e1474 100644 --- i/tools/virsh.c +++ w/tools/virsh.c @@ -256,7 +256,7 @@ static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *found); static unsigned long vshCommandOptUL(const vshCmd *cmd, const char *name, int *found); static const char *vshCommandOptString(const vshCmd *cmd, const char *name, - int *found); + int *found); static long long vshCommandOptLongLong(const vshCmd *cmd, const char *name, int *found); static int vshCommandOptBool(const vshCmd *cmd, const char *name); @@ -9546,8 +9546,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ret = FALSE; } - if (dir_malloced) - VIR_FREE(dir_malloced); + VIR_FREE(dir_malloced); return ret; } -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list