[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Make Tor build on win32 with VC6 without warnings.



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv16693/src/or

Modified Files:
	buffers.c circuit.c dirserv.c or.h rendservice.c 
Log Message:
Make Tor build on win32 with VC6 without warnings.

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- buffers.c	26 Apr 2004 23:05:58 -0000	1.83
+++ buffers.c	28 Apr 2004 20:13:21 -0000	1.84
@@ -168,7 +168,7 @@
  * to tear down the connection return -1, else return the number of
  * bytes read.
  */
-int read_to_buf(int s, int at_most, buf_t *buf, int *reached_eof) {
+int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof) {
 
   int read_result;
 #ifdef MS_WINDOWS
@@ -181,7 +181,7 @@
   if (buf_ensure_capacity(buf,buf->datalen+at_most))
     return -1;
 
-  if(at_most > buf->len - buf->datalen)
+  if(at_most + buf->datalen > buf->len)
     at_most = buf->len - buf->datalen; /* take the min of the two */
 
   if(at_most == 0)
@@ -212,7 +212,7 @@
   }
 }
 
-int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf) {
+int read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf) {
   int r;
   tor_assert(tls);
   assert_buf_ok(buf);
@@ -223,7 +223,7 @@
   if (buf_ensure_capacity(buf, at_most+buf->datalen))
     return TOR_TLS_ERROR;
 
-  if (at_most > buf->len - buf->datalen)
+  if (at_most + buf->datalen > buf->len)
     at_most = buf->len - buf->datalen;
 
   if (at_most == 0)
@@ -255,7 +255,7 @@
 #endif
 
   assert_buf_ok(buf);
-  tor_assert(buf_flushlen && (s>=0) && (*buf_flushlen <= buf->datalen));
+  tor_assert(buf_flushlen && (s>=0) && ((unsigned)*buf_flushlen <= buf->datalen));
 
   if(*buf_flushlen == 0) /* nothing to flush */
     return 0;
@@ -323,7 +323,7 @@
   return buf->datalen;
 }
 
-int fetch_from_buf(char *string, int string_len, buf_t *buf) {
+int fetch_from_buf(char *string, size_t string_len, buf_t *buf) {
 
   /* There must be string_len bytes in buf; write them onto string,
    * then memmove buf back (that is, remove them from buf).
@@ -447,7 +447,7 @@
       if(req->socks_version != 5) { /* we need to negotiate a method */
         unsigned char nummethods = (unsigned char)*(buf->mem+1);
         tor_assert(!req->socks_version);
-        if(buf->datalen < 2+nummethods)
+        if(buf->datalen < 2u+nummethods)
           return 0;
         if(!nummethods || !memchr(buf->mem+2, 0, nummethods)) {
           log_fn(LOG_WARN,"socks5: offered methods don't include 'no auth'. Rejecting.");
@@ -493,7 +493,7 @@
         case 3: /* fqdn */
           log_fn(LOG_DEBUG,"socks5: fqdn address type");
           len = (unsigned char)*(buf->mem+4);
-          if(buf->datalen < 7+len) /* addr/port there? */
+          if(buf->datalen < 7u+len) /* addr/port there? */
             return 0; /* not yet */
           if(len+1 > MAX_SOCKS_ADDR_LEN) {
             log_fn(LOG_WARN,"socks5 hostname is %d bytes, which doesn't fit in %d. Rejecting.",

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -d -r1.225 -r1.226
--- circuit.c	27 Apr 2004 11:28:45 -0000	1.225
+++ circuit.c	28 Apr 2004 20:13:21 -0000	1.226
@@ -1627,7 +1627,7 @@
  */
 int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
 {
-  unsigned char iv[CIPHER_IV_LEN];
+  unsigned char iv[_ARRAYSIZE(CIPHER_IV_LEN)];
   crypto_digest_env_t *tmp_digest;
   crypto_cipher_env_t *tmp_crypto;
 

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- dirserv.c	25 Apr 2004 19:04:11 -0000	1.39
+++ dirserv.c	28 Apr 2004 20:13:21 -0000	1.40
@@ -407,7 +407,7 @@
  * Return 0 on success, -1 on failure.
  */
 int
-dirserv_dump_directory_to_string(char *s, int maxlen,
+dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
                                  crypto_pk_env_t *private_key)
 {
   char *cp, *eos;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.326
retrieving revision 1.327
diff -u -d -r1.326 -r1.327
--- or.h	25 Apr 2004 23:47:26 -0000	1.326
+++ or.h	28 Apr 2004 20:13:21 -0000	1.327
@@ -657,14 +657,14 @@
 size_t buf_capacity(const buf_t *buf);
 const char *_buf_peek_raw_buffer(const buf_t *buf);
 
-int read_to_buf(int s, int at_most, buf_t *buf, int *reached_eof);
-int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf);
+int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof);
+int read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf);
 
 int flush_buf(int s, buf_t *buf, int *buf_flushlen);
 int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen);
 
 int write_to_buf(const char *string, int string_len, buf_t *buf);
-int fetch_from_buf(char *string, int string_len, buf_t *buf);
+int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
 int fetch_from_buf_http(buf_t *buf,
                         char **headers_out, int max_headerlen,
                         char **body_out, int *body_used, int max_bodylen);
@@ -1026,7 +1026,7 @@
 int dirserv_add_descriptor(const char **desc);
 int dirserv_init_from_directory_string(const char *dir);
 void dirserv_free_descriptors();
-int dirserv_dump_directory_to_string(char *s, int maxlen,
+int dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
                                      crypto_pk_env_t *private_key);
 void directory_set_dirty(void);
 size_t dirserv_get_directory(const char **cp);

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- rendservice.c	25 Apr 2004 21:32:04 -0000	1.59
+++ rendservice.c	28 Apr 2004 20:13:21 -0000	1.60
@@ -396,7 +396,7 @@
     log_fn(LOG_WARN, "Couldn't find a null-padded nickname in INTRODUCE2 cell");
     return -1;
   }
-  if (strspn(buf,LEGAL_NICKNAME_CHARACTERS) != ptr-buf) {
+  if ((int)strspn(buf,LEGAL_NICKNAME_CHARACTERS) != ptr-buf) {
     log_fn(LOG_WARN, "Nickname in INTRODUCE2 cell contains illegal character.");
     return -1;
   }
@@ -551,7 +551,7 @@
   /* Build the payload for a RELAY_ESTABLISH_INTRO cell. */
   len = crypto_pk_asn1_encode(service->private_key, buf+2,
                               RELAY_PAYLOAD_SIZE-2);
-  set_uint16(buf, htons(len));
+  set_uint16(buf, htons((uint16_t)len));
   len += 2;
   memcpy(auth, circuit->cpath->prev->handshake_digest, DIGEST_LEN);
   memcpy(auth+DIGEST_LEN, "INTRODUCE", 9);