From 051414bec6bdc43b8345e317b680d2d063b28067 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 12 Jul 2025 14:52:32 +0100 Subject: [PATCH] streams: use an enum for return type of _php_stream_make_seekable() --- main/php_streams.h | 13 ++++++++----- main/streams/cast.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main/php_streams.h b/main/php_streams.h index d3a6660c6ca..1c52539cfca 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -646,15 +646,18 @@ PHPAPI const char *php_stream_locate_eol(php_stream *stream, zend_string *buf); /* pushes an error message onto the stack for a wrapper instance */ PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); -#define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */ -#define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */ -#define PHP_STREAM_FAILED 2 /* an error occurred while attempting conversion */ -#define PHP_STREAM_CRITICAL 3 /* an error occurred; origstream is in an unknown state; you should close origstream */ +typedef enum { + PHP_STREAM_UNCHANGED = 0, /* orig stream was seekable anyway */ + PHP_STREAM_RELEASED = 1, /* newstream should be used; origstream is no longer valid */ + PHP_STREAM_FAILED = 2, /* an error occurred while attempting conversion */ + PHP_STREAM_CRITICAL = 3, /* an error occurred; origstream is in an unknown state; you should close origstream */ +} php_stream_make_seekable_status; + #define PHP_STREAM_NO_PREFERENCE 0 #define PHP_STREAM_PREFER_STDIO 1 #define PHP_STREAM_FORCE_CONVERSION 2 /* DO NOT call this on streams that are referenced by resources! */ -PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC); +PHPAPI php_stream_make_seekable_status _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC); #define php_stream_make_seekable(origstream, newstream, flags) _php_stream_make_seekable((origstream), (newstream), (flags) STREAMS_CC) /* Give other modules access to the url_stream_wrappers_hash and stream_filters_hash */ diff --git a/main/streams/cast.c b/main/streams/cast.c index 5c78b560945..4b718302457 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -370,7 +370,7 @@ PHPAPI FILE * _php_stream_open_wrapper_as_file(char *path, char *mode, int optio /* }}} */ /* {{{ php_stream_make_seekable */ -PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC) +PHPAPI php_stream_make_seekable_status _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC) { if (newstream == NULL) { return PHP_STREAM_FAILED;