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(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org