From 0b2e5a22eb170d6245c9ca7ccf5781e70259a08b Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 23 Nov 2026 12:06:06 -0800 Subject: [PATCH 1/4] config: drop unreferenced feature and profile macros Remove ODFS_PROFILE_FULL, ODFS_FEATURE_CACHE_BLOCK, the ODFS_FEATURE_LOG_{SERIAL,KPRINTF,RINGBUF} flags and ODFS_PLATFORM_HOST from config.h. Nothing in the tree tests any of them. The ODFS_FEATURE_CHARSET_{BUILTIN,EXTERNAL} flags are not tested yet either, but they stay: the name character set conversion will use them. Also collapse the ODFS_PROFILE_ROM conditionals whose two arms define the same value (ROCK_RIDGE, JOLIET, MULTISESSION, LOG), so the file shows only the settings that really differ between the default and the ROM profile. No behaviour change. --- include/odfs/config.h | 58 ++++++++----------------------------------- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/include/odfs/config.h b/include/odfs/config.h index 27d652f..def5c8c 100644 --- a/include/odfs/config.h +++ b/include/odfs/config.h @@ -9,35 +9,23 @@ /* * Build profiles: - * ODFS_PROFILE_FULL — all features enabled (default) - * ODFS_PROFILE_ROM — minimal ROM-capable subset + * default — all features enabled + * ODFS_PROFILE_ROM — minimal ROM-capable subset * - * Set exactly one profile, or configure individual flags below. + * Configure individual flags below or override from command line + * (-DODFS_FEATURE_xxx=0). */ -#if !defined(ODFS_PROFILE_FULL) && !defined(ODFS_PROFILE_ROM) -#define ODFS_PROFILE_FULL -#endif - /* ---------- backend feature flags ---------- */ -/* All flags can be overridden from command line (-DODFS_FEATURE_xxx=0) */ #ifndef ODFS_FEATURE_ISO9660 #define ODFS_FEATURE_ISO9660 1 #endif #ifndef ODFS_FEATURE_ROCK_RIDGE - #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_ROCK_RIDGE 1 - #else - #define ODFS_FEATURE_ROCK_RIDGE 1 - #endif + #define ODFS_FEATURE_ROCK_RIDGE 1 #endif #ifndef ODFS_FEATURE_JOLIET - #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_JOLIET 1 - #else - #define ODFS_FEATURE_JOLIET 1 - #endif + #define ODFS_FEATURE_JOLIET 1 #endif #ifndef ODFS_FEATURE_HIGH_SIERRA #ifdef ODFS_PROFILE_ROM @@ -47,11 +35,7 @@ #endif #endif #ifndef ODFS_FEATURE_MULTISESSION - #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_MULTISESSION 1 - #else - #define ODFS_FEATURE_MULTISESSION 1 - #endif + #define ODFS_FEATURE_MULTISESSION 1 #endif #ifndef ODFS_FEATURE_UDF #ifdef ODFS_PROFILE_ROM @@ -90,9 +74,6 @@ #define ODFS_FEATURE_CACHE_RETAIN 1 #endif -#ifndef ODFS_FEATURE_CACHE_BLOCK - #define ODFS_FEATURE_CACHE_BLOCK 1 -#endif #ifndef ODFS_FEATURE_CACHE_META #ifdef ODFS_PROFILE_ROM #define ODFS_FEATURE_CACHE_META 0 @@ -112,23 +93,13 @@ /* ODFS_FEATURE_LOG can be overridden from command line (-DODFS_FEATURE_LOG=0) */ #ifndef ODFS_FEATURE_LOG -#ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_LOG 1 -#else - #define ODFS_FEATURE_LOG 1 -#endif + #define ODFS_FEATURE_LOG 1 #endif #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_LOG_SERIAL 1 - #define ODFS_FEATURE_LOG_KPRINTF 0 - #define ODFS_FEATURE_LOG_RINGBUF 0 - #define ODFS_LOG_MAX_LEVEL ODFS_LOG_WARN + #define ODFS_LOG_MAX_LEVEL ODFS_LOG_WARN #else - #define ODFS_FEATURE_LOG_SERIAL 1 - #define ODFS_FEATURE_LOG_KPRINTF 1 - #define ODFS_FEATURE_LOG_RINGBUF 1 - #define ODFS_LOG_MAX_LEVEL ODFS_LOG_TRACE + #define ODFS_LOG_MAX_LEVEL ODFS_LOG_TRACE #endif /* ---------- charset feature flags ---------- */ @@ -166,13 +137,4 @@ #define ODFS_PLATFORM_AMIGA 0 #endif -/* host builds for testing */ -#ifndef ODFS_PLATFORM_HOST - #if !ODFS_PLATFORM_AMIGA - #define ODFS_PLATFORM_HOST 1 - #else - #define ODFS_PLATFORM_HOST 0 - #endif -#endif - #endif /* ODFS_CONFIG_H */ From 036b30e8fd70e8c3332dc7f7273eae9a0b1cdb85 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 23 Nov 2026 12:06:06 -0800 Subject: [PATCH 2/4] media: drop duplicate close callback check odfs_media_close() returns early when m->ops->close is NULL, so the second test of the same pointer right before the call is redundant. --- include/odfs/media.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/odfs/media.h b/include/odfs/media.h index 8563c9a..e119c66 100644 --- a/include/odfs/media.h +++ b/include/odfs/media.h @@ -145,8 +145,7 @@ static inline void odfs_media_close(odfs_media_t *m) { if (!m || !m->ops || !m->ops->close) return; - if (m->ops->close) - m->ops->close(m->ctx); + m->ops->close(m->ctx); } /* host-side: open an image file as media */ From dee600071dd9dd3bb906def6b5d2f6a8372e7506 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 23 Nov 2026 12:06:36 -0800 Subject: [PATCH 3/4] alloc: pass allocation sizes to AROS AllocVec as IPTR odfs_malloc() and odfs_calloc() cast the byte count to ULONG before calling AllocVec(). AROS declares the AllocVec() size as IPTR, so on 64-bit AROS, where size_t is 64 bits, a request above 4 GiB would be truncated and could return an undersized buffer instead of NULL. Cast to IPTR on AROS. Keep the ULONG cast for AmigaOS 3 and 4, whose AllocVec()/AllocVecTags() take a ULONG, and return NULL there for a size that does not fit. On those 32-bit targets size_t is no wider than ULONG, so the check folds away at compile time. --- include/odfs/alloc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/odfs/alloc.h b/include/odfs/alloc.h index cdf372c..ea14c74 100644 --- a/include/odfs/alloc.h +++ b/include/odfs/alloc.h @@ -27,11 +27,17 @@ static inline void *odfs_malloc(size_t size) { if (size == 0) size = 1; +#ifdef __AROS__ + return AllocVec((IPTR)size, MEMF_PUBLIC); +#else + if (sizeof(size_t) > sizeof(ULONG) && size > (size_t)(ULONG)-1) + return NULL; #if ODFS_AMIGA_OS4 return AllocVecTags((ULONG)size, AVT_Type, MEMF_SHARED, TAG_END); #else return AllocVec((ULONG)size, MEMF_PUBLIC); #endif +#endif } static inline void *odfs_calloc(size_t count, size_t size) @@ -45,6 +51,11 @@ static inline void *odfs_calloc(size_t count, size_t size) if (total == 0) total = 1; +#ifdef __AROS__ + return AllocVec((IPTR)total, MEMF_PUBLIC | MEMF_CLEAR); +#else + if (sizeof(size_t) > sizeof(ULONG) && total > (size_t)(ULONG)-1) + return NULL; #if ODFS_AMIGA_OS4 return AllocVecTags((ULONG)total, AVT_Type, MEMF_SHARED, @@ -53,6 +64,7 @@ static inline void *odfs_calloc(size_t count, size_t size) #else return AllocVec((ULONG)total, MEMF_PUBLIC | MEMF_CLEAR); #endif +#endif } static inline void odfs_free(void *ptr) From 9a5e76801d936227e844cf48604c12cf610c414f Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 23 Nov 2026 12:06:55 -0800 Subject: [PATCH 4/4] core: compare raw bytes before folding case in odfs_strcasecmp odfs_strcasecmp() folds both bytes through odfs_ascii_tolower() before comparing them. Compare the raw bytes first and fold only a pair that differs, as meta_name_eq() in the metadata cache already does. A NUL against any other byte still differs after folding, because no character folds to NUL, so the result is unchanged. The function is used by the backends' linear directory lookups, the namefix table, the CDDA virtual file names and the virtual root map, not by the metadata cache. In a linear scan most compares already fail on the first byte, where the new order adds a compare and branch before folding; a matching name now skips folding for every byte. Being inlined at all those call sites, the shorter loop shrinks the handlers: 68000 -328 bytes, 68020 -388, OS4 CDFileSystem -272; the ROM profile grows by 12 bytes. --- include/odfs/string.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/odfs/string.h b/include/odfs/string.h index a02433e..5926b62 100644 --- a/include/odfs/string.h +++ b/include/odfs/string.h @@ -60,9 +60,16 @@ static inline int odfs_strcasecmp(const char *a, const char *b) unsigned char cb; for (;;) { - ca = odfs_ascii_tolower((unsigned char)*a++); - cb = odfs_ascii_tolower((unsigned char)*b++); - if (ca != cb || ca == '\0') + ca = (unsigned char)*a++; + cb = (unsigned char)*b++; + if (ca == cb) { + if (ca == '\0') + return 0; + continue; + } + ca = odfs_ascii_tolower(ca); + cb = odfs_ascii_tolower(cb); + if (ca != cb) return (int)ca - (int)cb; } }