Skip to content

Commit 2331554

Browse files
committed
Fix misconfiguration for macOS
`zutils.h` contains obsolete configurations for the macOS target that are bug-prone and no longer exercised. - The target OS conditional macros are misused for modern Apple platforms. `TARGET_OS_MAC` covers all Apple targets including iOS and so on. And it should not be checked with `#if defined` as they would always be defined (to either 1 or 0) on Apple platforms. - The assumption that macOS does not have `fdopen`, or defines `fdopen` as a macro is no longer valid. The null definition in `zutils.h` would conflict with the macOS SDK and cause a compilation failure. The problem hasn't manifested because the code path hasn't been exercised for years because of the outdated `TARGET_OS` guard. A recent extension in clang (llvm/llvm-project#74676) would expose the issue and break zlib builds on Apple platforms.
1 parent 643e17b commit 2331554

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

zutil.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,11 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
137137
# endif
138138
#endif
139139

140-
#if defined(MACOS) || defined(TARGET_OS_MAC)
140+
#if TARGET_OS_OSX
141141
# define OS_CODE 7
142142
# ifndef Z_SOLO
143143
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
144144
# include <unix.h> /* for fdopen */
145-
# else
146-
# ifndef fdopen
147-
# define fdopen(fd,mode) NULL /* No fdopen() */
148-
# endif
149145
# endif
150146
# endif
151147
#endif

0 commit comments

Comments
 (0)