]> granicus.if.org Git - curl/commitdiff
lib1509.c: fix compiler warnings
authorYang Tse <yangsita@gmail.com>
Thu, 4 Apr 2013 14:20:27 +0000 (16:20 +0200)
committerYang Tse <yangsita@gmail.com>
Thu, 4 Apr 2013 14:31:27 +0000 (16:31 +0200)
tests/libtest/lib1509.c

index 5087363d79f152ca6a8396c1b0b5ad41a3a48eee..3c86a36b2ec9bb4ff1d134d002f3e54bf5dc9212 100644 (file)
@@ -25,8 +25,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define VERBOSE 0
-
 size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream);
 size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream);
 
@@ -34,12 +32,14 @@ long realHeaderSize = 0;
 
 int test(char *URL)
 {
-  CURL *curl;
   long headerSize;
-  CURLcode res=CURLE_OK;
+  CURLcode code;
+  CURL *curl = NULL;
+  int res = 0;
+
+  global_init(CURL_GLOBAL_ALL);
 
-  curl_global_init(CURL_GLOBAL_ALL);
-  curl = curl_easy_init();
+  easy_init(curl);
 
   easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
 
@@ -50,19 +50,34 @@ int test(char *URL)
   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
   easy_setopt(curl, CURLOPT_URL, URL);
   easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-  res = curl_easy_perform(curl);
 
-  curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize);
+  code = curl_easy_perform(curl);
+  if(CURLE_OK != code) {
+    fprintf(stderr, "%s:%d curl_easy_perform() failed, "
+            "with code %d (%s)\n",
+            __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
+    res = TEST_ERR_MAJOR_BAD;
+    goto test_cleanup;
+  }
+
+  code = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize);
+  if(CURLE_OK != code) {
+    fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
+            "with code %d (%s)\n",
+            __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
+    res = TEST_ERR_MAJOR_BAD;
+    goto test_cleanup;
+  }
+
   printf("header length is ........: %lu\n", headerSize);
   printf("header length should be..: %lu\n", realHeaderSize);
 
 test_cleanup:
 
-  /* undocumented cleanup sequence - type UA */
-
   curl_easy_cleanup(curl);
   curl_global_cleanup();
-  return (int)res;
+
+  return res;
 }
 
 size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream)