From: Nick Mathewson Date: Thu, 23 Apr 2009 05:40:06 +0000 (+0000) Subject: Fix c89 bugs reported by Cory Stup. X-Git-Tag: release-2.0.3-alpha~280 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9516df0e2eeb28234f679a65062631d409781346;p=libevent Fix c89 bugs reported by Cory Stup. Others may remain. I wasn't able to get gcc --std=c89 to build libevent at all, so I don't know what compiler the original reporter is using here. Note that this change requires us to disable the part of our rpc code that uses variadic macros when using a non-gcc compiler. This is a problem if we want our rpc api to be portable. svn:r1231 --- diff --git a/ChangeLog b/ChangeLog index a22d9fe7..3b1e0d53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ Changes in 2.0.2-alpha: o Disallow setting less than 1 priority. o Fix a bug when removing a timeout from the heap. [Patch from Marko Kreen] o Use signal.h, not sys/signal.h. [Patch from mmadia] + o Try harder to build with certain older c99 compilers. Changes in 2.0.1-alpha: o free minheap on event_base_free(); from Christopher Layne diff --git a/evdns.c b/evdns.c index 24ede4e9..f4051d2e 100644 --- a/evdns.c +++ b/evdns.c @@ -261,8 +261,8 @@ struct evdns_server_port { struct server_reply_item { struct server_reply_item *next; /* next item in sequence. */ char *name; /* name part of the RR */ - u16 type : 16; /* The RR type */ - u16 class : 16; /* The RR class (usually CLASS_INET) */ + u16 type; /* The RR type */ + u16 class; /* The RR class (usually CLASS_INET) */ u32 ttl; /* The RR TTL */ char is_name; /* True iff data is a label */ u16 datalen; /* Length of data; -1 if data is a label */ diff --git a/event_rpcgen.py b/event_rpcgen.py index 536104dc..f8c7c006 100755 --- a/event_rpcgen.py +++ b/event_rpcgen.py @@ -1541,12 +1541,14 @@ class CCodeGenerator: pre += ( '#define EVTAG_HAS(msg, member) ((msg)->member##_set == 1)\n' + '#ifdef __GNUC__\n' '#define EVTAG_ASSIGN(msg, member, args...) ' '(*(msg)->base->member##_assign)(msg, ## args)\n' '#define EVTAG_GET(msg, member, args...) ' '(*(msg)->base->member##_get)(msg, ## args)\n' '#define EVTAG_ADD(msg, member, args...) ' '(*(msg)->base->member##_add)(msg, ## args)\n' + '#endif\n' '#define EVTAG_LEN(msg, member) ((msg)->member##_length)\n' ) diff --git a/http-internal.h b/http-internal.h index 194980a0..ab3d8039 100644 --- a/http-internal.h +++ b/http-internal.h @@ -147,8 +147,10 @@ void evhttp_connection_fail(struct evhttp_connection *, void evhttp_get_request(struct evhttp *, evutil_socket_t, struct sockaddr *, socklen_t); -int evhttp_parse_firstline(struct evhttp_request *, struct evbuffer*); -int evhttp_parse_headers(struct evhttp_request *, struct evbuffer*); +enum message_read_status; + +enum message_read_status evhttp_parse_firstline(struct evhttp_request *, struct evbuffer*); +enum message_read_status evhttp_parse_headers(struct evhttp_request *, struct evbuffer*); void evhttp_start_read(struct evhttp_connection *); void evhttp_make_header(struct evhttp_connection *, struct evhttp_request *); diff --git a/http.c b/http.c index 18d7e4e2..51d7f16e 100644 --- a/http.c +++ b/http.c @@ -2157,7 +2157,10 @@ evhttp_decode_uri_internal( c = ' '; } else if (c == '%' && EVUTIL_ISXDIGIT(uri[i+1]) && EVUTIL_ISXDIGIT(uri[i+2])) { - char tmp[] = { uri[i+1], uri[i+2], '\0' }; + char tmp[3]; + tmp[0] = uri[i+1]; + tmp[1] = uri[i+2]; + tmp[2] = '\0'; c = (char)strtol(tmp, NULL, 16); i += 2; }