Skip to content

Commit 57d3888

Browse files
committed
Use correct format string in curl debug messages
Use `%p` for pointers, `%zu` for size_t. This only applies when PHP_CURL_DEBUG is enabled. If so, it solves compiler warnings, avoids undefined behavior and prints values correctly.
1 parent 2c7c630 commit 57d3888

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

ext/curl/interface.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
528528

529529
#if PHP_CURL_DEBUG
530530
fprintf(stderr, "curl_write() called\n");
531-
fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx);
531+
fprintf(stderr, "data = %s, size = %zu, nmemb = %zu, ctx = %p\n", data, size, nmemb, (void *) ctx);
532532
#endif
533533

534534
switch (write_handler->method) {
@@ -610,7 +610,7 @@ static int curl_progress(void *clientp, double dltotal, double dlnow, double ult
610610

611611
#if PHP_CURL_DEBUG
612612
fprintf(stderr, "curl_progress() called\n");
613-
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
613+
fprintf(stderr, "clientp = %p, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
614614
#endif
615615
if (!ZEND_FCC_INITIALIZED(ch->handlers.progress)) {
616616
return rval;
@@ -651,7 +651,7 @@ static int curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, cu
651651

652652
#if PHP_CURL_DEBUG
653653
fprintf(stderr, "curl_xferinfo() called\n");
654-
fprintf(stderr, "clientp = %x, dltotal = %ld, dlnow = %ld, ultotal = %ld, ulnow = %ld\n", clientp, dltotal, dlnow, ultotal, ulnow);
654+
fprintf(stderr, "clientp = %p, dltotal = %ld, dlnow = %ld, ultotal = %ld, ulnow = %ld\n", clientp, dltotal, dlnow, ultotal, ulnow);
655655
#endif
656656
if (!ZEND_FCC_INITIALIZED(ch->handlers.xferinfo)) {
657657
return rval;
@@ -746,7 +746,7 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
746746

747747
#if PHP_CURL_DEBUG
748748
fprintf(stderr, "curl_ssh_hostkeyfunction() called\n");
749-
fprintf(stderr, "clientp = %x, keytype = %d, key = %s, keylen = %zu\n", clientp, keytype, key, keylen);
749+
fprintf(stderr, "clientp = %p, keytype = %d, key = %s, keylen = %zu\n", clientp, keytype, key, keylen);
750750
#endif
751751

752752
zval args[4];
@@ -2801,7 +2801,7 @@ static void curl_free_obj(zend_object *object)
28012801
php_curl *ch = curl_from_obj(object);
28022802

28032803
#if PHP_CURL_DEBUG
2804-
fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
2804+
fprintf(stderr, "DTOR CALLED, ch = %p\n", (void *) ch);
28052805
#endif
28062806

28072807
if (!ch->cp) {

0 commit comments

Comments
 (0)