]> granicus.if.org Git - curl/commitdiff
Fixed some minor type mismatches and missing consts mainly found by splint.
authorDan Fandrich <dan@coneharvesters.com>
Mon, 27 Aug 2007 06:31:28 +0000 (06:31 +0000)
committerDan Fandrich <dan@coneharvesters.com>
Mon, 27 Aug 2007 06:31:28 +0000 (06:31 +0000)
17 files changed:
lib/formdata.c
lib/ftp.c
lib/http.c
lib/http.h
lib/http_digest.c
lib/http_digest.h
lib/http_negotiate.c
lib/http_negotiate.h
lib/http_ntlm.c
lib/http_ntlm.h
lib/socks.c
lib/socks.h
lib/sslgen.c
lib/sslgen.h
lib/ssluse.c
lib/transfer.c
lib/transfer.h

index e4d0922bb97bdde89a64423c72a69a39432b10d4..64414f57bc18bde29ecf42b2183cb861215f0cb6 100644 (file)
@@ -481,7 +481,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
         return_value = CURL_FORMADD_OPTION_TWICE;
       else
         current_form->namelength =
-          array_state?(long)array_value:(long)va_arg(params, long);
+          array_state?(size_t)array_value:(size_t)va_arg(params, long);
       break;
 
       /*
@@ -506,7 +506,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
         return_value = CURL_FORMADD_OPTION_TWICE;
       else
         current_form->contentslength =
-          array_state?(long)array_value:va_arg(params, long);
+          array_state?(size_t)array_value:(size_t)va_arg(params, long);
       break;
 
       /* Get contents from a given file name */
