1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 09:08:49 -05:00

examples: remove unused variables

Fixes Codacy/CppCheck warnings.

Closes
This commit is contained in:
Marcel Raad 2019-05-20 11:50:23 +02:00
parent 528b284e4b
commit b069815a7a
No known key found for this signature in database
GPG Key ID: 33C416EFAE4D6F02
12 changed files with 26 additions and 35 deletions

View File

@ -86,7 +86,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
BIO *cbio = BIO_new_mem_buf(mypem, sizeof(mypem)); BIO *cbio = BIO_new_mem_buf(mypem, sizeof(mypem));
X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
X509_INFO *itmp; X509_INFO *itmp;
int i, count = 0; int i;
STACK_OF(X509_INFO) *inf; STACK_OF(X509_INFO) *inf;
(void)curl; (void)curl;
(void)parm; (void)parm;
@ -106,11 +106,9 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
itmp = sk_X509_INFO_value(inf, i); itmp = sk_X509_INFO_value(inf, i);
if(itmp->x509) { if(itmp->x509) {
X509_STORE_add_cert(cts, itmp->x509); X509_STORE_add_cert(cts, itmp->x509);
count++;
} }
if(itmp->crl) { if(itmp->crl) {
X509_STORE_add_crl(cts, itmp->crl); X509_STORE_add_crl(cts, itmp->crl);
count++;
} }
} }

View File

