fixes from Joerg Sonnenberger:

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
This commit is contained in:
Niels Provos 2007-06-30 18:58:34 +00:00
parent aa5c806888
commit f0ff792afa
7 changed files with 17 additions and 16 deletions

View File

@ -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);

16
evdns.c
View File

@ -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);

View File

@ -31,6 +31,7 @@
extern "C" {
#endif
#include <sys/time.h>
#include <stdarg.h>
#ifdef WIN32

View 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;

7
http.c
View File

@ -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,

View File

@ -48,6 +48,7 @@
#endif
#include <netdb.h>
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View 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);
}