tree: replace some unnecessary uses of spprintf (#19354)

This commit is contained in:
Gina Peter Banyard 2025-08-05 17:25:47 +01:00 committed by GitHub
parent 0596135d20
commit d9000b3094
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 34 additions and 38 deletions

View file

@ -1383,14 +1383,14 @@ static void fpm_conf_cleanup(int which, void *arg) /* {{{ */
static void fpm_conf_ini_parser_include(char *inc, void *arg) /* {{{ */
{
char *filename;
int *error = (int *)arg;
php_glob_t g;
size_t i;
if (!inc || !arg) return;
if (*error) return; /* We got already an error. Switch to the end. */
spprintf(&filename, 0, "%s", ini_filename);
const char *filename = ini_filename;
{
g.gl_offs = 0;
@ -1398,31 +1398,26 @@ static void fpm_conf_ini_parser_include(char *inc, void *arg) /* {{{ */
#ifdef PHP_GLOB_NOMATCH
if (i == PHP_GLOB_NOMATCH) {
zlog(ZLOG_WARNING, "Nothing matches the include pattern '%s' from %s at line %d.", inc, filename, ini_lineno);
efree(filename);
return;
}
#endif /* PHP_GLOB_NOMATCH */
zlog(ZLOG_ERROR, "Unable to globalize '%s' (ret=%zd) from %s at line %d.", inc, i, filename, ini_lineno);
*error = 1;
efree(filename);
return;
}
for (i = 0; i < g.gl_pathc; i++) {
int len = strlen(g.gl_pathv[i]);
size_t len = strlen(g.gl_pathv[i]);
if (len < 1) continue;
if (g.gl_pathv[i][len - 1] == '/') continue; /* don't parse directories */
if (0 > fpm_conf_load_ini_file(g.gl_pathv[i])) {
zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, ini_lineno);
*error = 1;
efree(filename);
return;
}
}
php_globfree(&g);
}
efree(filename);
}
/* }}} */

View file

@ -111,7 +111,7 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
array_init(&params);
while (next) {
char *buffered = NULL;
zend_string *buffered = NULL;
switch (next->type) {
case OP_PARAM:
@ -125,28 +125,28 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
break;
case METHOD_PARAM:
spprintf(&buffered, 0, "%s::%s", next->method.class, next->method.name);
add_next_index_string(&params, buffered);
buffered = strpprintf(0, "%s::%s", next->method.class, next->method.name);
add_next_index_str(&params, buffered);
break;
case NUMERIC_METHOD_PARAM:
spprintf(&buffered, 0, "%s::%s#"ZEND_LONG_FMT, next->method.class, next->method.name, next->num);
add_next_index_string(&params, buffered);
buffered = strpprintf(0, "%s::%s#"ZEND_LONG_FMT, next->method.class, next->method.name, next->num);
add_next_index_str(&params, buffered);
break;
case NUMERIC_FUNCTION_PARAM:
spprintf(&buffered, 0, "%s#"ZEND_LONG_FMT, next->str, next->num);
add_next_index_string(&params, buffered);
buffered = strpprintf(0, "%s#"ZEND_LONG_FMT, next->str, next->num);
add_next_index_str(&params, buffered);
break;
case FILE_PARAM:
spprintf(&buffered, 0, "%s:"ZEND_ULONG_FMT, next->file.name, next->file.line);
add_next_index_string(&params, buffered);
buffered = strpprintf(0, "%s:"ZEND_ULONG_FMT, next->file.name, next->file.line);
add_next_index_str(&params, buffered);
break;
case NUMERIC_FILE_PARAM:
spprintf(&buffered, 0, "%s:#"ZEND_ULONG_FMT, next->file.name, next->file.line);
add_next_index_string(&params, buffered);
buffered = strpprintf(0, "%s:#"ZEND_ULONG_FMT, next->file.name, next->file.line);
add_next_index_str(&params, buffered);
break;
default: {