fixes from Joerg Sonnenberger:
authorNiels Provos <provos@gmail.com>
Sat, 30 Jun 2007 18:58:34 +0000 (18:58 +0000)
committerNiels Provos <provos@gmail.com>
Sat, 30 Jun 2007 18:58:34 +0000 (18:58 +0000)
http.c is a violation of the ctype(3) interface and an unused function.

test/regress_http.c are incorrect format strings.

test/regress.c uses raise(3) from signal.h.

evdns.c: evdns_error_strings is unused. The GET* macros can eat the
semicolon from the expression. pos is passed in as off_t, so just pass
that down. When assigning negativ values to unsigned variables, an
explicit cast is considered good style.

svn:r367

buffer.c
evdns.c
event.h
event_tagging.c
http.c
test/regress.c
test/regress_http.c

index 6b558a833bd09fb956ad6d5cda4f627207c4980a..0a57dda3104de7b8c2e58af5c7747a2fb1067464 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -249,7 +249,7 @@ evbuffer_readline(struct evbuffer *buffer)
 
 /* Adds data to an event buffer */
 
-static inline void
+static void
 evbuffer_align(struct evbuffer *buf)
 {
        memmove(buf->orig_buffer, buf->buffer, buf->off);
diff --git a/evdns.c b/evdns.c
index 068dc7df4dae05efb6c75d1aef145c8c12e16a66..7c45d782801e0ac66edf77e86b47c981146ef227 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -307,8 +307,6 @@ static int global_max_nameserver_timeout = 3;
 static const struct timeval global_nameserver_timeouts[] = {{10, 0}, {60, 0}, {300, 0}, {900, 0}, {3600, 0}};
 static const int global_nameserver_timeouts_length = sizeof(global_nameserver_timeouts)/sizeof(struct timeval);
 
-static const char *const evdns_error_strings[] = {"no error", "The name server was unable to interpret the query", "The name server suffered an internal error", "The requested domain name does not exist", "The name server refused to reply to the request"};
-
 static struct nameserver *nameserver_pick(void);
 static void evdns_request_insert(struct request *req, struct request **head);
 static void nameserver_ready_callback(int fd, short events, void *arg);
@@ -744,14 +742,14 @@ reply_handle(struct request *const req, u16 flags, u32 ttl, struct reply *reply)
        }
 }
 
-static inline int
+static int
 name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) {
        int name_end = -1;
        int j = *idx;
        int ptr_count = 0;
-#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&_t32, packet + j, 4); j += 4; x = ntohl(_t32); } while(0);
-#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&_t, packet + j, 2); j += 2; x = ntohs(_t); } while(0);
-#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while(0);
+#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&_t32, packet + j, 4); j += 4; x = ntohl(_t32); } while(0)
+#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&_t, packet + j, 2); j += 2; x = ntohs(_t); } while(0)
+#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while(0)
 
        char *cp = name_out;
        const char *const end = name_out + name_out_len;
@@ -1226,7 +1224,7 @@ server_port_ready_callback(int fd, short events, void *arg) {
  * functions, so that is can be safely replaced with something smarter later. */
 #define MAX_LABELS 128
 // Structures used to implement name compression
-struct dnslabel_entry { char *v; int pos; };
+struct dnslabel_entry { char *v; off_t pos; };
 struct dnslabel_table {
        int n_labels; // number of current entries
        // map from name to position in message
@@ -1265,7 +1263,7 @@ dnslabel_table_get_pos(const struct dnslabel_table *table, const char *label)
 
 // remember that we've used the label at position pos
 static int
-dnslabel_table_add(struct dnslabel_table *table, const char *label, int pos)
+dnslabel_table_add(struct dnslabel_table *table, const char *label, off_t pos)
 {
        char *v;
        int p;
@@ -1483,7 +1481,7 @@ evdns_server_request_add_reply(struct evdns_server_request *_req, int section, c
                                free(item);
                                return -1;
                        }
-                       item->datalen = -1;
+                       item->datalen = (u16)-1;
                } else {
                        if (!(item->data = malloc(datalen))) {
                                free(item->name);
diff --git a/event.h b/event.h
index 8687f19498d481c3c6e387aa2b9f90a599a7eb65..753008a76a5bebd62ce593f83b7ca47cad2b89d2 100644 (file)
--- a/event.h
+++ b/event.h
@@ -31,6 +31,7 @@
 extern "C" {
 #endif
 
+#include <sys/time.h>
 #include <stdarg.h>
 
 #ifdef WIN32
index 7a82b829ee7462fafcf7a559fa62ae3b46e0ce60..6bb44e23fe5a7f366dc1a551439661e1eabab292 100644 (file)
@@ -149,7 +149,7 @@ evtag_marshal_timeval(struct evbuffer *evbuf, u_int8_t tag, struct timeval *tv)
            EVBUFFER_LENGTH(_buf));
 }
 
-static int inline
+static int
 decode_int_internal(u_int32_t *pnumber, struct evbuffer *evbuf, int dodrain)
 {
        u_int32_t number = 0;
diff --git a/http.c b/http.c
index 7b654c7fabe1c3de84d443676cbd62f9f1b75515..be9421f2c3d6a66b27c8b12c6fec59df0aefdd26 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1735,8 +1735,8 @@ evhttp_decode_uri(const char *uri)
                        in_query = 1;
                } else if (c == '+' && in_query) {
                        c = ' ';
-               } else if (c == '%' && isxdigit(uri[i+1]) &&
-                   isxdigit(uri[i+2])) {
+               } else if (c == '%' && isxdigit((unsigned char)uri[i+1]) &&
+                   isxdigit((unsigned char)uri[i+2])) {
                        char tmp[] = { uri[i+1], uri[i+2], '\0' };
                        c = (char)strtol(tmp, NULL, 16);
                        i += 2;
@@ -2178,7 +2178,7 @@ evhttp_get_request(struct evhttp *http, int fd,
  * Network helper functions that we do not want to export to the rest of
  * the world.
  */
-
+#if 0 /* Unused */
 static struct addrinfo *
 addr_from_name(char *address)
 {
@@ -2203,6 +2203,7 @@ addr_from_name(char *address)
        return NULL; // XXXXX Use gethostbyname, if this function is ever used.
 #endif
 }
+#endif
 
 static void
 name_from_addr(struct sockaddr *sa, socklen_t salen,
index 455604d57b4f889fd6e959e9a871ad03675fc62e..602449d1e286dbde1baedd094d1c3dc32923fcc0 100644 (file)
@@ -48,6 +48,7 @@
 #endif
 #include <netdb.h>
 #include <fcntl.h>
+#include <signal.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
index 3fdaacb4350522972e03e017a42975bab6d0adab..33f070b898e17b0d52f69da03f0d52844d5e2de9 100644 (file)
@@ -389,7 +389,7 @@ http_post_cb(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(POST_DATA)) {
-               fprintf(stdout, "FAILED (length: %ld vs %ld)\n",
+               fprintf(stdout, "FAILED (length: %zu vs %zu)\n",
                    EVBUFFER_LENGTH(req->input_buffer), strlen(POST_DATA));
                exit(1);
        }
@@ -427,7 +427,7 @@ http_postrequest_done(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(what)) {
-               fprintf(stderr, "FAILED (length %ld vs %ld)\n",
+               fprintf(stderr, "FAILED (length %zu vs %zu)\n",
                    EVBUFFER_LENGTH(req->input_buffer), strlen(what));
                exit(1);
        }