[libvirt] [PATCH v2]virsh: Add helper to avoid the strcase check for virsh-*.c
Eric Blake
eblake at redhat.com
Tue Aug 14 11:44:12 UTC 2012
On 08/14/2012 01:21 AM, Osier Yang wrote:
> * tools/virsh.c: New macro vshStrcasecmp
> * tools/virsh-domain-monitor.c: Use vshStrcasecmp instead of
> strcasecmp
> * tools/virsh-snapshot.c: Likewise
> * cfg.mk: Only avoid doing strcase checking for virsh.c
> ---
> cfg.mk | 2 +-
> tools/virsh-domain-monitor.c | 2 +-
> tools/virsh-snapshot.c | 4 ++--
> tools/virsh.c | 1 +
> 4 files changed, 5 insertions(+), 4 deletions(-)
ACK.
> +++ b/tools/virsh-snapshot.c
> @@ -817,8 +817,8 @@ vshSnapSorter(const void *a, const void *b)
> return sb->snap != NULL;
>
> /* User visible sort, so we want locale-specific case comparison. */
I would have moved this comment...
> - return strcasecmp(virDomainSnapshotGetName(sa->snap),
> - virDomainSnapshotGetName(sb->snap));
> + return vshStrcasecmp(virDomainSnapshotGetName(sa->snap),
> + virDomainSnapshotGetName(sb->snap));
> }
>
> /* Compute a list of snapshots from DOM. If FROM is provided, the
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 6a5724d..a2674ae 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -357,6 +357,7 @@ static void vshDebug(vshControl *ctl, int level, const char *format, ...)
>
> /* XXX: add batch support */
> #define vshPrint(_ctl, ...) vshPrintExtra(NULL, __VA_ARGS__)
> +#define vshStrcasecmp(S1, S2) strcasecmp(S1, S2)
...to here, right before this #define. That is, we only need to know
that vshStrcasecmp exists to give us user-visible sorting in one place,
rather than at each caller.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120814/9c3df3e3/attachment-0001.sig>
More information about the libvir-list
mailing list