From e9837124563d6d4bb871d0620e9b02550f796c43 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 13 Dec 2014 19:42:42 +0100 Subject: [PATCH] use ev_uint16_t instead of unsigned short for port Like in `sockaddr_in` structure in /usr/include/netinet/in.h @azat: convert all other users (bench, compat, ..) and tweak message Fixes: #178 Fixes: #196 Refs: 6bf1ca78 Link: https://codereview.appspot.com/156040043/#msg4 --- http-internal.h | 4 ++-- http.c | 8 ++++---- include/event2/http.h | 4 ++-- include/event2/http_compat.h | 4 ++-- sample/http-server.c | 2 +- test/bench_http.c | 2 +- test/regress_http.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/http-internal.h b/http-internal.h index ae01f386ae..45555171c2 100644 --- a/http-internal.h +++ b/http-internal.h @@ -62,10 +62,10 @@ struct evhttp_connection { struct event retry_ev; /* for retrying connects */ char *bind_address; /* address to use for binding the src */ - unsigned short bind_port; /* local port for binding the src */ + ev_uint16_t bind_port; /* local port for binding the src */ char *address; /* address to connect to */ - unsigned short port; + ev_uint16_t port; size_t max_headers_size; ev_uint64_t max_body_size; diff --git a/http.c b/http.c index b9f909e4ac..8429240075 100644 --- a/http.c +++ b/http.c @@ -2342,14 +2342,14 @@ evhttp_read_header(struct evhttp_connection *evcon, */ struct evhttp_connection * -evhttp_connection_new(const char *address, unsigned short port) +evhttp_connection_new(const char *address, ev_uint16_t port) { return (evhttp_connection_base_new(NULL, NULL, address, port)); } struct evhttp_connection * evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, - const char *address, unsigned short port) + const char *address, ev_uint16_t port) { struct evhttp_connection *evcon = NULL; @@ -2425,7 +2425,7 @@ evhttp_connection_get_server(struct evhttp_connection *evcon) struct evhttp_connection * evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, - const char *address, unsigned short port) + const char *address, ev_uint16_t port) { return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port); } @@ -3665,7 +3665,7 @@ evhttp_new(struct event_base *base) */ struct evhttp * -evhttp_start(const char *address, unsigned short port) +evhttp_start(const char *address, ev_uint16_t port) { struct evhttp *http = NULL; diff --git a/include/event2/http.h b/include/event2/http.h index 10a7e975f2..8fb5642f7f 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -520,7 +520,7 @@ enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE }; */ EVENT2_EXPORT_SYMBOL struct evhttp_connection *evhttp_connection_base_bufferevent_new( - struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, unsigned short port); + struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port); /** * Return the bufferevent that an evhttp_connection is using. @@ -641,7 +641,7 @@ void evhttp_request_free(struct evhttp_request *req); EVENT2_EXPORT_SYMBOL struct evhttp_connection *evhttp_connection_base_new( struct event_base *base, struct evdns_base *dnsbase, - const char *address, unsigned short port); + const char *address, ev_uint16_t port); /** * Set family hint for DNS requests. diff --git a/include/event2/http_compat.h b/include/event2/http_compat.h index 0d9af17f3f..43c2c43e46 100644 --- a/include/event2/http_compat.h +++ b/include/event2/http_compat.h @@ -58,7 +58,7 @@ extern "C" { * @param port the port number on which the HTTP server should listen * @return an struct evhttp object */ -struct evhttp *evhttp_start(const char *address, unsigned short port); +struct evhttp *evhttp_start(const char *address, ev_uint16_t port); /** * A connection object that can be used to for making HTTP requests. The @@ -68,7 +68,7 @@ struct evhttp *evhttp_start(const char *address, unsigned short port); * @deprecated It does not allow an event base to be specified */ struct evhttp_connection *evhttp_connection_new( - const char *address, unsigned short port); + const char *address, ev_uint16_t port); /** * Associates an event base with the connection - can only be called diff --git a/sample/http-server.c b/sample/http-server.c index cbb9c914dd..99c249a24b 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -333,7 +333,7 @@ main(int argc, char **argv) struct evhttp *http; struct evhttp_bound_socket *handle; - unsigned short port = 0; + ev_uint16_t port = 0; #ifdef _WIN32 WSADATA WSAData; WSAStartup(0x101, &WSAData); diff --git a/test/bench_http.c b/test/bench_http.c index 0c46855f4f..d20d3bc790 100644 --- a/test/bench_http.c +++ b/test/bench_http.c @@ -90,7 +90,7 @@ main(int argc, char **argv) int i; int c; int use_iocp = 0; - unsigned short port = 8080; + ev_uint16_t port = 8080; char *endptr = NULL; #ifdef _WIN32 diff --git a/test/regress_http.c b/test/regress_http.c index 6d6abe29d3..cfe85387a2 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -164,7 +164,7 @@ http_setup(ev_uint16_t *pport, struct event_base *base, int mask) #endif static evutil_socket_t -http_connect(const char *address, unsigned short port) +http_connect(const char *address, ev_uint16_t port) { /* Stupid code for connecting */ struct evutil_addrinfo ai, *aitop;