Compare function used in qsort gets arguments by reference, so strcmp
cannot be used directly - it expects pointer to char, but gets pointer
to pointer to char.
Introduce new helper grub_qsort_strcmp and use it in grub-install.
This helper is going to be used in a couple more places as well so
add it to global file, not in grub-install.c.
+2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/misc.c (grub_qsort_strcmp): Add qsort helper function to sort
+ strings.
+ * include/grub/util/misc.h: Define it ...
+ * util/grub-install.c (device_map_check_duplicates): ... and use it.
+
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub.d/30_os-prober.in: Fix use of grub-probe instead of
void grub_util_host_init (int *argc, char ***argv);
+int grub_qsort_strcmp (const void *, const void *);
+
#endif /* ! GRUB_UTIL_MISC_HEADER */
fclose (fp);
- qsort (d, filled, sizeof (d[0]), (int (*) (const void *, const void *))strcmp);
+ qsort (d, filled, sizeof (d[0]), grub_qsort_strcmp);
for (i = 0; i + 1 < filled; i++)
if (strcmp (d[i], d[i+1]) == 0)
grub_register_exported_symbols (void)
{
}
+
+/* Used in comparison of arrays of strings with qsort */
+int
+grub_qsort_strcmp (const void *p1, const void *p2)
+{
+ return strcmp(*(char **)p1, *(char **)p2);
+}
+