Skip to content

Commit 6456aa7

Browse files
committed
Fix -Woverflow warning for POSIX_RLIMIT_INFINITY on 32-bit
With a 64-bit rlim_t, RLIM_INFINITY does not fit into a 32-bit zend_long and the implicit conversion warns, which breaks --enable-werror builds. Register -1 in that case, which posix_setrlimit() maps back to RLIM_INFINITY. This is the value the truncation produced already, so the constant does not change on any platform.
1 parent 688d0fe commit 6456aa7

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎ext/posix/posix.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
#define POSIX_PID_MAX INT_MAX
5252
#endif
5353

54+
/* RLIM_INFINITY does not fit into a 32-bit zend_long if rlim_t is 64-bit.
55+
* posix_setrlimit() maps -1 to RLIM_INFINITY, so use that in this case. */
56+
#define PHP_POSIX_RLIM_INFINITY (RLIM_INFINITY > ZEND_LONG_MAX ? -1 : (zend_long) RLIM_INFINITY)
57+
5458
#include "posix_arginfo.h"
5559

5660
ZEND_DECLARE_MODULE_GLOBALS(posix)

‎ext/posix/posix.stub.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
#ifdef HAVE_SETRLIMIT
188188
/**
189189
* @var int
190-
* @cvalue RLIM_INFINITY
190+
* @cvalue PHP_POSIX_RLIM_INFINITY
191191
*/
192192
const POSIX_RLIMIT_INFINITY = UNKNOWN;
193193
#endif

‎ext/posix/posix_arginfo.h‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)