Skip to content

Commit bb247a8

Browse files
committed
Fix GCC warning when using getThis() in a conditional
Since GCC 12.x, using getThis() in a conditional yields a warning: <source>:12:22: warning: the comparison will always evaluate as 'true' for the address of 'This' will never be NULL [-Waddress] 12 | return getThis() ? 2 : 3; | ^
1 parent 345580c commit bb247a8

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

ext/intl/calendar/calendar_methods.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ using icu::Locale;
4444

4545
#define ZEND_VALUE_ERROR_INVALID_FIELD(argument, zpp_arg_position) \
4646
if (argument < 0 || argument >= UCAL_FIELD_COUNT) { \
47-
zend_argument_value_error(getThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
47+
zend_argument_value_error(hasThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
4848
"must be a valid field"); \
4949
RETURN_THROWS(); \
5050
}
5151

5252
#define ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(argument, zpp_arg_position) \
5353
if (UNEXPECTED(argument < INT32_MIN || argument > INT32_MAX)) { \
54-
zend_argument_value_error(getThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
54+
zend_argument_value_error(hasThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
5555
"must be between %d and %d", INT32_MIN, INT32_MAX); \
5656
RETURN_THROWS(); \
5757
}
5858

5959
#define ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK(argument, zpp_arg_position) \
6060
if (argument < UCAL_SUNDAY || argument > UCAL_SATURDAY) { \
61-
zend_argument_value_error(getThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
61+
zend_argument_value_error(hasThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
6262
"must be a valid day of the week"); \
6363
RETURN_THROWS(); \
6464
}
@@ -641,7 +641,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_locale)
641641
}
642642

643643
if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) {
644-
zend_argument_value_error(getThis() ? 1 : 2, "must be either Locale::ACTUAL_LOCALE or Locale::VALID_LOCALE");
644+
zend_argument_value_error(hasThis() ? 1 : 2, "must be either Locale::ACTUAL_LOCALE or Locale::VALID_LOCALE");
645645
RETURN_THROWS();
646646
}
647647

@@ -886,7 +886,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_minimal_days_in_first_week)
886886

887887
// Use ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK ?
888888
if (num_days < 1 || num_days > 7) {
889-
zend_argument_value_error(getThis() ? 1 : 2, "must be between 1 and 7");
889+
zend_argument_value_error(hasThis() ? 1 : 2, "must be between 1 and 7");
890890
RETURN_THROWS();
891891
}
892892

@@ -961,7 +961,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option)
961961
}
962962

963963
if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST) {
964-
zend_argument_value_error(getThis() ? 1 : 2, "must be either IntlCalendar::WALLTIME_FIRST or "
964+
zend_argument_value_error(hasThis() ? 1 : 2, "must be either IntlCalendar::WALLTIME_FIRST or "
965965
"IntlCalendar::WALLTIME_LAST");
966966
RETURN_THROWS();
967967
}
@@ -985,7 +985,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option)
985985

986986
if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST
987987
&& option != UCAL_WALLTIME_NEXT_VALID) {
988-
zend_argument_value_error(getThis() ? 1 : 2, "must be one of IntlCalendar::WALLTIME_FIRST, "
988+
zend_argument_value_error(hasThis() ? 1 : 2, "must be one of IntlCalendar::WALLTIME_FIRST, "
989989
"IntlCalendar::WALLTIME_LAST, or IntlCalendar::WALLTIME_NEXT_VALID");
990990
RETURN_THROWS();
991991
}

ext/intl/calendar/gregoriancalendar_methods.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static void _php_intlgregcal_constructor_body(
178178
} else {
179179
// From date/time (3, 5 or 6 arguments)
180180
for (int i = 0; i < variant; i++) {
181-
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(largs[i], getThis() ? (i-1) : i);
181+
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(largs[i], hasThis() ? (i-1) : i);
182182
}
183183

184184
if (variant == 3) {
@@ -348,7 +348,7 @@ U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
348348
}
349349

350350
if (UNEXPECTED(year < INT32_MIN || year > INT32_MAX)) {
351-
zend_argument_value_error(getThis() ? 1 : 2, "must be between %d and %d", INT32_MIN, INT32_MAX);
351+
zend_argument_value_error(hasThis() ? 1 : 2, "must be between %d and %d", INT32_MIN, INT32_MAX);
352352
RETURN_THROWS();
353353
}
354354

ext/intl/formatter/formatter_format.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ PHP_FUNCTION( numfmt_format )
114114
}
115115
RETURN_THROWS();
116116
default:
117-
zend_argument_value_error(getThis() ? 2 : 3, "must be a NumberFormatter::TYPE_* constant");
117+
zend_argument_value_error(hasThis() ? 2 : 3, "must be a NumberFormatter::TYPE_* constant");
118118
RETURN_THROWS();
119119
}
120120