@ -45,7 +45,6 @@ int my_progress_func(GtkWidget *bar,
void *my_thread(void *ptr) void *my_thread(void *ptr)
{ {
CURL *curl; CURL *curl;
CURLcode res;
FILE *outfile; FILE *outfile;
gchar *url = ptr; gchar *url = ptr;
@ -62,7 +61,7 @@ void *my_thread(void *ptr)
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar);
res = curl_easy_perform(curl); curl_easy_perform(curl);
fclose(outfile); fclose(outfile);
/* always cleanup */ /* always cleanup */

View File

@ -544,7 +544,7 @@ int main(int argc, char **argv)
BIO_printf(p.errorbio, "%d %s %d\n", __LINE__, "curl_easy_perform", BIO_printf(p.errorbio, "%d %s %d\n", __LINE__, "curl_easy_perform",
res = curl_easy_perform(p.curl)); res = curl_easy_perform(p.curl));
{ {
int result = curl_easy_getinfo(p.curl, CURLINFO_CONTENT_TYPE, &response); curl_easy_getinfo(p.curl, CURLINFO_CONTENT_TYPE, &response);
if(mimetypeaccept && p.verbose) { if(mimetypeaccept && p.verbose) {
if(!strcmp(mimetypeaccept, response)) if(!strcmp(mimetypeaccept, response))
BIO_printf(p.errorbio, "the response has a correct mimetype : %s\n", BIO_printf(p.errorbio, "the response has a correct mimetype : %s\n",

View File

@ -148,7 +148,6 @@ static void timer_cb(GlobalInfo* g, int revents);
static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g) static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{ {
struct itimerspec its; struct itimerspec its;
CURLMcode rc;
fprintf(MSG_OUT, "multi_timer_cb: Setting timeout to %ld ms\n", timeout_ms); fprintf(MSG_OUT, "multi_timer_cb: Setting timeout to %ld ms\n", timeout_ms);
@ -341,7 +340,8 @@ static size_t write_cb(void *ptr _Unused, size_t size, size_t nmemb,
void *data) void *data)
{ {
size_t realsize = size * nmemb; size_t realsize = size * nmemb;
ConnInfo *conn _Unused = (ConnInfo*) data; (void)_Unused;
(void)data;
return realsize; return realsize;
} }

View File

@ -421,7 +421,6 @@ static int init_fifo(GlobalInfo *g)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
GlobalInfo g; GlobalInfo g;
CURLMcode rc;
(void)argc; (void)argc;
(void)argv; (void)argv;

View File

@ -411,7 +411,6 @@ int init_fifo(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
GlobalInfo *g; GlobalInfo *g;
CURLMcode rc;
GMainLoop*gmain; GMainLoop*gmain;
int fd; int fd;
GIOChannel* ch; GIOChannel* ch;

View File

@ -307,7 +307,8 @@ static size_t write_cb(void *ptr _Unused, size_t size, size_t nmemb,
void *data) void *data)
{ {
size_t realsize = size * nmemb; size_t realsize = size * nmemb;
ConnInfo *conn _Unused = (ConnInfo*) data; (void)_Unused;
(void)data;
return realsize; return realsize;
} }

View File

@ -69,13 +69,12 @@ int main(int argc, char **argv)
{ {
pthread_t tid[NUMT]; pthread_t tid[NUMT];
int i; int i;
int error;
/* Must initialize libcurl before any threads are started */ /* Must initialize libcurl before any threads are started */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
for(i = 0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_create(&tid[i], int error = pthread_create(&tid[i],
NULL, /* default attributes please */ NULL, /* default attributes please */
pull_one_url, pull_one_url,
(void *)urls[i]); (void *)urls[i]);
@ -87,7 +86,7 @@ int main(int argc, char **argv)
/* now wait for all threads to terminate */ /* now wait for all threads to terminate */
for(i = 0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_join(tid[i], NULL); pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }

View File

@ -90,7 +90,6 @@ static CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length)
int main(void) int main(void)
{ {
CURL *curl; CURL *curl;
CURLcode res;
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if(curl) {
@ -104,7 +103,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION, curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION,
my_conv_from_utf8_to_ebcdic); my_conv_from_utf8_to_ebcdic);
res = curl_easy_perform(curl); curl_easy_perform(curl);
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);

View File

@ -68,7 +68,6 @@ size_t write_file(void *ptr, size_t size, size_t nmemb, FILE *stream)
void *pull_one_url(void *NaN) void *pull_one_url(void *NaN)
{ {
CURL *curl; CURL *curl;
CURLcode res;
gchar *http; gchar *http;
FILE *outfile; FILE *outfile;
@ -98,7 +97,7 @@ void *pull_one_url(void *NaN)
j++; /* critical line */ j++; /* critical line */
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);
res = curl_easy_perform(curl); curl_easy_perform(curl);
fclose(outfile); fclose(outfile);
printf("fclose\n"); printf("fclose\n");
@ -131,11 +130,10 @@ void *create_thread(void *progress_bar)
{ {
pthread_t tid[NUMT]; pthread_t tid[NUMT];
int i; int i;
int error;
/* Make sure I don't create more threads than urls. */ /* Make sure I don't create more threads than urls. */
for(i = 0; i < NUMT && i < num_urls ; i++) { for(i = 0; i < NUMT && i < num_urls ; i++) {
error = pthread_create(&tid[i], int error = pthread_create(&tid[i],
NULL, /* default attributes please */ NULL, /* default attributes please */
pull_one_url, pull_one_url,
NULL); NULL);
@ -147,7 +145,7 @@ void *create_thread(void *progress_bar)
/* Wait for all threads to terminate. */ /* Wait for all threads to terminate. */
for(i = 0; i < NUMT && i < num_urls; i++) { for(i = 0; i < NUMT && i < num_urls; i++) {
error = pthread_join(tid[i], NULL); pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }

View File

@ -117,7 +117,6 @@ int main(void)
{ {
pthread_t tid[NUM_THREADS]; pthread_t tid[NUM_THREADS];
int i; int i;
int error;
CURLSH *share; CURLSH *share;
struct initurl url[NUM_THREADS]; struct initurl url[NUM_THREADS];
@ -132,6 +131,7 @@ int main(void)
init_locks(); init_locks();
for(i = 0; i< NUM_THREADS; i++) { for(i = 0; i< NUM_THREADS; i++) {
int error;
url[i].url = URL; url[i].url = URL;
url[i].share = share; url[i].share = share;
url[i].threadno = i; url[i].threadno = i;
@ -144,7 +144,7 @@ int main(void)
/* now wait for all threads to terminate */ /* now wait for all threads to terminate */
for(i = 0; i< NUM_THREADS; i++) { for(i = 0; i< NUM_THREADS; i++) {
error = pthread_join(tid[i], NULL); pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }

View File

@ -135,7 +135,6 @@ int main(int argc, char **argv)
{ {
pthread_t tid[NUMT]; pthread_t tid[NUMT];
int i; int i;
int error;
(void)argc; /* we don't use any arguments in this example */ (void)argc; /* we don't use any arguments in this example */
(void)argv; (void)argv;
@ -145,7 +144,7 @@ int main(int argc, char **argv)
init_locks(); init_locks();
for(i = 0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_create(&tid[i], int error = pthread_create(&tid[i],
NULL, /* default attributes please */ NULL, /* default attributes please */
pull_one_url, pull_one_url,
(void *)urls[i]); (void *)urls[i]);
@ -157,7 +156,7 @@ int main(int argc, char **argv)
/* now wait for all threads to terminate */ /* now wait for all threads to terminate */
for(i = 0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_join(tid[i], NULL); pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }