Fix FTP module type and initializer defects surfaced by GCC 13 - #165
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 takingstruct message_update_info *, but every consumer types the callback asint (*)(void *, int, char *): the signature used byftp_cwd(),connect_host(),login()and_getreply()inftp.h, and by theupdatefn/startupfn/cwdfnlocals. Calling through a mismatched function pointer is undefined behaviour, and it was happening at five sites —ftp_lister.c:1004,1125,2051andftp_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 guard —
lister_new_connection()testedcm->cm_opus &&before dereferencing, butcm_opusis achar[]member so the test can never be false;cmitself is already checked one line above. Dead term removed.Brace elision —
systype_lookup()'ssys_types[]initialized an array of two-member structs from a flat list. Legal C and behaviourally correct, but fragile. Now braced per element.struct timevalinitializer —iread()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 atftp.c:1213,1613,1867andftp_recursive.c:3477— this line was the lone deviation.Verification
sacredbanana/amiga-compiler:m68k-amigaos)make os3 all debug=noftp_lister_connect.cwarnings remainCI 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
-Waddressalways-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.