ext/intl/formatter/formatter_parse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ PHP_FUNCTION( numfmt_parse )
9696
}
9797
goto cleanup;
9898
default:
99-
zend_argument_value_error(getThis() ? 2 : 3, "must be a NumberFormatter::TYPE_* constant");
99+
zend_argument_value_error(hasThis() ? 2 : 3, "must be a NumberFormatter::TYPE_* constant");
100100
goto cleanup;
101101
}
102102

ext/mysqli/mysqli.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static PHP_GINIT_FUNCTION(mysqli);
4949
} \
5050
}
5151

52-
#define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num))
52+
#define ERROR_ARG_POS(arg_num) (hasThis() ? (arg_num-1) : (arg_num))
5353

5454
static HashTable classes;
5555
static zend_object_handlers mysqli_object_handlers;

ext/mysqli/mysqli_api.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "mysqli_priv.h"
3232
#include "ext/mysqlnd/mysql_float_to_double.h"
3333

34-
#define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num))
34+
#define ERROR_ARG_POS(arg_num) (hasThis() ? (arg_num-1) : (arg_num))
3535

3636
/* {{{ Get number of affected rows in previous MySQL operation */
3737
PHP_FUNCTION(mysqli_affected_rows)
@@ -157,7 +157,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param)
157157
RETURN_THROWS();
158158
}
159159

160-
RETVAL_BOOL(!mysqli_stmt_bind_param_do_bind(stmt, argc, args, types, getThis() ? 1 : 2));
160+
RETVAL_BOOL(!mysqli_stmt_bind_param_do_bind(stmt, argc, args, types, hasThis() ? 1 : 2));
161161
MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
162162
}
163163
/* }}} */

ext/mysqli/mysqli_nonapi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "zend_smart_str.h"
2929
#include "php_mysqli_structs.h"
3030
#include "mysqli_priv.h"
31-
#define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num))
31+
#define ERROR_ARG_POS(arg_num) (hasThis() ? (arg_num-1) : (arg_num))
3232

3333
#define SAFE_STR(a) ((a)?a:"")
3434

ext/tidy/tidy.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ PHP_FUNCTION(tidy_get_opt_doc)
11761176
opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
11771177

11781178
if (!opt) {
1179-
zend_argument_value_error(getThis() ? 1 : 2, "is an invalid configuration option, \"%s\" given", optname);
1179+
zend_argument_value_error(hasThis() ? 1 : 2, "is an invalid configuration option, \"%s\" given", optname);
11801180
RETURN_THROWS();
11811181
}
11821182

@@ -1320,7 +1320,7 @@ PHP_FUNCTION(tidy_getopt)
13201320
opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
13211321

13221322
if (!opt) {
1323-
zend_argument_value_error(getThis() ? 1 : 2, "is an invalid configuration option, \"%s\" given", optname);
1323+
zend_argument_value_error(hasThis() ? 1 : 2, "is an invalid configuration option, \"%s\" given", optname);
13241324
RETURN_THROWS();
13251325
}
13261326

0 commit comments

Comments
 (0)