@@ -514,7 +514,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
       if (current_form->flags != 0)
         return_value = CURL_FORMADD_OPTION_TWICE;
       else {
-        char *filename = array_state?
+        const char *filename = array_state?
           array_value:va_arg(params, char *);
         if (filename) {
           current_form->value = strdup(filename);
@@ -533,7 +533,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
       /* We upload a file */
     case CURLFORM_FILE:
       {
-        char *filename = array_state?array_value:
+        const char *filename = array_state?array_value:
           va_arg(params, char *);
 
         if (current_form->value) {
@@ -567,7 +567,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
 
     case CURLFORM_BUFFER:
       {
-        char *filename = array_state?array_value:
+        const char *filename = array_state?array_value:
           va_arg(params, char *);
 
         if (current_form->value) {
@@ -615,12 +615,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
         return_value = CURL_FORMADD_OPTION_TWICE;
       else
         current_form->bufferlength =
-          array_state?(long)array_value:va_arg(params, long);
+          array_state?(size_t)array_value:(size_t)va_arg(params, long);
       break;
 
     case CURLFORM_CONTENTTYPE:
       {
-        char *contenttype =
+        const char *contenttype =
           array_state?array_value:va_arg(params, char *);
         if (current_form->contenttype) {
           if (current_form->flags & HTTPPOST_FILENAME) {
@@ -666,7 +666,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
       }
     case CURLFORM_FILENAME:
       {
-        char *filename = array_state?array_value:
+        const char *filename = array_state?array_value:
           va_arg(params, char *);
         if( current_form->showfilename )
           return_value = CURL_FORMADD_OPTION_TWICE;
@@ -1055,7 +1055,7 @@ static char *basename(char *path)
 }
 #endif
 
-static char *strippath(char *fullfile)
+static char *strippath(const char *fullfile)
 {
   char *filename;
   char *base;
index 7d00b7ccff2a8bfb4cfdf6dd127f48f7b20c354d..3bdfaff331b89155a4a8cc605c0da36ab1501846 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -374,7 +374,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
       /* we got a whole chunk of data, which can be anything from one
        * byte to a set of lines and possible just a piece of the last
        * line */
-      int i;
+      ssize_t i;
 
       data->reqdata.keep.headerbytecount += gotbytes;
 
@@ -661,7 +661,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
         /* we got a whole chunk of data, which can be anything from one
          * byte to a set of lines and possible just a piece of the last
          * line */
-        int i;
+        ssize_t i;
 
         data->reqdata.keep.headerbytecount += gotbytes;
 
@@ -3340,7 +3340,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
 {
   struct ftp_conn *ftpc = &conn->proto.ftpc;
   CURLcode result;
-  int want = ascii?'A':'I';
+  char want = ascii?'A':'I';
 
   if (ftpc->transfertype == want) {
     state(conn, newstate);
@@ -3351,7 +3351,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
   state(conn, newstate);
 
   /* keep track of our current transfer type */
-  ftpc->transfertype = (char)want;
+  ftpc->transfertype = want;
   return CURLE_OK;
 }
 
index 715031658c1b52cf2124f2e9e596a5ffc56bbbc3..2938c37cada9c835243c115c71b1e2c1c5872d77 100644 (file)
@@ -384,14 +384,14 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
  */
 static CURLcode
 Curl_http_output_auth(struct connectdata *conn,
-                      char *request,
-                      char *path,
+                      const char *request,
+                      const char *path,
                       bool proxytunnel) /* TRUE if this is the request setting
                                            up the proxy tunnel */
 {
   CURLcode result = CURLE_OK;
   struct SessionHandle *data = conn->data;
-  char *auth=NULL;
+  const char *auth=NULL;
   struct auth *authhost;
   struct auth *authproxy;
 
@@ -426,7 +426,7 @@ Curl_http_output_auth(struct connectdata *conn,
       (conn->bits.tunnel_proxy == proxytunnel)) {
 #ifdef USE_NTLM
     if(authproxy->picked == CURLAUTH_NTLM) {
-      auth=(char *)"NTLM";
+      auth="NTLM";
       result = Curl_output_ntlm(conn, TRUE);
       if(result)
         return result;
@@ -437,7 +437,7 @@ Curl_http_output_auth(struct connectdata *conn,
         /* Basic */
         if(conn->bits.proxy_user_passwd &&
            !checkheaders(data, "Proxy-authorization:")) {
-          auth=(char *)"Basic";
+          auth="Basic";
           result = Curl_output_basic(conn, TRUE);
           if(result)
             return result;
@@ -448,11 +448,11 @@ Curl_http_output_auth(struct connectdata *conn,
       }
 #ifndef CURL_DISABLE_CRYPTO_AUTH
       else if(authproxy->picked == CURLAUTH_DIGEST) {
-        auth=(char *)"Digest";
+        auth="Digest";
         result = Curl_output_digest(conn,
                                     TRUE, /* proxy */
-                                    (unsigned char *)request,
-                                    (unsigned char *)path);
+                                    (const unsigned char *)request,
+                                    (const unsigned char *)path);
         if(result)
           return result;
       }
@@ -485,7 +485,7 @@ Curl_http_output_auth(struct connectdata *conn,
       if((authhost->picked == CURLAUTH_GSSNEGOTIATE) &&
          data->state.negotiate.context &&
          !GSS_ERROR(data->state.negotiate.status)) {
-        auth=(char *)"GSS-Negotiate";
+        auth="GSS-Negotiate";
         result = Curl_output_negotiate(conn);
         if (result)
           return result;
@@ -495,7 +495,7 @@ Curl_http_output_auth(struct connectdata *conn,
 #endif
 #ifdef USE_NTLM
       if(authhost->picked == CURLAUTH_NTLM) {
-        auth=(char *)"NTLM";
+        auth="NTLM";
         result = Curl_output_ntlm(conn, FALSE);
         if(result)
           return result;
@@ -505,11 +505,11 @@ Curl_http_output_auth(struct connectdata *conn,
       {
 #ifndef CURL_DISABLE_CRYPTO_AUTH
         if(authhost->picked == CURLAUTH_DIGEST) {
-          auth=(char *)"Digest";
+          auth="Digest";
           result = Curl_output_digest(conn,
                                       FALSE, /* not a proxy */
-                                      (unsigned char *)request,
-                                      (unsigned char *)path);
+                                      (const unsigned char *)request,
+                                      (const unsigned char *)path);
           if(result)
             return result;
         } else
@@ -517,7 +517,7 @@ Curl_http_output_auth(struct connectdata *conn,
         if(authhost->picked == CURLAUTH_BASIC) {
           if(conn->bits.user_passwd &&
              !checkheaders(data, "Authorization:")) {
-            auth=(char *)"Basic";
+            auth="Basic";
             result = Curl_output_basic(conn, FALSE);
             if(result)
               return result;
@@ -551,7 +551,7 @@ Curl_http_output_auth(struct connectdata *conn,
 
 CURLcode Curl_http_input_auth(struct connectdata *conn,
                               int httpcode,
-                              char *header) /* the first non-space */
+                              const char *header) /* the first non-space */
 {
   /*
    * This resource requires authentication
@@ -559,7 +559,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
   struct SessionHandle *data = conn->data;
 
   long *availp;
-  char *start;
+  const char *start;
   struct auth *authp;
 
   if (httpcode == 407) {
@@ -1118,7 +1118,7 @@ Curl_compareheader(const char *headerline, /* line to check */
 
 CURLcode Curl_proxyCONNECT(struct connectdata *conn,
                            int sockindex,
-                           char *hostname,
+                           const char *hostname,
                            unsigned short remote_port)
 {
   int subversion=0;
index cd75f0802f6bd522a93dcdd5047764e826229448..0b8f8b63efa643b64ae8ab04da1c6636f0951fbb 100644 (file)
@@ -31,7 +31,7 @@ bool Curl_compareheader(const char *headerline,  /* line to check */
 /* ftp can use this as well */
 CURLcode Curl_proxyCONNECT(struct connectdata *conn,
                            int tunnelsocket,
-                           char *hostname, unsigned short remote_port);
+                           const char *hostname, unsigned short remote_port);
 
 /* protocol-specific functions set up to be called by the main engine */
 CURLcode Curl_http(struct connectdata *conn, bool *done);
@@ -50,7 +50,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap,
 /* These functions are in http.c */
 void Curl_http_auth_stage(struct SessionHandle *data, int stage);
 CURLcode Curl_http_input_auth(struct connectdata *conn,
-                              int httpcode, char *header);
+                              int httpcode, const char *header);
 CURLcode Curl_http_auth_act(struct connectdata *conn);
 
 int Curl_http_should_fail(struct connectdata *conn);
index 7338ce72a5a93ce33ad0aba3ccbadfe391fe51ac..5afabc7e6ab7f72bb82a9288fa8d1c36e7bd8cc7 100644 (file)
@@ -56,8 +56,8 @@ Proxy-Authenticate: Digest realm="testrealm", nonce="1053604598"
 
 CURLdigest Curl_input_digest(struct connectdata *conn,
                              bool proxy,
-                             char *header) /* rest of the *-authenticate:
-                                              header */
+                             const char *header) /* rest of the *-authenticate:
+                                                    header */
 {
   bool more = TRUE;
   char *token = NULL;
@@ -212,8 +212,8 @@ static void md5_to_ascii(unsigned char *source, /* 16 bytes */
 
 CURLcode Curl_output_digest(struct connectdata *conn,
                             bool proxy,
-                            unsigned char *request,
-                            unsigned char *uripath)
+                            const unsigned char *request,
+                            const unsigned char *uripath)
 {
   /* We have a Digest setup for this, use it!  Now, to get all the details for
      this sorted out, I must urge you dear friend to read up on the RFC2617
index 6cf0259754126e9db111ac7444afe1125964eb6d..c83cb1e3c52c49da6026dd679def4dc2219e2cfe 100644 (file)
@@ -40,13 +40,13 @@ enum {
 
 /* this is for digest header input */
 CURLdigest Curl_input_digest(struct connectdata *conn,
-                             bool proxy, char *header);
+                             bool proxy, const char *header);
 
 /* this is for creating digest header output */
 CURLcode Curl_output_digest(struct connectdata *conn,
                             bool proxy,
-                            unsigned char *request,
-                            unsigned char *uripath);
+                            const unsigned char *request,
+                            const unsigned char *uripath);
 void Curl_digest_cleanup_one(struct digestdata *dig);
 
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
index ac93413cf693769698c5f4982a429ea1cc683a00..f504c12d804b285dd92689ce7560a307a17bc28c 100644 (file)
@@ -113,7 +113,7 @@ log_gss_error(struct connectdata *conn, OM_uint32 error_status, char *prefix)
   infof(conn->data, "%s", buf);
 }
 
-int Curl_input_negotiate(struct connectdata *conn, char *header)
+int Curl_input_negotiate(struct connectdata *conn, const char *header)
 {
   struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
   OM_uint32 major_status, minor_status, minor_status2;
index ce0d083f91b4b2a23bb6f8a7d38ab98c32cac209..e0507013fd272a4713d20b431ef0adf05d537f1a 100644 (file)
@@ -27,7 +27,7 @@
 #ifdef HAVE_GSSAPI
 
 /* this is for Negotiate header input */
-int Curl_input_negotiate(struct connectdata *conn, char *header);
+int Curl_input_negotiate(struct connectdata *conn, const char *header);
 
 /* this is for creating Negotiate header output */
 CURLcode Curl_output_negotiate(struct connectdata *conn);
index e50ace1000d08cf1aa93eacbcc712651af90613b..2dda4d069c10c78e2939f728b8e32e2c6ede72a9 100644 (file)
@@ -218,8 +218,8 @@ static void print_hex(FILE *handle, const char *buf, size_t len)
 
 CURLntlm Curl_input_ntlm(struct connectdata *conn,
                          bool proxy,   /* if proxy or not */
-                         char *header) /* rest of the www-authenticate:
-                                          header */
+                         const char *header) /* rest of the www-authenticate:
+                                                header */
 {
   /* point to the correct struct with this */
   struct ntlmdata *ntlm;
index 265a912b4f650ba446ac7492695ebaa418db2d58..40a0c9b5d54d46f9abf487bff9a4a81a54d7e226 100644 (file)
@@ -33,7 +33,8 @@ typedef enum {
 } CURLntlm;
 
 /* this is for ntlm header input */
-CURLntlm Curl_input_ntlm(struct connectdata *conn, bool proxy, char *header);
+CURLntlm Curl_input_ntlm(struct connectdata *conn, bool proxy,
+                        const char *header);
 
 /* this is for creating ntlm header output */
 CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
index e1ad86cc0dfccdb14fcf04b6397b34c6f53e99fa..9dec1bd224943a37fad4df0397dbdb77df8d15ee 100644 (file)
@@ -122,7 +122,7 @@ static int blockread_all(struct connectdata *conn, /* connection data */
 *   Nonsupport "Identification Protocol (RFC1413)"
 */
 CURLcode Curl_SOCKS4(const char *proxy_name,
-                     char *hostname,
+                     const char *hostname,
                      int remote_port,
                      int sockindex,
                      struct connectdata *conn)
@@ -329,7 +329,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
  */
 CURLcode Curl_SOCKS5(const char *proxy_name,
                      const char *proxy_password,
-                     char *hostname,
+                     const char *hostname,
                      int remote_port,
                      int sockindex,
                      struct connectdata *conn)
index dfe5cb4f1552fa44d96f8bd3faa0e7e13045acee..8da142fbd88e7d97fd287b8baf08a11c8e1824ba 100644 (file)
@@ -28,7 +28,7 @@
  * final destination server.
  */
 CURLcode Curl_SOCKS4(const char *proxy_name,
-                     char *hostname,
+                     const char *hostname,
                      int remote_port,
                      int sockindex,
                      struct connectdata *conn);
@@ -39,7 +39,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
  */
 CURLcode Curl_SOCKS5(const char *proxy_name,
                      const char *proxy_password,
-                     char *hostname,
+                     const char *hostname,
                      int remote_port,
                      int sockindex,
                      struct connectdata *conn);
index 90af86053f0c176a45cbd61f2a411a8b8e1b2494..3549232ab21ba8b3ac8c31034aef28173eed78e3 100644 (file)
@@ -345,7 +345,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
                                void *ssl_sessionid,
                                size_t idsize)
 {
-  int i;
+  long i;
   struct SessionHandle *data=conn->data; /* the mother of all structs */
   struct curl_ssl_session *store = &data->state.session[0];
   long oldest_age=data->state.session[0].age; /* zero if unused */
@@ -395,7 +395,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
 void Curl_ssl_close_all(struct SessionHandle *data)
 {
 #ifdef USE_SSL
-  int i;
+  long i;
   /* kill the session ID cache */
   if(data->state.session) {
     for(i=0; i< data->set.ssl.numsessions; i++)
@@ -632,7 +632,7 @@ ssize_t Curl_ssl_recv(struct connectdata *conn, /* connection data */
       return -1;
   }
 
-  return (int)nread;
+  return nread;
 
 #else /* USE_SSL */
   (void)conn;
@@ -726,7 +726,7 @@ int Curl_ssl_check_cxn(struct connectdata *conn)
 #endif /* USE_SSLEAY */
 }
 
-bool Curl_ssl_data_pending(struct connectdata *conn,
+bool Curl_ssl_data_pending(const struct connectdata *conn,
                            int connindex)
 {
 #ifdef USE_SSLEAY
index 70bd7c562267f81c0ee8bedff0297119e7f25166..391b8f33ed388faa290b9142bf897f683764597d 100644 (file)
@@ -71,7 +71,7 @@ int Curl_ssl_check_cxn(struct connectdata *conn);
 
 CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex);
 
-bool Curl_ssl_data_pending(struct connectdata *conn,
+bool Curl_ssl_data_pending(const struct connectdata *conn,
                            int connindex);
 
 #if !defined(USE_SSL) && !defined(SSLGEN_C)
index acaf9612d4b7d5c143d2f627d993c4698c04add4..3aea2dee91847baaea8547df62f031f10118e641 100644 (file)
@@ -858,9 +858,9 @@ int Curl_ossl_close_all(struct SessionHandle *data)
 
 static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
                                     const char *prefix,
-                                    ASN1_UTCTIME *tm)
+                                    const ASN1_UTCTIME *tm)
 {
-  char *asn1_string;
+  const char *asn1_string;
   int gmt=FALSE;
   int i;
   int year=0,month=0,day=0,hour=0,minute=0,second=0;
@@ -874,7 +874,7 @@ static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
     return 0;
 
   i=tm->length;
-  asn1_string=(char *)tm->data;
+  asn1_string=(const char *)tm->data;
 
   if(i < 10)
     return 1;
@@ -929,7 +929,7 @@ static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
 static int hostmatch(const char *hostname, const char *pattern)
 {
   while (1) {
-    int c = *pattern++;
+    char c = *pattern++;
 
     if (c == '\0')
       return (*hostname ? HOST_NOMATCH : HOST_MATCH);
index de1e186401cfbfa7bf08b1c998d5312c7a859bae..0fb21c528941079d1ef9aea4eca9e188e8bf67a0 100644 (file)
@@ -268,7 +268,7 @@ CURLcode Curl_readrewind(struct connectdata *conn)
   return CURLE_OK;
 }
 
-static int data_pending(struct connectdata *conn)
+static int data_pending(const struct connectdata *conn)
 {
   /* in the case of libssh2, we can never be really sure that we have emptied
      its internal buffers so we MUST always try until we get EAGAIN back */
@@ -1377,7 +1377,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
     if((k->keepon & KEEP_WRITE) && (select_res & CURL_CSELECT_OUT)) {
       /* write */
 
-      int i, si;
+      ssize_t i, si;
       ssize_t bytes_written;
       bool writedone=TRUE;
 
@@ -1743,14 +1743,14 @@ void Curl_pre_readwrite(struct connectdata *conn)
  * keeps track of. This function will only be called for connections that are
  * in the proper state to have this information available.
  */
-int Curl_single_getsock(struct connectdata *conn,
+int Curl_single_getsock(const struct connectdata *conn,
                         curl_socket_t *sock, /* points to numsocks number
                                                 of sockets */
                         int numsocks)
 {
-  struct SessionHandle *data = conn->data;
+  const struct SessionHandle *data = conn->data;
   int bitmap = GETSOCK_BLANK;
-  int index = 0;
+  unsigned index = 0;
 
   if(numsocks < 2)
     /* simple check but we might need two slots */
@@ -1957,16 +1957,17 @@ CURLcode Curl_posttransfer(struct SessionHandle *data)
  * strlen_url() returns the length of the given URL if the spaces within the
  * URL were properly URL encoded.
  */
-static int strlen_url(char *url)
+static size_t strlen_url(const char *url)
 {
-  char *ptr;
-  int newlen=0;
+  const char *ptr;
+  size_t newlen=0;
   bool left=TRUE; /* left side of the ? */
 
   for(ptr=url; *ptr; ptr++) {
     switch(*ptr) {
     case '?':
       left=FALSE;
+      /* fall through */
     default:
       newlen++;
       break;
@@ -1984,11 +1985,11 @@ static int strlen_url(char *url)
 /* strcpy_url() copies a url to a output buffer and URL-encodes the spaces in
  * the source URL accordingly.
  */
-static void strcpy_url(char *output, char *url)
+static void strcpy_url(char *output, const char *url)
 {
   /* we must add this with whitespace-replacing */
   bool left=TRUE;
-  char *iptr;
+  const char *iptr;
   char *optr = output;
   for(iptr = url;    /* read from here */
       *iptr;         /* until zero byte */
@@ -1996,6 +1997,7 @@ static void strcpy_url(char *output, char *url)
     switch(*iptr) {
     case '?':
       left=FALSE;
+      /* fall through */
     default:
       *optr++=*iptr;
       break;
index 7a08b334e873decd91db66152b0247eac56cba24..a2fcd11e20e40b6fdc00189f144b55d5de4655fb 100644 (file)
@@ -28,7 +28,7 @@ CURLcode Curl_second_connect(struct connectdata *conn);
 CURLcode Curl_posttransfer(struct SessionHandle *data);
 CURLcode Curl_follow(struct SessionHandle *data, char *newurl, bool retry);
 CURLcode Curl_readwrite(struct connectdata *conn, bool *done);
-int Curl_single_getsock(struct connectdata *conn,
+int Curl_single_getsock(const struct connectdata *conn,
                         curl_socket_t *socks,
                         int numsocks);
 CURLcode Curl_readwrite_init(struct connectdata *conn);