diff --git a/ChangeLog b/ChangeLog index aa1c7a076..ee27fccd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-12-07 Andrey Borzenkov + + * 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 * util/grub.d/30_os-prober.in: Fix use of grub-probe instead of diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h index 6aacf237a..192874d42 100644 --- a/include/grub/util/misc.h +++ b/include/grub/util/misc.h @@ -47,4 +47,6 @@ void grub_util_init_nls (void); void grub_util_host_init (int *argc, char ***argv); +int grub_qsort_strcmp (const void *, const void *); + #endif /* ! GRUB_UTIL_MISC_HEADER */ diff --git a/util/grub-install.c b/util/grub-install.c index 7a1db422b..db5e0c321 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -586,7 +586,7 @@ device_map_check_duplicates (const char *dev_map) 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) diff --git a/util/misc.c b/util/misc.c index 0de340bbe..9eb1fc13c 100644 --- a/util/misc.c +++ b/util/misc.c @@ -256,3 +256,11 @@ void 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); +} +