From: Bruno Haible Date: Tue, 5 May 2026 18:23:13 +0000 (+0200) Subject: intl: Fix an ISO C undefined behaviour. X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=df92d6a9d7873d3ab71a1ba104ba0d0f17759d43;p=thirdparty%2Fgettext.git intl: Fix an ISO C undefined behaviour. ISO C 23 § 6.5.3.3.(7) and § 6.7.7.4.(14) and § 6.2.7 forbid invoking a function pointer after having cast it to an incompatible function type. * gettext-runtime/intl/localealias.c (alias_compare): Change type of parameters to 'const void *'. (_nl_expand_alias, read_alias_file): Don't cast the alias_compare function pointer. --- diff --git a/gettext-runtime/intl/localealias.c b/gettext-runtime/intl/localealias.c index 7e0d4e7b5..ddd9b8bda 100644 --- a/gettext-runtime/intl/localealias.c +++ b/gettext-runtime/intl/localealias.c @@ -176,8 +176,7 @@ static size_t maxmap; /* Prototypes for local functions. */ static size_t read_alias_file (const char *fname, int fname_len); static int extend_alias_table (void); -static int alias_compare (const struct alias_map *map1, - const struct alias_map *map2); +static int alias_compare (const void *, const void *); #endif @@ -206,9 +205,7 @@ _nl_expand_alias (const char *name) if (nmap > 0) retval = (struct alias_map *) bsearch (&item, map, nmap, sizeof (struct alias_map), - (int (*) (const void *, - const void *) - ) alias_compare); + alias_compare); else retval = NULL; @@ -423,8 +420,7 @@ read_alias_file (const char *fname, int fname_len) fclose (fp); if (added > 0) - qsort (map, nmap, sizeof (struct alias_map), - (int (*) (const void *, const void *)) alias_compare); + qsort (map, nmap, sizeof (struct alias_map), alias_compare); return added; } @@ -450,8 +446,10 @@ extend_alias_table (void) static int -alias_compare (const struct alias_map *map1, const struct alias_map *map2) +alias_compare (const void *arg1, const void *arg2) { + const struct alias_map *map1 = (const struct alias_map *) arg1; + const struct alias_map *map2 = (const struct alias_map *) arg2; return strcasecmp (map1->alias, map2->alias); }