Skip to content

Commit

Permalink
GCC15(-std=gnu23) adjustments
Browse files Browse the repository at this point in the history
1. Suppress -Wold-style-definition warnings globally since we prefer
   old-style definitions.
2. Fix hlink.c's cast in qsort() call to properly declare type.
3. Fix pool_alloc.c's function pointer type to match its usage.
4. Fix syscall.c's lseek64 forward declarations.
5. Fix bool typedef conflict in wildtest.c by renaming to rsync_bool.

This cleans up the build with modern compilers (GCC15) while maintaining
compatibility with older versions. The qsort comparison function cast in
particular is now more type-safe.

Signed-off-by: Charalampos Mitrodimas <[email protected]>
  • Loading branch information
charmitro committed Nov 19, 2024
1 parent f654e47 commit 6faf3be
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ CFLAGS="$CFLAGS -DHAVE_CONFIG_H"

# If GCC, turn on warnings.
if test x"$GCC" = x"yes"; then
CFLAGS="$CFLAGS -Wall -W"
CFLAGS="$CFLAGS -Wall -W -Wno-old-style-definition"
fi

AC_ARG_WITH(openssl-conf,
Expand Down
2 changes: 1 addition & 1 deletion hlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void match_gnums(int32 *ndx_list, int ndx_count)
struct ht_int32_node *node = NULL;
int32 gnum, gnum_next;

qsort(ndx_list, ndx_count, sizeof ndx_list[0], (int (*)()) hlink_compare_gnum);
qsort(ndx_list, ndx_count, sizeof ndx_list[0], (int (*)(const void*, const void*))hlink_compare_gnum);

for (from = 0; from < ndx_count; from++) {
file = hlink_flist->sorted[ndx_list[from]];
Expand Down
2 changes: 1 addition & 1 deletion lib/pool_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct alloc_pool
size_t size; /* extent size */
size_t quantum; /* allocation quantum */
struct pool_extent *extents; /* top extent is "live" */
void (*bomb)(); /* called if malloc fails */
void (*bomb)(const char*, const char*, int); /* called if malloc fails */
int flags;

/* statistical data */
Expand Down
10 changes: 3 additions & 7 deletions syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,10 @@ int do_fstat(int fd, STRUCT_STAT *st)
OFF_T do_lseek(int fd, OFF_T offset, int whence)
{
#ifdef HAVE_LSEEK64
#if !SIZEOF_OFF64_T
OFF_T lseek64();
/* No need for forward declaration since it's in unistd.h */
return lseek64(fd, offset, whence);
#else
off64_t lseek64();
#endif
return lseek64(fd, offset, whence);
#else
return lseek(fd, offset, whence);
return lseek(fd, offset, whence);
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions wildtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int fnmatch_errors = 0;

int wildmatch_errors = 0;

typedef char bool;
typedef char rsync_bool;

int output_iterations = 0;
int explode_mod = 0;
Expand All @@ -50,13 +50,13 @@ static struct poptOption long_options[] = {

/* match just at the start of string (anchored tests) */
static void
run_test(int line, bool matches,
run_test(int line, rsync_bool matches,
#ifdef COMPARE_WITH_FNMATCH
bool same_as_fnmatch,
rsync_bool same_as_fnmatch,
#endif
const char *text, const char *pattern)
{
bool matched;
rsync_bool matched;
#ifdef COMPARE_WITH_FNMATCH
bool fn_matched;
int flags = strstr(pattern, "**")? 0 : FNM_PATHNAME;
Expand Down

0 comments on commit 6faf3be

Please sign in to comment.