examples: check more errors, fix cleanups, scope variables

Inspired by Joshua's report on examples.

Closes #19055
This commit is contained in:
Viktor Szakats 2025-10-13 22:57:01 +02:00
parent 61dcb56743
commit 64ed2ea196
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
42 changed files with 874 additions and 785 deletions

View file

@ -34,8 +34,7 @@
int main(void)
{
CURL *curl;
CURL *curl = NULL;
CURLU *urlp;
CURLUcode uc;
@ -43,9 +42,6 @@ int main(void)
if(res)
return (int)res;
/* get a curl handle */
curl = curl_easy_init();
/* init Curl URL */
urlp = curl_url();
uc = curl_url_set(urlp, CURLUPART_URL,
@ -56,6 +52,8 @@ int main(void)
goto cleanup;
}
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* set urlp to use as working URL */
curl_easy_setopt(curl, CURLOPT_CURLU, urlp);
@ -69,8 +67,6 @@ int main(void)
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
goto cleanup;
}
cleanup: