com php-src: Fix some printf() specifier usages: main/main.c sapi/fpm/fpm/fpm_status.c

From: Date: Tue, 21 Nov 2017 21:50:27 +0000
Subject: com php-src: Fix some printf() specifier usages: main/main.c sapi/fpm/fpm/fpm_status.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100333@lists.php.net to get a copy of this message
Commit: 7d5691cd69c4528e2bc0bb909c60310cbf03b33a Author: Sebastian Ramadan <plebbyastian@gmail.com> Tue, 21 Nov 2017 22:50:27 +0100 Committer: Nikita Popov <nikita.ppv@gmail.com> Tue, 21 Nov 2017 22:50:27 +0100 Parents: 1415f27d010d8f61499d25d5ad01f060a8436810 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7d5691cd69c4528e2bc0bb909c60310cbf03b33a Log: Fix some printf() specifier usages Use PRIu32 when printing uint32_t. Fix some %u/%d confusions. Add some casts where types are not standardized. Changed paths: M main/main.c M sapi/fpm/fpm/fpm_status.c

diff --git a/main/main.c b/main/main.c index 3e7f956..d080439 100644 --- a/main/main.c +++ b/main/main.c @@ -1162,14 +1162,14 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, buffer, GetCommandLine()); } #endif - spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); + spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %" PRIu32, error_type_str, buffer, error_filename, error_lineno); php_log_err_with_severity(log_buffer, syslog_type_int); efree(log_buffer); } if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors)))) { if (PG(xmlrpc_errors)) { - php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno); + php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %" PRIu32 "</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno); } else { char *prepend_string = INI_STR("error_prepend_string"); char *append_string = INI_STR("error_append_string"); @@ -1177,22 +1177,22 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u if (PG(html_errors)) { if (type == E_ERROR || type == E_PARSE) { zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, get_safe_charset_hint()); - php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string)); + php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string)); zend_string_free(buf); } else { - php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } } else { /* Write CLI/CGI errors to stderr if display_errors = "stderr" */ if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi")) && PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR ) { - fprintf(stderr, "%s: %s in %s on line %u\n", error_type_str, buffer, error_filename, error_lineno); + fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, buffer, error_filename, error_lineno); #ifdef PHP_WIN32 fflush(stderr); #endif } else { - php_printf("%s\n%s: %s in %s on line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + php_printf("%s\n%s: %s in %s on line %" PRIu32 "\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } } } @@ -1212,7 +1212,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u trigger_break=0; break; } - zend_output_debug_string(trigger_break, "%s(%d) : %s - %s", error_filename, error_lineno, error_type_str, buffer); + zend_output_debug_string(trigger_break, "%s(%" PRIu32 ") : %s - %s", error_filename, error_lineno, error_type_str, buffer); } #endif } @@ -1509,17 +1509,17 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void if (message==ZMSG_MEMORY_LEAK_DETECTED) { zend_leak_info *t = (zend_leak_info *) data; - snprintf(memory_leak_buf, 512, "%s(%d) : Freeing " ZEND_ADDR_FMT " (%zu bytes), script=%s\n", t->filename, t->lineno, (size_t)t->addr, t->size, SAFE_FILENAME(SG(request_info).path_translated)); + snprintf(memory_leak_buf, 512, "%s(%" PRIu32 ") : Freeing " ZEND_ADDR_FMT " (%zu bytes), script=%s\n", t->filename, t->lineno, (size_t)t->addr, t->size, SAFE_FILENAME(SG(request_info).path_translated)); if (t->orig_filename) { char relay_buf[512]; - snprintf(relay_buf, 512, "%s(%d) : Actual location (location was relayed)\n", t->orig_filename, t->orig_lineno); + snprintf(relay_buf, 512, "%s(%" PRIu32 ") : Actual location (location was relayed)\n", t->orig_filename, t->orig_lineno); strlcat(memory_leak_buf, relay_buf, sizeof(memory_leak_buf)); } } else { unsigned long leak_count = (zend_uintptr_t) data; - snprintf(memory_leak_buf, 512, "Last leak repeated %ld time%s\n", leak_count, (leak_count>1?"s":"")); + snprintf(memory_leak_buf, 512, "Last leak repeated %lu time%s\n", leak_count, (leak_count>1?"s":"")); } # if defined(PHP_WIN32) OutputDebugString(memory_leak_buf); diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 42d7d7b..92b55ab 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -151,9 +151,9 @@ int fpm_status_handle_request(void) /* {{{ */ "<tr><th>start since</th><td>%lu</td></tr>\n" "<tr><th>accepted conn</th><td>%lu</td></tr>\n" #ifdef HAVE_FPM_LQ - "<tr><th>listen queue</th><td>%u</td></tr>\n" - "<tr><th>max listen queue</th><td>%u</td></tr>\n" - "<tr><th>listen queue len</th><td>%d</td></tr>\n" + "<tr><th>listen queue</th><td>%d</td></tr>\n" + "<tr><th>max listen queue</th><td>%d</td></tr>\n" + "<tr><th>listen queue len</th><td>%u</td></tr>\n" #endif "<tr><th>idle processes</th><td>%d</td></tr>\n" "<tr><th>active processes</th><td>%d</td></tr>\n" @@ -223,9 +223,9 @@ int fpm_status_handle_request(void) /* {{{ */ "<start-since>%lu</start-since>\n" "<accepted-conn>%lu</accepted-conn>\n" #ifdef HAVE_FPM_LQ - "<listen-queue>%u</listen-queue>\n" - "<max-listen-queue>%u</max-listen-queue>\n" - "<listen-queue-len>%d</listen-queue-len>\n" + "<listen-queue>%d</listen-queue>\n" + "<max-listen-queue>%d</max-listen-queue>\n" + "<listen-queue-len>%u</listen-queue-len>\n" #endif "<idle-processes>%d</idle-processes>\n" "<active-processes>%d</active-processes>\n" @@ -273,9 +273,9 @@ int fpm_status_handle_request(void) /* {{{ */ "\"start since\":%lu," "\"accepted conn\":%lu," #ifdef HAVE_FPM_LQ - "\"listen queue\":%u," - "\"max listen queue\":%u," - "\"listen queue len\":%d," + "\"listen queue\":%d," + "\"max listen queue\":%d," + "\"listen queue len\":%u," #endif "\"idle processes\":%d," "\"active processes\":%d," @@ -323,9 +323,9 @@ int fpm_status_handle_request(void) /* {{{ */ "start since: %lu\n" "accepted conn: %lu\n" #ifdef HAVE_FPM_LQ - "listen queue: %u\n" - "max listen queue: %u\n" - "listen queue len: %d\n" + "listen queue: %d\n" + "max listen queue: %d\n" + "listen queue len: %u\n" #endif "idle processes: %d\n" "active processes: %d\n" @@ -362,7 +362,7 @@ int fpm_status_handle_request(void) /* {{{ */ scoreboard.pool, PM2STR(scoreboard.pm), time_buffer, - now_epoch - scoreboard.start_epoch, + (unsigned long) (now_epoch - scoreboard.start_epoch), scoreboard.requests, #ifdef HAVE_FPM_LQ scoreboard.lq, @@ -443,10 +443,10 @@ int fpm_status_handle_request(void) /* {{{ */ } strftime(time_buffer, sizeof(time_buffer) - 1, time_format, localtime(&proc.start_epoch)); spprintf(&buffer, 0, full_syntax, - proc.pid, + (int) proc.pid, fpm_request_get_stage_name(proc.request_stage), time_buffer, - now_epoch - proc.start_epoch, + (unsigned long) (now_epoch - proc.start_epoch), proc.requests, duration.tv_sec * 1000000UL + duration.tv_usec, proc.request_method[0] != '\0' ? proc.request_method : "-",
« previous php.cvs (#100333) next »