]> granicus.if.org Git - curl/commitdiff
Fix compiler warnings
authorYang Tse <yangsita@gmail.com>
Wed, 19 Jul 2006 21:14:02 +0000 (21:14 +0000)
committerYang Tse <yangsita@gmail.com>
Wed, 19 Jul 2006 21:14:02 +0000 (21:14 +0000)
lib/base64.c
lib/http_ntlm.c
lib/ssluse.c
lib/telnet.c
lib/tftp.c
lib/url.c

index 627fa9840e3e10c271ec725a496044ff61e6718a..c9e8a382c70b9c6eae4b91085efd335ddd04de74 100644 (file)
@@ -177,10 +177,12 @@ size_t Curl_base64_encode(const char *inp, size_t insize, char **outptr)
         ibuf[i] = 0;
     }
 
-    obuf [0] = (ibuf [0] & 0xFC) >> 2;
-    obuf [1] = ((ibuf [0] & 0x03) << 4) | ((ibuf [1] & 0xF0) >> 4);
-    obuf [2] = ((ibuf [1] & 0x0F) << 2) | ((ibuf [2] & 0xC0) >> 6);
-    obuf [3] = ibuf [2] & 0x3F;
+    obuf[0] = (unsigned char)  ((ibuf[0] & 0xFC) >> 2);
+    obuf[1] = (unsigned char) (((ibuf[0] & 0x03) << 4) | \
+                               ((ibuf[1] & 0xF0) >> 4));
+    obuf[2] = (unsigned char) (((ibuf[1] & 0x0F) << 2) | \
+                               ((ibuf[2] & 0xC0) >> 6));
+    obuf[3] = (unsigned char)   (ibuf[2] & 0x3F);
 
     switch(inputparts) {
     case 1: /* only one byte read */
index 01f049f242ae8ec022b16a09a356a71b0730e03b..24b89ddeda491bd23c9fdc77e023b5bee9861ab0 100644 (file)
@@ -304,13 +304,13 @@ static void setup_des_key(unsigned char *key_56,
   DES_cblock key;
 
   key[0] = key_56[0];
-  key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1);
-  key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2);
-  key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3);
-  key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4);
-  key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5);
-  key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6);
-  key[7] =  (key_56[6] << 1) & 0xFF;
+  key[1] = (unsigned char)(((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1));
+  key[2] = (unsigned char)(((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2));
+  key[3] = (unsigned char)(((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3));
+  key[4] = (unsigned char)(((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4));
+  key[5] = (unsigned char)(((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5));
+  key[6] = (unsigned char)(((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6));
+  key[7] = (unsigned char) ((key_56[6] << 1) & 0xFF);
 
   DES_set_odd_parity(&key);
   DES_set_key(&key, ks);
@@ -357,7 +357,7 @@ static void mk_lm_hash(char *password, unsigned char *lmbuffer /* 21 bytes */)
     len = 14;
 
   for (i=0; i<len; i++)
-    pw[i] = toupper(password[i]);
+    pw[i] = (unsigned char)toupper(password[i]);
 
   for (; i<14; i++)
     pw[i] = 0;
index 284406084103b85c94f60a34a3361fde44bec168..90b8afe20181637392b729b125356636c8c6c1b7 100644 (file)
@@ -1806,7 +1806,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
     }
     else {
       if(ssleay_value&0xff0) {
-        sub[0]=(char)((ssleay_value>>4)&0xff) + 'a' -1;
+        sub[0]=(char)(((ssleay_value>>4)&0xff) + 'a' -1);
       }
       else
         sub[0]='\0';
index 29e053e1573c1a70284af4e64a776429916e6fa5..5f94807df76bc01598eaa9e13321ab276e15d86b 100644 (file)
@@ -295,8 +295,8 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
    struct SessionHandle *data = conn->data;
 
    buf[0] = CURL_IAC;
-   buf[1] = cmd;
-   buf[2] = option;
+   buf[1] = (unsigned char)cmd;
+   buf[2] = (unsigned char)option;
 
    bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
    if(bytes_written < 0) {
index 7a347b5c3be7baab91201ec04adc85800c0b3894..38adc0c75cc84b26bbb134ca1fe21355b3fb370f 100644 (file)
@@ -228,25 +228,25 @@ void tftp_set_timeouts(tftp_state_data_t *state)
 
 static void setpacketevent(tftp_packet_t *packet, unsigned short num)
 {
-  packet->data[0] = (num >> 8);
-  packet->data[1] = (num & 0xff);
+  packet->data[0] = (unsigned char)(num >> 8);
+  packet->data[1] = (unsigned char)(num & 0xff);
 }
 
 
 static void setpacketblock(tftp_packet_t *packet, unsigned short num)
 {
-  packet->data[2] = (num >> 8);
-  packet->data[3] = (num & 0xff);
+  packet->data[2] = (unsigned char)(num >> 8);
+  packet->data[3] = (unsigned char)(num & 0xff);
 }
 
 static unsigned short getrpacketevent(tftp_packet_t *packet)
 {
-  return (packet->data[0] << 8) | packet->data[1];
+  return (unsigned short)((packet->data[0] << 8) | packet->data[1]);
 }
 
 static unsigned short getrpacketblock(tftp_packet_t *packet)
 {
-  return (packet->data[2] << 8) | packet->data[3];
+  return (unsigned short)((packet->data[2] << 8) | packet->data[3]);
 }
 
 static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
@@ -355,7 +355,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
       }
     }
     /* This is the expected block.  Reset counters and ACK it. */
-    state->block = rblock;
+    state->block = (unsigned short)rblock;
     state->retries = 0;
     setpacketevent(&state->spacket, TFTP_EVENT_ACK);
     setpacketblock(&state->spacket, state->block);
index 7c0ebc7e6200978d1dd24b8adb4c5d87deece19b..85fef52c09aa5c09605a84eb97dd7f8a8a24ee63 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2927,7 +2927,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
 
         /* Now, build <protocol>_proxy and check for such a one to use */
         while(*protop)
-          *envp++ = tolower((int)*protop++);
+          *envp++ = (char)tolower((int)*protop++);
 
         /* append _proxy */
         strcpy(envp, "_proxy");
@@ -2950,7 +2950,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
         if(!prox && !strequal("http_proxy", proxy_env)) {
           /* There was no lowercase variable, try the uppercase version: */
           for(envp = proxy_env; *envp; envp++)
-            *envp = toupper((int)*envp);
+            *envp = (char)toupper((int)*envp);
           prox=curl_getenv(proxy_env);
         }
 
@@ -3080,7 +3080,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
     }
 
     conn->port = port;
-    conn->remote_port = port;
+    conn->remote_port = (unsigned short)port;
     conn->protocol |= PROT_FTP;
 
     if(data->change.proxy &&
@@ -3120,7 +3120,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
     if(type) {
       char command;
       *type=0;                     /* it was in the middle of the hostname */
-      command = toupper((int)type[6]);
+      command = (char)toupper((int)type[6]);
       switch(command) {
       case 'A': /* ASCII mode */
         data->set.ftp_ascii = 1;
@@ -3222,7 +3222,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
     if(type) {
       char command;
       *type=0;                     /* it was in the middle of the hostname */
-      command = toupper((int)type[6]);
+      command = (char)toupper((int)type[6]);
       switch(command) {
       case 'A': /* ASCII mode */
       case 'N': /* NETASCII mode */