docs: make 5 example snippets compile cleanly with clang

verify-examples.pl invokes 'gcc', which on macOS is clang. With
-Wall -Wextra... -Werror -pedantic, clang rejects two patterns that
GNU gcc accepts:

- passing a char * to %p without a cast (-Wformat-pedantic): the C
  standard says %p expects void *, so cast explicitly in the
  CURLOPT_PROGRESSDATA, CURLOPT_PROGRESSFUNCTION, CURLOPT_XFERINFODATA
  and CURLOPT_XFERINFOFUNCTION examples

- returning CURLcode result from main() when curl_easy_init() returned
  NULL leaves it uninitialized (-Wsometimes-uninitialized) in the
  CURLINFO_TLS_SSL_PTR example: initialize it to CURLE_OK like other
  man pages already do

Closes #22638
This commit is contained in:
zaveshaa 2026-08-22 15:01:09 +03:00 committed by Daniel Stenberg
parent 1086f513b8
commit 5c61e16869
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 5 additions and 5 deletions

View file

@ -142,7 +142,7 @@ static size_t wf(char *ptr, size_t size, size_t nmemb, void *stream)
int main(int argc, char *argv[])
{
CURLcode result;
CURLcode result = CURLE_OK;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

View file

@ -50,7 +50,7 @@ static int progress_callback(void *clientp,
double ulnow)
{
struct progress *memory = clientp;
printf("private: %p\n", memory->private);
printf("private: %p\n", (void *)memory->private);
/* use the values */

View file

@ -96,7 +96,7 @@ static int progress_callback(void *clientp,
double ulnow)
{
struct progress *memory = clientp;
printf("private: %p\n", memory->private);
printf("private: %p\n", (void *)memory->private);
/* use the values */

View file

@ -53,7 +53,7 @@ static int progress_cb(void *clientp,
curl_off_t ulnow)
{
struct progress *memory = clientp;
printf("private ptr: %p\n", memory->private);
printf("private ptr: %p\n", (void *)memory->private);
/* use the values */
return 0; /* all is good */

View file

@ -92,7 +92,7 @@ static int xferinfo_callback(void *clientp,
curl_off_t ulnow)
{
struct progress *memory = clientp;
printf("my ptr: %p\n", memory->private);
printf("my ptr: %p\n", (void *)memory->private);
/* use the values */