From d696ee00eec865747daedfaeeb1a880cf7d9a65c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 30 Jun 2021 12:56:22 +0200 Subject: [PATCH] lib: use %u instead of %ld for port number printf Follow-up to 764c6bd3bf which changed the type of some port number fields. Detected by Coverity (CID 1486624) etc. Closes #7325 --- lib/connect.c | 2 +- lib/url.c | 2 +- lib/urlapi.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/connect.c b/lib/connect.c index 18d3d84f5..1875334d6 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -1038,7 +1038,7 @@ CURLcode Curl_is_connected(struct Curl_easy *data, else hostname = conn->host.name; - failf(data, "Failed to connect to %s port %ld after %ld ms: %s", + failf(data, "Failed to connect to %s port %u after %ld ms: %s", hostname, conn->port, Curl_timediff(now, data->progress.t_startsingle), Curl_strerror(error, buffer, sizeof(buffer))); diff --git a/lib/url.c b/lib/url.c index a8208d749..405499aff 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1521,7 +1521,7 @@ void Curl_verboseconnect(struct Curl_easy *data, struct connectdata *conn) { if(data->set.verbose) - infof(data, "Connected to %s (%s) port %ld (#%ld)\n", + infof(data, "Connected to %s (%s) port %u (#%ld)\n", #ifndef CURL_DISABLE_PROXY conn->bits.socksproxy ? conn->socks_proxy.host.dispname : conn->bits.httpproxy ? conn->http_proxy.host.dispname : diff --git a/lib/urlapi.c b/lib/urlapi.c index d6d92cf77..905c499d9 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -1155,7 +1155,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what, const struct Curl_handler *h = Curl_builtin_scheme(u->scheme); if(h) { - msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport); + msnprintf(portbuf, sizeof(portbuf), "%u", h->defport); ptr = portbuf; } } @@ -1214,7 +1214,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what, /* there's no stored port number, but asked to deliver a default one for the scheme */ if(h) { - msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport); + msnprintf(portbuf, sizeof(portbuf), "%u", h->defport); port = portbuf; } }