mirror of
https://github.com/curl/curl.git
synced 2026-08-24 16:23:34 +03:00
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:
parent
1086f513b8
commit
5c61e16869
5 changed files with 5 additions and 5 deletions
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue