]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: fix some type mismatches and remove unneeded typecasts
authorRose <83477269+AtariDreams@users.noreply.github.com>
Fri, 28 Oct 2022 16:32:09 +0000 (12:32 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 8 Nov 2022 08:11:01 +0000 (03:11 -0500)
Many of these castings are unneeded if we change the variables to work
better with each other.

Ref: https://github.com/curl/curl/pull/9823

Closes https://github.com/curl/curl/pull/9835

23 files changed:
lib/connect.c
lib/cookie.c
lib/curl_fnmatch.c
lib/escape.c
lib/file.c
lib/formdata.c
lib/ftp.c
lib/ftplistparser.c
lib/http.c
lib/ldap.c
lib/mime.c
lib/setopt.c
lib/socks.c
lib/telnet.c
lib/vauth/digest.c
lib/vtls/gskit.c
lib/vtls/openssl.c
packages/OS400/ccsidcurl.c
packages/OS400/os400sys.c
packages/vms/curl_crtl_init.c
packages/vms/report_openssl_version.c
tests/libtest/lib1542.c
tests/libtest/lib1568.c

index ac007c61b0c0713615f055d04000d47f73b9701e..0d2414edc3e16933cab46cba7b5261bca295fe14 100644 (file)
@@ -398,18 +398,23 @@ static CURLcode bindlocal(struct Curl_easy *data,
 #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
         char *scope_ptr = strchr(myhost, '%');
         if(scope_ptr)
-          *(scope_ptr++) = 0;
+          *(scope_ptr++) = '\0';
 #endif
         if(Curl_inet_pton(AF_INET6, myhost, &si6->sin6_addr) > 0) {
           si6->sin6_family = AF_INET6;
           si6->sin6_port = htons(port);
 #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
-          if(scope_ptr)
+          if(scope_ptr) {
             /* The "myhost" string either comes from Curl_if2ip or from
                Curl_printable_address. The latter returns only numeric scope
                IDs and the former returns none at all.  So the scope ID, if
                present, is known to be numeric */
-            si6->sin6_scope_id = atoi(scope_ptr);
+            unsigned long scope_id = strtoul(scope_ptr, NULL, 10);
+            if(scope_id > UINT_MAX)
+              return CURLE_UNSUPPORTED_PROTOCOL;
+
+            si6->sin6_scope_id = (unsigned int)scope_id;
+          }
 #endif
         }
         sizeof_sa = sizeof(struct sockaddr_in6);
@@ -866,7 +871,7 @@ CURLcode Curl_is_connected(struct Curl_easy *data,
   int error = 0;
   struct curltime now;
   int rc = 0;
-  unsigned int i;
+  int i;
 
   DEBUGASSERT(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET);
 
@@ -1207,7 +1212,7 @@ static CURLcode singleipconnect(struct Curl_easy *data,
     return result;
 
   /* store remote address and port used in this connection attempt */
-  if(!Curl_addr2string((struct sockaddr*)&addr.sa_addr, addr.addrlen,
+  if(!Curl_addr2string(&addr.sa_addr, addr.addrlen,
                        ipaddress, &port)) {
     /* malformed address or bug in inet_ntop, try next address */
     failf(data, "sa_addr inet_ntop() failed with errno %d: %s",
@@ -1262,7 +1267,7 @@ static CURLcode singleipconnect(struct Curl_easy *data,
 #endif
     ) {
     result = bindlocal(data, sockfd, addr.family,
-                       Curl_ipv6_scope((struct sockaddr*)&addr.sa_addr));
+                       Curl_ipv6_scope(&addr.sa_addr));
     if(result) {
       Curl_closesocket(data, conn, sockfd); /* close socket and bail out */
       if(result == CURLE_UNSUPPORTED_PROTOCOL) {
index f3f3e4cf7a54286ed48a42d48235e1d58b66c2be..4d81344ba79045af41d37038853817abc4cb94f3 100644 (file)
@@ -300,12 +300,11 @@ static char *sanitize_cookie_path(const char *cookie_path)
   /* some stupid site sends path attribute with '"'. */
   len = strlen(new_path);
   if(new_path[0] == '\"') {
-    memmove((void *)new_path, (const void *)(new_path + 1), len);
+    memmove(new_path, new_path + 1, len);
     len--;
   }
   if(len && (new_path[len - 1] == '\"')) {
-    new_path[len - 1] = 0x0;
-    len--;
+    new_path[--len] = 0x0;
   }
 
   /* RFC6265 5.2.4 The Path Attribute */
index 0dd1eb5ef58b8672642247bd91c9c4aafa26277f..b8a85a96ec2f0e3085d0a9e60567706574de9c56 100644 (file)
@@ -76,9 +76,9 @@ static int parsekeyword(unsigned char **pattern, unsigned char *charset)
   parsekey_state state = CURLFNM_PKW_INIT;
 #define KEYLEN 10
   char keyword[KEYLEN] = { 0 };
-  int found = FALSE;
   int i;
   unsigned char *p = *pattern;
+  bool found = FALSE;
   for(i = 0; !found; i++) {
     char c = *p++;
     if(i >= KEYLEN)
@@ -368,14 +368,13 @@ int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
  */
 int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
 {
-  int rc;
   (void)ptr; /* the argument is specified by the curl_fnmatch_callback
                 prototype, but not used by Curl_fnmatch() */
   if(!pattern || !string) {
     return CURL_FNMATCH_FAIL;
   }
-  rc = fnmatch(pattern, string, 0);
-  switch(rc) {
+
+  switch(fnmatch(pattern, string, 0)) {
   case 0:
     return CURL_FNMATCH_MATCH;
   case FNM_NOMATCH:
index da7e5524f724991b9e8c76fb743910aca98e72ed..ed59838bd1b4724d2c3556ffcd6bb5cd2be90211 100644 (file)
@@ -202,7 +202,7 @@ char *curl_easy_unescape(struct Curl_easy *data, const char *string,
   char *str = NULL;
   (void)data;
   if(length >= 0) {
-    size_t inputlen = length;
+    size_t inputlen = (size_t)length;
     size_t outputlen;
     CURLcode res = Curl_urldecode(string, inputlen, &str, &outputlen,
                                   REJECT_NADA);
index 4ed707883a451887db046d58022566e682931925..892d2519970707137e006f9ac3e0680cf6da6566 100644 (file)
@@ -329,7 +329,7 @@ static CURLcode file_upload(struct Curl_easy *data)
 
   while(!result) {
     size_t nread;
-    size_t nwrite;
+    ssize_t nwrite;
     size_t readcount;
     result = Curl_fillreadbuffer(data, data->set.buffer_size, &readcount);
     if(result)
@@ -358,7 +358,7 @@ static CURLcode file_upload(struct Curl_easy *data)
 
     /* write the data to the target */
     nwrite = write(fd, buf2, nread);
-    if(nwrite != nread) {
+    if((size_t)nwrite != nread) {
       result = CURLE_SEND_ERROR;
       break;
     }
index c8442637595bf2680af3f684df90468b5bcd82a9..058e06f1f4f06b58eec8e719ad7f242d6e075057 100644 (file)
@@ -135,15 +135,13 @@ static struct FormInfo *AddFormInfo(char *value,
 {
   struct FormInfo *form_info;
   form_info = calloc(1, sizeof(struct FormInfo));
-  if(form_info) {
-    if(value)
-      form_info->value = value;
-    if(contenttype)
-      form_info->contenttype = contenttype;
-    form_info->flags = HTTPPOST_FILENAME;
-  }
-  else
+  if(!form_info)
     return NULL;
+  if(value)
+    form_info->value = value;
+  if(contenttype)
+    form_info->contenttype = contenttype;
+  form_info->flags = HTTPPOST_FILENAME;
 
   if(parent_form_info) {
     /* now, point our 'more' to the original 'more' */
index 7d91caad879ba4b2b32bcb09f32587f3db5da6a5..4d3bcc387dca637f5a921710ea3b3976fe2b28f5 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1174,7 +1174,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
   /* get the name again after the bind() so that we can extract the
      port number it uses now */
   sslen = sizeof(ss);
-  if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) {
+  if(getsockname(portsock, sa, &sslen)) {
     failf(data, "getsockname() failed: %s",
           Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
     Curl_closesocket(data, conn, portsock);
@@ -1950,7 +1950,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
      */
     const char * const host_name = conn->bits.socksproxy ?
       conn->socks_proxy.host.name : conn->http_proxy.host.name;
-    rc = Curl_resolv(data, host_name, (int)conn->port, FALSE, &addr);
+    rc = Curl_resolv(data, host_name, conn->port, FALSE, &addr);
     if(rc == CURLRESOLV_PENDING)
       /* BLOCKING, ignores the return code but 'addr' will be NULL in
          case of failure */
@@ -4167,7 +4167,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
         /* get path before last slash, except for / */
         size_t dirlen = slashPos - rawPath;
         if(dirlen == 0)
-            dirlen++;
+          dirlen = 1;
 
         ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
         if(!ftpc->dirs) {
@@ -4194,13 +4194,14 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
       /* current position: begin of next path component */
       const char *curPos = rawPath;
 
-      int dirAlloc = 0; /* number of entries allocated for the 'dirs' array */
+      /* number of entries allocated for the 'dirs' array */
+      size_t dirAlloc = 0;
       const char *str = rawPath;
       for(; *str != 0; ++str)
         if (*str == '/')
           ++dirAlloc;
 
-      if(dirAlloc > 0) {
+      if(dirAlloc) {
         ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0]));
         if(!ftpc->dirs) {
           free(rawPath);
@@ -4230,7 +4231,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
           curPos = slashPos + 1;
         }
       }
-      DEBUGASSERT(ftpc->dirdepth <= dirAlloc);
+      DEBUGASSERT((size_t)ftpc->dirdepth <= dirAlloc);
       fileName = curPos; /* the rest is the file name (or empty) */
     }
     break;
index 40f5f3f1897f0472f512999d01d80de33f7c7de1..eded5691cb2574a3ba76c80597262b1c8252bfa6 100644 (file)
@@ -205,9 +205,9 @@ CURLcode Curl_ftp_parselist_geterror(struct ftp_parselist_data *pl_data)
 
 #define FTP_LP_MALFORMATED_PERM 0x01000000
 
-static int ftp_pl_get_permission(const char *str)
+static unsigned int ftp_pl_get_permission(const char *str)
 {
-  int permissions = 0;
+  unsigned int permissions = 0;
   /* USER */
   if(str[0] == 'r')
     permissions |= 1 << 8;
index f70405895236d5ba3bd9f70ef1ce67cc7811fbad..6037b1737eae7a578ab638c273f2f39a6fb163d8 100644 (file)
@@ -650,7 +650,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
   if(!data->set.str[STRING_BEARER])
     authmask &= (unsigned long)~CURLAUTH_BEARER;
 
-  if(100 <= data->req.httpcode && 199 >= data->req.httpcode)
+  if(100 <= data->req.httpcode && data->req.httpcode <= 199)
     /* this is a transient response code, ignore */
     return CURLE_OK;
 
@@ -3751,7 +3751,7 @@ CURLcode Curl_http_header(struct Curl_easy *data, struct connectdata *conn,
     result = Curl_altsvc_parse(data, data->asi,
                                headp + strlen("Alt-Svc:"),
                                id, conn->host.name,
-                               curlx_uitous(conn->remote_port));
+                               curlx_uitous((unsigned int)conn->remote_port));
     if(result)
       return result;
   }
index b073349042b179ebc21663ceee5a1b5e45a78615..92006d6936469cc1516832b5c9ba54080f36ed3b 100644 (file)
@@ -565,8 +565,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
         goto quit;
       }
 
-      result = Curl_client_write(data, CLIENTWRITE_BODY, (char *) name,
-                                 name_len);
+      result = Curl_client_write(data, CLIENTWRITE_BODY, name, name_len);
       if(result) {
         FREE_ON_WINLDAP(name);
         ldap_memfree(dn);
@@ -622,8 +621,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
             goto quit;
           }
 
-          result = Curl_client_write(data, CLIENTWRITE_BODY,
-                                     (char *) attr, attr_len);
+          result = Curl_client_write(data, CLIENTWRITE_BODY, attr, attr_len);
           if(result) {
             ldap_value_free_len(vals);
             FREE_ON_WINLDAP(attr);
@@ -648,7 +646,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
           dlsize += attr_len + 3;
 
           if((attr_len > 7) &&
-             (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) {
+             (strcmp(";binary", attr + (attr_len - 7)) == 0)) {
             /* Binary attribute, encode to base64. */
             result = Curl_base64_encode(vals[i]->bv_val, vals[i]->bv_len,
                                         &val_b64, &val_b64_sz);
index 042141fc80b19598212d1f1f3ac8bacd378a02f7..117c66f4dd41bd03d37e86199af30938214cca4e 100644 (file)
@@ -1636,7 +1636,7 @@ static size_t slist_size(struct curl_slist *s,
 static curl_off_t multipart_size(curl_mime *mime)
 {
   curl_off_t size;
-  size_t boundarysize;
+  curl_off_t boundarysize;
   curl_mimepart *part;
 
   if(!mime)
index 0ff9f904347c46ce12849b5add5be41e16c907ed..d32fdac0d93f85f24f2dc7c944dd091adfa2e5b7 100644 (file)
@@ -2205,7 +2205,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
     else if(arg < READBUFFER_MIN)
       arg = READBUFFER_MIN;
 
-    data->set.buffer_size = (int)arg;
+    data->set.buffer_size = (unsigned int)arg;
     break;
 
   case CURLOPT_UPLOAD_BUFFERSIZE:
index 52c29880a67c17669c0666f97b535265f5ab82fb..52eac0990edfc00195e6ecc380d79ce50e415443 100644 (file)
@@ -566,7 +566,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
     /* write the number of authentication methods */
     socksreq[1] = (unsigned char) (idx - 2);
 
-    result = Curl_write_plain(data, sockfd, (char *)socksreq, idx, &written);
+    result = Curl_write_plain(data, sockfd, socksreq, idx, &written);
     if(result && (CURLE_AGAIN != result)) {
       failf(data, "Unable to send initial SOCKS5 request.");
       return CURLPX_SEND_CONNECT;
@@ -712,7 +712,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
   }
     /* FALLTHROUGH */
   case CONNECT_AUTH_SEND:
-    result = Curl_write_plain(data, sockfd, (char *)sx->outp,
+    result = Curl_write_plain(data, sockfd, sx->outp,
                               sx->outstanding, &written);
     if(result && (CURLE_AGAIN != result)) {
       failf(data, "Failed to send SOCKS5 sub-negotiation request.");
index 77258736a8fdae327dd8bd722346180d84ff2450..34f1a3419f2f993c7366479795a578039c7389d6 100644 (file)
@@ -1200,7 +1200,7 @@ static CURLcode send_telnet_data(struct Curl_easy *data,
 
     j = 0;
     for(i = 0; i < nread; i++) {
-      outbuf[j++] = buffer[i];
+      outbuf[j++] = (unsigned char)buffer[i];
       if((unsigned char)buffer[i] == CURL_IAC)
         outbuf[j++] = CURL_IAC;
     }
index 462a96fd6671b9fa219691df4b6157720162de2c..c81ce109586a0e2469f3c48c80e8f86a6986bab6 100644 (file)
@@ -186,7 +186,7 @@ static char *auth_digest_string_quoted(const char *source)
       }
       *d++ = *s++;
     }
-    *d = 0;
+    *d = '\0';
   }
 
   return dest;
index 4ee4edea6c49e2d40e5e8bb6472786fce8db6736..52d2eaec3d14b34af78a4edb9676ed5261b713fa 100644 (file)
@@ -324,7 +324,7 @@ static CURLcode set_ciphers(struct Curl_easy *data,
      GSKit tokens are always shorter than their cipher names, allocated buffers
      will always be large enough to accommodate the result. */
   l = strlen(cipherlist) + 1;
-  memset((char *) ciphers, 0, sizeof(ciphers));
+  memset(ciphers, 0, sizeof(ciphers));
   for(i = 0; i < CURL_GSKPROTO_LAST; i++) {
     ciphers[i].buf = malloc(l);
     if(!ciphers[i].buf) {
index dd9d24a7ccb55813af622dad373b7f9790659f52..29ff13f1c60627eef057422692ad5ea06f87399a 100644 (file)
@@ -1827,7 +1827,7 @@ static int ossl_shutdown(struct Curl_easy *data,
   char buf[256]; /* We will use this for the OpenSSL error buffer, so it has
                     to be at least 256 bytes long. */
   unsigned long sslerror;
-  ssize_t nread;
+  int nread;
   int buffsize;
   int err;
   bool done = FALSE;
@@ -1856,8 +1856,8 @@ static int ossl_shutdown(struct Curl_easy *data,
 
         /* Something to read, let's do it and hope that it is the close
            notify alert from the server */
-        nread = (ssize_t)SSL_read(backend->handle, buf, buffsize);
-        err = SSL_get_error(backend->handle, (int)nread);
+        nread = SSL_read(backend->handle, buf, buffsize);
+        err = SSL_get_error(backend->handle, nread);
 
         switch(err) {
         case SSL_ERROR_NONE: /* this is not an error */
index da696ca2b9e38b754986f9691efd4f4278e43fb8..b7ef28caed021732506003f822fd925b8a718541 100644 (file)
@@ -472,7 +472,7 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
   memcpy((char *) id, (char *) p, sizeof(*p));
 
   if(id->protocols) {
-    int i = nproto * sizeof(id->protocols[0]);
+    i = nproto * sizeof(id->protocols[0]);
 
     id->protocols = (const char * const *) cp;
     memcpy(cp, (char *) p->protocols, i);
@@ -487,7 +487,7 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
 
   for(i = 0; i < sizeof(charfields) / sizeof(charfields[0]); i++) {
     cpp = (const char **) ((char *) p + charfields[i]);
-    if (*cpp && convert_version_info_string(cpp, &cp, &n, ccsid))
+    if(*cpp && convert_version_info_string(cpp, &cp, &n, ccsid))
       return (curl_version_info_data *) NULL;
   }
 
index 4219351ba1937c8baec55f8b2fe25e9de583a9a1..2cedc4fd73c780b44a6a77615e7f45d2ec12a02d 100644 (file)
@@ -745,7 +745,7 @@ OM_uint32
 Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name,
                        gss_OID in_name_type, gss_name_t *out_name)
 {
-  int rc;
+  OM_uint32 rc;
   unsigned int i;
   gss_buffer_desc in;
 
@@ -859,7 +859,7 @@ Curl_gss_delete_sec_context_a(OM_uint32 *minor_status,
                               gss_ctx_id_t *context_handle,
                               gss_buffer_t output_token)
 {
-  int rc;
+  OM_uint32 rc;
 
   rc = gss_delete_sec_context(minor_status, context_handle, output_token);
 
@@ -886,7 +886,7 @@ Curl_gss_delete_sec_context_a(OM_uint32 *minor_status,
 void *
 Curl_ldap_init_a(char *host, int port)
 {
-  unsigned int i;
+  size_t i;
   char *ehost;
   void *result;
 
index 8b5da62d5283d6310a52781fdeedfd560f3efb52..eedfa22a637b6e4117448e34725a21efdbb44fb7 100644 (file)
@@ -130,7 +130,7 @@ static int sys_trnlnm
 
     status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);
 
-    if ($VMS_STATUS_SUCCESS(status)) {
+    if($VMS_STATUS_SUCCESS(status)) {
 
          /* Null terminate and return the string */
         /*--------------------------------------*/
@@ -192,7 +192,7 @@ static void set_feature_default(const char *name, int value)
 
     index = decc$feature_get_index(name);
 
-    if (index > 0)
+    if(index > 0)
         decc$feature_set_value (index, 0, value);
 }
 #endif
@@ -205,7 +205,7 @@ static void set_features(void)
 
     status = sys_trnlnm("GNV$UNIX_SHELL",
                         unix_shell_name, sizeof unix_shell_name -1);
-    if (!$VMS_STATUS_SUCCESS(status)) {
+    if(!$VMS_STATUS_SUCCESS(status)) {
         use_unix_settings = 0;
     }
 
@@ -249,7 +249,7 @@ static void set_features(void)
     /* Fix mv aa.bb aa  */
     set_feature_default ("DECC$RENAME_NO_INHERIT", ENABLE);
 
-    if (use_unix_settings) {
+    if(use_unix_settings) {
 
         /* POSIX requires that open files be able to be removed */
         set_feature_default ("DECC$ALLOW_REMOVE_OPEN_FILES", ENABLE);
index 493969616098d93d3779adbf26edfc57920eddb8..2f5f5278125ecd8720f1ecbdf025c5c64dff4cd3 100644 (file)
@@ -49,7 +49,7 @@ void * libptr;
 const char * (*ssl_version)(int t);
 const char * version;
 
-   if (argc < 1) {
+   if(argc < 1) {
        puts("report_openssl_version filename");
        exit(1);
    }
@@ -57,16 +57,16 @@ const char * version;
    libptr = dlopen(argv[1], 0);
 
    ssl_version = (const char * (*)(int))dlsym(libptr, "SSLeay_version");
-   if ((void *)ssl_version == NULL) {
+   if(ssl_version == NULL) {
       ssl_version = (const char * (*)(int))dlsym(libptr, "ssleay_version");
-      if ((void *)ssl_version == NULL) {
+      if(ssl_version == NULL) {
          ssl_version = (const char * (*)(int))dlsym(libptr, "SSLEAY_VERSION");
       }
    }
 
    dlclose(libptr);
 
-   if ((void *)ssl_version == NULL) {
+   if(ssl_version == NULL) {
       puts("Unable to lookup version of OpenSSL");
       exit(1);
    }
@@ -76,7 +76,7 @@ const char * version;
    puts(version);
 
    /* Was a symbol argument given? */
-   if (argc > 1) {
+   if(argc > 1) {
       int status;
       struct dsc$descriptor_s symbol_dsc;
       struct dsc$descriptor_s value_dsc;
@@ -93,7 +93,7 @@ const char * version;
       value_dsc.dsc$b_class = DSC$K_CLASS_S;
 
       status = LIB$SET_SYMBOL(&symbol_dsc, &value_dsc, &table_type);
-      if (!$VMS_STATUS_SUCCESS(status)) {
+      if(!$VMS_STATUS_SUCCESS(status)) {
          exit(status);
       }
    }
index 19c46b59b72246a5afed3eb97f6bdc6802d0084c..5f268463cec3b06e36b8a22d63a7e7f5b043e588 100644 (file)
@@ -84,5 +84,5 @@ test_cleanup:
   curl_easy_cleanup(easy);
   curl_global_cleanup();
 
-  return (int)res;
+  return res;
 }
index 7e68b5f495cc5af14a30d9d57a25af813f04c380..42204b0fd47f6ba7cf02b921023285c39838d452 100644 (file)
@@ -40,7 +40,7 @@ int test(char *URL)
   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "lib1568");
   curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
   curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
-  curl_easy_setopt(hnd, CURLOPT_PORT, (long)atoi(libtest_arg2));
+  curl_easy_setopt(hnd, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
 
   ret = curl_easy_perform(hnd);