Skip to content

Fix FTP module type and initializer defects surfaced by GCC 13 - #165

Merged
midwan merged 2 commits into
masterfrom
ftp-gcc13-warning-fixes
Aug 3, 2026
Merged

Fix FTP module type and initializer defects surfaced by GCC 13#165
midwan merged 2 commits into
masterfrom
ftp-gcc13-warning-fixes

Conversation

@midwan

@midwan midwan commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Building the OS3 target with GCC 13.4 (via stefanreinauer/amiga-gcc:gcc-v13.4) surfaced several latent defects in the FTP module that GCC 6.5 does not diagnose. No functional change intended.

Changes

Function pointer type mismatch (the one with teeth)message_update() was declared taking struct message_update_info *, but every consumer types the callback as int (*)(void *, int, char *): the signature used by ftp_cwd(), connect_host(), login() and _getreply() in ftp.h, and by the updatefn/startupfn/cwdfn locals. Calling through a mismatched function pointer is undefined behaviour, and it was happening at five sites — ftp_lister.c:1004,1125,2051 and ftp_lister_connect.c:620,624.

Fixed at the definition so all five sites are well typed with no casts. Worth doing regardless of toolchain: GCC 14 rejects this outright, and mismatched indirect calls are a known hazard under -flto, which the OS3 build uses.

Always-true guardlister_new_connection() tested cm->cm_opus && before dereferencing, but cm_opus is a char[] member so the test can never be false; cm itself is already checked one line above. Dead term removed.

Brace elisionsystype_lookup()'s sys_types[] initialized an array of two-member structs from a flat list. Legal C and behaviourally correct, but fragile. Now braced per element.

struct timeval initializeriread() used {0, 0}. The NDK 3.2 definition wraps both fields in anonymous unions (tv_sec/tv_secs, tv_usec/tv_micro), so the flat form warns. Changed to {0}, which is already the idiom at ftp.c:1213,1613,1867 and ftp_recursive.c:3477 — this line was the lone deviation.

Verification

Check Result
GCC 6.5 (sacredbanana/amiga-compiler:m68k-amigaos) make os3 all debug=no exit 0, no new warnings in touched files
GCC 13.4, the seven target warnings all resolved; zero ftp_lister_connect.c warnings remain

CI exercises the GCC 6.5 path, which is what the regression build above covers.

Not included

A GCC 13 baseline over the whole codebase shows 261 unique warnings. Among them are 11 more -Waddress always-true tests of exactly the class fixed here — buffers_sort.c (8, lines 536-581), config_environment.c:1521, filetype.c:2290, ftp_main.c:1189. Each needs individual reading to tell whether the intended check was something else, so they are left for a follow-up rather than bundled in.

Building the OS3 target with GCC 13.4 (via stefanreinauer/amiga-gcc)
surfaced several latent defects in the FTP module that GCC 6.5 does not
diagnose.

message_update() was declared as taking a struct message_update_info *,
but every consumer types the callback as int (*)(void *, int, char *) --
the signature used by ftp_cwd(), connect_host(), login() and _getreply()
in ftp.h, and by the updatefn/startupfn/cwdfn locals. Calling through a
mismatched function pointer is undefined behaviour, and it was happening
at five sites (ftp_lister.c:1004,1125,2051 and
ftp_lister_connect.c:620,624). Fixed at the definition so all five call
sites are well typed without casts. GCC 14 rejects this outright, and
mismatched indirect calls are a known hazard under LTO.

lister_new_connection() tested "cm->cm_opus &&" before dereferencing it,
but cm_opus is a char array member, so the test is always true; cm itself
is already checked. Dropped the dead term.

systype_lookup()'s sys_types[] relied on brace elision to initialize an
array of two-member structs from a flat list. Legal, but fragile; now
braced per element.

ftp.c's iread() initialized struct timeval with {0, 0}. The NDK 3.2
definition wraps both fields in anonymous unions, so the flat form warns.
Changed to {0}, matching ftp.c:1213,1613,1867 and ftp_recursive.c:3477.

No functional change intended. Verified with a full OS3 build under the
production GCC 6.5 image (clean) and under GCC 13.4 (all seven warnings
resolved).
The sacredbanana/amiga-compiler tags are mutable and get rebuilt in
place, so CI can break on commits that change nothing relevant. A rebuild
on 2026-07-04 shipped a ppc-morphos image whose amd64 cc1 cannot be
executed:

  ppc-morphos-gcc: fatal error: cannot execute
  '/opt/ppc-morphos/lib/gcc-lib/ppc-morphos/15.2.0/cc1':
  posix_spawn: Exec format error

That broke every MorphOS build on the first source file compiled, on
branches whose changes were confined to the FTP module. Master's last
green run predates the rebuild, so master is equally affected.

Pin all three sacredbanana images by digest. m68k-amigaos and
ppc-amigaos are pinned to the current images, which are verified green.
ppc-morphos is pinned to the last known-good image (2025-08-31, GCC
15.1.0), which was verified locally with a full 'make mos all debug=no'
producing every artifact including ftp.module.

The midwan/aros-compiler images are left as tags since they are ours and
do not change without our involvement.
@midwan
midwan merged commit 9362996 into master Aug 3, 2026
16 checks passed
@midwan
midwan deleted the ftp-gcc13-warning-fixes branch August 3, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant