Skip to content

Commit 77bf9b7

Browse files
committed
Use an inline function to check for the valid mode
1 parent d803080 commit 77bf9b7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ext/standard/info.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,16 @@ static void php_get_windows_cpu(char *buf, size_t bufsize)
656656
/* }}} */
657657
#endif
658658

659+
static inline bool php_is_valid_uname_mode(char mode) {
660+
return mode == 'a' || mode == 'm' || mode == 'n' || mode == 'r' || mode == 's' || mode == 'v';
661+
}
662+
659663
/* {{{ php_get_uname */
660664
PHPAPI zend_string *php_get_uname(char mode)
661665
{
662666
char *php_uname;
663667

664-
ZEND_ASSERT(mode == 'a' || mode == 'm' || mode == 'n' || mode == 'r' || mode == 's' || mode == 'v');
668+
ZEND_ASSERT(php_is_valid_uname_mode(mode));
665669
#ifdef PHP_WIN32
666670
char tmp_uname[256];
667671
DWORD dwBuild=0;
@@ -1329,7 +1333,7 @@ PHP_FUNCTION(php_uname)
13291333
}
13301334

13311335
char mode = *mode_str;
1332-
if (mode != 'a' && mode != 'm' && mode != 'n' && mode != 'r' && mode != 's' && mode != 'v') {
1336+
if (!php_is_valid_uname_mode(mode)) {
13331337
zend_argument_value_error(1, "must be one of \"a\", \"m\", \"n\", \"r\", \"s\", or \"v\"");
13341338
RETURN_THROWS();
13351339
}

0 commit comments

Comments
 (0)