From: Victor Seva Date: Tue, 16 Sep 2025 18:20:41 +0200 Subject: fix gcc15 build --- src/MMagicST.c | 30 +++++++++++++++++------------- src/MMagicST.h | 4 ++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/MMagicST.c b/src/MMagicST.c index 01e616c..d7cb81d 100644 --- a/src/MMagicST.c +++ b/src/MMagicST.c @@ -35,17 +35,17 @@ struct st_table_entry { * allocated initially * */ -static int numcmp(long, long); -static int numhash(long); +static int numcmp(const void *, const void *); +static int numhash(const void *); static struct st_hash_type type_numhash = { numcmp, numhash, }; -/* extern int strcmp(const char *, const char *); */ -static int strhash(const char *); +static int mm_strcmp(const void *, const void *); +static int strhash(const void *); static struct st_hash_type type_strhash = { - strcmp, + mm_strcmp, strhash, }; @@ -69,9 +69,9 @@ static void rehash(st_table *); #define alloc(type) (type*)xmalloc((unsigned)sizeof(type)) #define Calloc(n,s) (char*)xcalloc((n),(s)) -#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0) +#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((void *)(x),(void *)(y)) == 0) -#define do_hash(key,table) (unsigned int)(*(table)->type->hash)((key)) +#define do_hash(key,table) (unsigned int)(*(table)->type->hash)((void *)(key)) #define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins) /* @@ -533,11 +533,15 @@ st_foreach(table, func, arg) } } } +static int +mm_strcmp(const void *arg1, const void *arg2) { + return strcmp((const char *)arg1, (const char *)arg2); +} static int -strhash(string) - register const char *string; +strhash(const void *arg) { + register const char *string = (const char *)arg; register int c; #ifdef HASH_ELFHASH @@ -574,16 +578,16 @@ strhash(string) } static int -numcmp(x, y) - long x, y; +numcmp(const void *arg1, const void *arg2) { + long x = (long)arg1, y = (long)arg2; return x != y; } static int -numhash(n) - long n; +numhash(const void *arg1) { + long n = (long)arg1; return n; } diff --git a/src/MMagicST.h b/src/MMagicST.h index bc12624..528a48b 100644 --- a/src/MMagicST.h +++ b/src/MMagicST.h @@ -12,8 +12,8 @@ typedef unsigned long st_data_t; typedef struct st_table st_table; struct st_hash_type { - int (*compare)(); - int (*hash)(); + int (*compare)(const void *, const void *); + int (*hash)(const void *); }; struct st_table {