virsh: Rename namesorter to vshNameSorter and clean up indentation

This commit is contained in:
Peter Krempa 2012-06-19 15:13:47 +02:00
parent fafb80a145
commit f1b872b25a

View File

@ -500,12 +500,14 @@ static int idsorter(const void *a, const void *b) {
return -1; return -1;
return 0; return 0;
} }
static int namesorter(const void *a, const void *b) { static int
const char **sa = (const char**)a; vshNameSorter(const void *a, const void *b)
const char **sb = (const char**)b; {
const char **sa = (const char**)a;
const char **sb = (const char**)b;
/* User visible sort, so we want locale-specific case comparison. */ /* User visible sort, so we want locale-specific case comparison. */
return strcasecmp(*sa, *sb); return strcasecmp(*sa, *sb);
} }
static double static double
@ -1083,7 +1085,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
qsort(&names[0], maxname, sizeof(char*), namesorter); qsort(&names[0], maxname, sizeof(char*), vshNameSorter);
} }
} }
@ -8672,7 +8674,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter); qsort(&activeNames[0], maxactive, sizeof(char *), vshNameSorter);
} }
} }
if (inactive) { if (inactive) {
@ -8694,7 +8696,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter); qsort(&inactiveNames[0], maxinactive, sizeof(char*), vshNameSorter);
} }
} }
vshPrintExtra(ctl, "%-20s %-10s %s\n", _("Name"), _("State"), vshPrintExtra(ctl, "%-20s %-10s %s\n", _("Name"), _("State"),
@ -8944,7 +8946,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter); qsort(&activeNames[0], maxactive, sizeof(char *), vshNameSorter);
} }
} }
if (inactive) { if (inactive) {
@ -8966,7 +8968,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter); qsort(&inactiveNames[0], maxinactive, sizeof(char*), vshNameSorter);
} }
} }
vshPrintExtra(ctl, "%-20s %-10s %s\n", _("Name"), _("State"), vshPrintExtra(ctl, "%-20s %-10s %s\n", _("Name"), _("State"),
@ -9938,7 +9940,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
qsort(&names[0], numfilters, sizeof(char *), namesorter); qsort(&names[0], numfilters, sizeof(char *), vshNameSorter);
vshPrintExtra(ctl, "%-36s %-20s \n", _("UUID"), _("Name")); vshPrintExtra(ctl, "%-36s %-20s \n", _("UUID"), _("Name"));
vshPrintExtra(ctl, vshPrintExtra(ctl,
@ -10728,7 +10730,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
} }
/* Sort the storage pool names */ /* Sort the storage pool names */
qsort(poolNames, numAllPools, sizeof(*poolNames), namesorter); qsort(poolNames, numAllPools, sizeof(*poolNames), vshNameSorter);
/* Collect the storage pool information for display */ /* Collect the storage pool information for display */
for (i = 0; i < numAllPools; i++) { for (i = 0; i < numAllPools; i++) {
@ -12385,7 +12387,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
} }
/* Sort the volume names */ /* Sort the volume names */
qsort(&activeNames[0], numVolumes, sizeof(*activeNames), namesorter); qsort(&activeNames[0], numVolumes, sizeof(*activeNames), vshNameSorter);
/* Set aside memory for volume information pointers */ /* Set aside memory for volume information pointers */
volInfoTexts = vshCalloc(ctl, numVolumes, sizeof(*volInfoTexts)); volInfoTexts = vshCalloc(ctl, numVolumes, sizeof(*volInfoTexts));
@ -13048,7 +13050,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
qsort(uuids, maxuuids, sizeof(char *), namesorter); qsort(uuids, maxuuids, sizeof(char *), vshNameSorter);
vshPrintExtra(ctl, "%-36s %s\n", _("UUID"), _("Usage")); vshPrintExtra(ctl, "%-36s %s\n", _("UUID"), _("Usage"));
vshPrintExtra(ctl, "-----------------------------------------------------------\n"); vshPrintExtra(ctl, "-----------------------------------------------------------\n");
@ -13331,7 +13333,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
VIR_FREE(devices); VIR_FREE(devices);
return false; return false;
} }
qsort(&devices[0], num_devices, sizeof(char*), namesorter); qsort(&devices[0], num_devices, sizeof(char*), vshNameSorter);
if (tree) { if (tree) {
char **parents = vshMalloc(ctl, sizeof(char *) * num_devices); char **parents = vshMalloc(ctl, sizeof(char *) * num_devices);
struct vshNodeList arrays = { devices, parents }; struct vshNodeList arrays = { devices, parents };