Skip to content

Commit

Permalink
Fix non-std printf %p arguments (libevent#1327)
Browse files Browse the repository at this point in the history
* Fix non-std printf %p arguments when running with -Werror -pedantic-errors

Co-authored-by: Mareks Malnacs <mareks.malnacs>
  • Loading branch information
mareksm authored Aug 28, 2022
1 parent bb57cea commit b19af67
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
10 changes: 5 additions & 5 deletions bufferevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ bufferevent_enable(struct bufferevent *bufev, short event)
if (impl_events && bufev->be_ops->enable(bufev, impl_events) < 0)
r = -1;
if (r)
event_debug(("%s: cannot enable 0x%hx on %p", __func__, event, bufev));
event_debug(("%s: cannot enable 0x%hx on %p", __func__, event, (void *)bufev));

bufferevent_decref_and_unlock_(bufev);
return r;
Expand Down Expand Up @@ -585,7 +585,7 @@ bufferevent_disable(struct bufferevent *bufev, short event)
if (bufev->be_ops->disable(bufev, event) < 0)
r = -1;
if (r)
event_debug(("%s: cannot disable 0x%hx on %p", __func__, event, bufev));
event_debug(("%s: cannot disable 0x%hx on %p", __func__, event, (void *)bufev));

BEV_UNLOCK(bufev);
return r;
Expand Down Expand Up @@ -876,7 +876,7 @@ bufferevent_setfd(struct bufferevent *bev, evutil_socket_t fd)
if (bev->be_ops->ctrl)
res = bev->be_ops->ctrl(bev, BEV_CTRL_SET_FD, &d);
if (res)
event_debug(("%s: cannot set fd for %p to "EV_SOCK_FMT, __func__, bev, fd));
event_debug(("%s: cannot set fd for %p to "EV_SOCK_FMT, __func__, (void *)bev, fd));
BEV_UNLOCK(bev);
return res;
}
Expand All @@ -903,7 +903,7 @@ bufferevent_replacefd(struct bufferevent *bev, evutil_socket_t fd)
}
}
if (err)
event_debug(("%s: cannot replace fd for %p from "EV_SOCK_FMT" to "EV_SOCK_FMT, __func__, bev, old_fd, fd));
event_debug(("%s: cannot replace fd for %p from "EV_SOCK_FMT" to "EV_SOCK_FMT, __func__, (void *)bev, old_fd, fd));
BEV_UNLOCK(bev);

return err;
Expand All @@ -919,7 +919,7 @@ bufferevent_getfd(struct bufferevent *bev)
if (bev->be_ops->ctrl)
res = bev->be_ops->ctrl(bev, BEV_CTRL_GET_FD, &d);
if (res)
event_debug(("%s: cannot get fd for %p", __func__, bev));
event_debug(("%s: cannot get fd for %p", __func__, (void *)bev));
BEV_UNLOCK(bev);
return (res<0) ? -1 : d.fd;
}
Expand Down
30 changes: 15 additions & 15 deletions evdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ request_finished(struct request *const req, struct request **head, int free_hand
if (head)
evdns_request_remove(req, head);

log(EVDNS_LOG_DEBUG, "Removing timeout for request %p", req);
log(EVDNS_LOG_DEBUG, "Removing timeout for request %p", (void *)req);
if (was_inflight) {
evtimer_del(&req->timeout_event);
base->global_requests_inflight--;
Expand Down Expand Up @@ -1755,7 +1755,7 @@ server_send_response(struct evdns_server_port *port, struct server_request *req)
}

beferevent_error:
log(EVDNS_LOG_WARN, "Failed to send reply to request %p for client %p", req, req->client);
log(EVDNS_LOG_WARN, "Failed to send reply to request %p for client %p", (void *)req, (void *)req->client);
/* disconnect if we got bufferevent error */
evdns_remove_tcp_client(port, req->client);
return -1;
Expand Down Expand Up @@ -2196,7 +2196,7 @@ server_tcp_read_packet_cb(struct bufferevent *bev, void *ctx)

while (1) {
if (tcp_read_message(conn, &msg, &msg_len)) {
log(EVDNS_LOG_MSG, "Closing client connection %p due to error", bev);
log(EVDNS_LOG_MSG, "Closing client connection %p due to error", (void *)bev);
evdns_remove_tcp_client(port, client);
rc = port->refcnt;
EVDNS_UNLOCK(port);
Expand Down Expand Up @@ -2230,7 +2230,7 @@ server_tcp_event_cb(struct bufferevent *bev, short events, void *ctx)
EVUTIL_ASSERT(port && bev);
EVDNS_LOCK(port);
if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT)) {
log(EVDNS_LOG_DEBUG, "Closing connection %p", bev);
log(EVDNS_LOG_DEBUG, "Closing connection %p", (void *)bev);
evdns_remove_tcp_client(port, client);
}
rc = port->refcnt;
Expand All @@ -2250,7 +2250,7 @@ incoming_conn_cb(struct evconnlistener *listener, evutil_socket_t fd,

if (!bev)
goto error;
log(EVDNS_LOG_DEBUG, "New incoming client connection %p", bev);
log(EVDNS_LOG_DEBUG, "New incoming client connection %p", (void *)bev);

bufferevent_set_timeouts(bev, &port->tcp_idle_timeout, &port->tcp_idle_timeout);

Expand Down Expand Up @@ -2721,7 +2721,7 @@ retransmit_all_tcp_requests_for(struct nameserver *server)
if (req->ns == server && (req->handle->tcp_flags & DNS_QUERY_USEVC)) {
if (req->tx_count >= req->base->global_max_retransmits) {
log(EVDNS_LOG_DEBUG, "Giving up on request %p; tx_count==%d",
req, req->tx_count);
(void *)req, req->tx_count);
reply_schedule_callback(req, 0, DNS_ERR_TIMEOUT, NULL);
request_finished(req, &REQ_HEAD(req->base, req->trans_id), 1);
} else {
Expand Down Expand Up @@ -2843,7 +2843,7 @@ evdns_tcp_connect_if_disconnected(struct nameserver *server)
return 1;

conn->state = TS_CONNECTING;
log(EVDNS_LOG_DEBUG, "New tcp connection %p created", conn);
log(EVDNS_LOG_DEBUG, "New tcp connection %p created", (void *)conn);
return 0;
}

Expand Down Expand Up @@ -2893,7 +2893,7 @@ client_tcp_event_cb(struct bufferevent *bev, short events, void *ctx) {
EVDNS_LOCK(server->base);
EVUTIL_ASSERT(conn && conn->bev == bev && bev);

log(EVDNS_LOG_DEBUG, "Event %d on connection %p", events, conn);
log(EVDNS_LOG_DEBUG, "Event %d on connection %p", events, (void *)conn);

if (events & (BEV_EVENT_TIMEOUT)) {
disconnect_and_free_connection(server->connection);
Expand Down Expand Up @@ -2931,7 +2931,7 @@ evdns_request_transmit_through_tcp(struct request *req, struct nameserver *serve
conn = server->connection;
bufferevent_setcb(conn->bev, client_tcp_read_packet_cb, NULL, client_tcp_event_cb, server);

log(EVDNS_LOG_DEBUG, "Sending request %p via tcp connection %p", req, conn);
log(EVDNS_LOG_DEBUG, "Sending request %p via tcp connection %p", (void *)req, (void *)conn);
packet_size = htons(req->request_len);
if (bufferevent_write(conn->bev, &packet_size, sizeof(packet_size)) )
goto fail;
Expand All @@ -2944,7 +2944,7 @@ evdns_request_transmit_through_tcp(struct request *req, struct nameserver *serve

return 0;
fail:
log(EVDNS_LOG_WARN, "Failed to send request %p via tcp connection %p", req, conn);
log(EVDNS_LOG_WARN, "Failed to send request %p via tcp connection %p", (void *)req, (void *)conn);
disconnect_and_free_connection(server->connection);
server->connection = NULL;
return 2;
Expand Down Expand Up @@ -3006,11 +3006,11 @@ evdns_request_transmit(struct request *req) {
default:
/* all ok */
log(EVDNS_LOG_DEBUG,
"Setting timeout for request %p, sent to nameserver %p", req, req->ns);
"Setting timeout for request %p, sent to nameserver %p", (void *)req, (void *)req->ns);
if (evtimer_add(&req->timeout_event, &req->base->global_timeout) < 0) {
log(EVDNS_LOG_WARN,
"Error from libevent when adding timer for request %p",
req);
(void *)req);
/* ???? Do more? */
}
req->tx_count++;
Expand Down Expand Up @@ -3290,7 +3290,7 @@ evdns_nameserver_add_impl_(struct evdns_base *base, const struct sockaddr *addre
}

log(EVDNS_LOG_DEBUG, "Added nameserver %s as %p",
evutil_format_sockaddr_port_(address, addrbuf, sizeof(addrbuf)), ns);
evutil_format_sockaddr_port_(address, addrbuf, sizeof(addrbuf)), (void *)ns);

/* insert this nameserver into the list of them */
if (!base->server_head) {
Expand Down Expand Up @@ -5670,7 +5670,7 @@ evdns_getaddrinfo(struct evdns_base *dns_base,

if (hints.ai_family != PF_INET6) {
log(EVDNS_LOG_DEBUG, "Sending request for %s on ipv4 as %p",
nodename, &data->ipv4_request);
nodename, (void *)&data->ipv4_request);

data->ipv4_request.r = evdns_base_resolve_ipv4(dns_base,
nodename, 0, evdns_getaddrinfo_gotresolve,
Expand All @@ -5681,7 +5681,7 @@ evdns_getaddrinfo(struct evdns_base *dns_base,
}
if (hints.ai_family != PF_INET) {
log(EVDNS_LOG_DEBUG, "Sending request for %s on ipv6 as %p",
nodename, &data->ipv6_request);
nodename, (void *)&data->ipv6_request);

data->ipv6_request.r = evdns_base_resolve_ipv6(dns_base,
nodename, 0, evdns_getaddrinfo_gotresolve,
Expand Down
42 changes: 21 additions & 21 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static void event_debug_note_add_(const struct event *ev)
"%s: noting an add on a non-setup event %p"
" (events: 0x%x, fd: "EV_SOCK_FMT
", flags: 0x%x)",
__func__, ev, ev->ev_events,
__func__, (void *)ev, ev->ev_events,
EV_SOCK_ARG(ev->ev_fd), ev->ev_flags);
}
EVLOCK_UNLOCK(event_debug_map_lock_, 0);
Expand All @@ -328,7 +328,7 @@ static void event_debug_note_del_(const struct event *ev)
"%s: noting a del on a non-setup event %p"
" (events: 0x%x, fd: "EV_SOCK_FMT
", flags: 0x%x)",
__func__, ev, ev->ev_events,
__func__, (void *)ev, ev->ev_events,
EV_SOCK_ARG(ev->ev_fd), ev->ev_flags);
}
EVLOCK_UNLOCK(event_debug_map_lock_, 0);
Expand All @@ -352,7 +352,7 @@ static void event_debug_assert_is_setup_(const struct event *ev)
"%s called on a non-initialized event %p"
" (events: 0x%x, fd: "EV_SOCK_FMT
", flags: 0x%x)",
__func__, ev, ev->ev_events,
__func__, (void *)ev, ev->ev_events,
EV_SOCK_ARG(ev->ev_fd), ev->ev_flags);
}
EVLOCK_UNLOCK(event_debug_map_lock_, 0);
Expand All @@ -373,7 +373,7 @@ static void event_debug_assert_not_added_(const struct event *ev)
"%s called on an already added event %p"
" (events: 0x%x, fd: "EV_SOCK_FMT", "
"flags: 0x%x)",
__func__, ev, ev->ev_events,
__func__, (void *)ev, ev->ev_events,
EV_SOCK_ARG(ev->ev_fd), ev->ev_flags);
}
EVLOCK_UNLOCK(event_debug_map_lock_, 0);
Expand Down Expand Up @@ -1673,16 +1673,16 @@ event_process_active_single_queue(struct event_base *base,
event_del_nolock_(ev, EVENT_DEL_NOBLOCK);
event_debug((
"event_process_active: event: %p, %s%s%scall %p",
ev,
(void *)ev,
ev->ev_res & EV_READ ? "EV_READ " : " ",
ev->ev_res & EV_WRITE ? "EV_WRITE " : " ",
ev->ev_res & EV_CLOSED ? "EV_CLOSED " : " ",
ev->ev_callback));
(void *)ev->ev_callback));
} else {
event_queue_remove_active(base, evcb);
event_debug(("event_process_active: event_callback %p, "
"closure %d, call %p",
evcb, evcb->evcb_closure, evcb->evcb_cb_union.evcb_callback));
(void *)evcb, evcb->evcb_closure, (void *)evcb->evcb_cb_union.evcb_callback));
}

if (!(evcb->evcb_flags & EVLIST_INTERNAL))
Expand Down Expand Up @@ -2600,7 +2600,7 @@ event_remove_timer_nolock_(struct event *ev)
EVENT_BASE_ASSERT_LOCKED(base);
event_debug_assert_is_setup_(ev);

event_debug(("event_remove_timer_nolock: event: %p", ev));
event_debug(("event_remove_timer_nolock: event: %p", (void *)ev));

/* If it's not pending on a timeout, we don't need to do anything. */
if (ev->ev_flags & EVLIST_TIMEOUT) {
Expand Down Expand Up @@ -2647,13 +2647,13 @@ event_add_nolock_(struct event *ev, const struct timeval *tv,

event_debug((
"event_add: event: %p (fd "EV_SOCK_FMT"), %s%s%s%scall %p",
ev,
(void *)ev,
EV_SOCK_ARG(ev->ev_fd),
ev->ev_events & EV_READ ? "EV_READ " : " ",
ev->ev_events & EV_WRITE ? "EV_WRITE " : " ",
ev->ev_events & EV_CLOSED ? "EV_CLOSED " : " ",
tv ? "EV_TIMEOUT " : " ",
ev->ev_callback));
(void *)ev->ev_callback));

EVUTIL_ASSERT(!(ev->ev_flags & ~EVLIST_ALL));

Expand Down Expand Up @@ -2767,7 +2767,7 @@ event_add_nolock_(struct event *ev, const struct timeval *tv,

event_debug((
"event_add: event %p, timeout in %d seconds %d useconds, call %p",
ev, (int)tv->tv_sec, (int)tv->tv_usec, ev->ev_callback));
(void *)ev, (int)tv->tv_sec, (int)tv->tv_usec, (void *)ev->ev_callback));

#ifdef USE_REINSERT_TIMEOUT
event_queue_reinsert_timeout(base, ev, was_common, common_timeout, old_timeout_idx);
Expand Down Expand Up @@ -2854,7 +2854,7 @@ event_del_nolock_(struct event *ev, int blocking)
int res = 0, notify = 0;

event_debug(("event_del: %p (fd "EV_SOCK_FMT"), callback %p",
ev, EV_SOCK_ARG(ev->ev_fd), ev->ev_callback));
(void *)ev, EV_SOCK_ARG(ev->ev_fd), (void *)ev->ev_callback));

/* An event without a base has not been added */
if (ev->ev_base == NULL)
Expand Down Expand Up @@ -2962,7 +2962,7 @@ event_active_nolock_(struct event *ev, int res, short ncalls)
struct event_base *base;

event_debug(("event_active: %p (fd "EV_SOCK_FMT"), res %d, callback %p",
ev, EV_SOCK_ARG(ev->ev_fd), (int)res, ev->ev_callback));
(void *)ev, EV_SOCK_ARG(ev->ev_fd), (int)res, (void *)ev->ev_callback));

base = ev->ev_base;
EVENT_BASE_ASSERT_LOCKED(base);
Expand Down Expand Up @@ -3211,7 +3211,7 @@ timeout_next(struct event_base *base, struct timeval **tv_p)

EVUTIL_ASSERT(tv->tv_sec >= 0);
EVUTIL_ASSERT(tv->tv_usec >= 0);
event_debug(("timeout_next: event: %p, in %d seconds, %d useconds", ev, (int)tv->tv_sec, (int)tv->tv_usec));
event_debug(("timeout_next: event: %p, in %d seconds, %d useconds", (void *)ev, (int)tv->tv_sec, (int)tv->tv_usec));

out:
return (res);
Expand Down Expand Up @@ -3239,7 +3239,7 @@ timeout_process(struct event_base *base)
event_del_nolock_(ev, EVENT_DEL_NOBLOCK);

event_debug(("timeout_process: event: %p, call %p",
ev, ev->ev_callback));
(void *)ev, (void *)ev->ev_callback));
event_active_nolock_(ev, EV_TIMEOUT, 1);
}
}
Expand Down Expand Up @@ -3267,7 +3267,7 @@ event_queue_remove_inserted(struct event_base *base, struct event *ev)
EVENT_BASE_ASSERT_LOCKED(base);
if (EVUTIL_FAILURE_CHECK(!(ev->ev_flags & EVLIST_INSERTED))) {
event_errx(1, "%s: %p(fd "EV_SOCK_FMT") not on queue %x", __func__,
ev, EV_SOCK_ARG(ev->ev_fd), EVLIST_INSERTED);
(void *)ev, EV_SOCK_ARG(ev->ev_fd), EVLIST_INSERTED);
return;
}
DECR_EVENT_COUNT(base, ev->ev_flags);
Expand All @@ -3279,7 +3279,7 @@ event_queue_remove_active(struct event_base *base, struct event_callback *evcb)
EVENT_BASE_ASSERT_LOCKED(base);
if (EVUTIL_FAILURE_CHECK(!(evcb->evcb_flags & EVLIST_ACTIVE))) {
event_errx(1, "%s: %p not on queue %x", __func__,
evcb, EVLIST_ACTIVE);
(void *)evcb, EVLIST_ACTIVE);
return;
}
DECR_EVENT_COUNT(base, evcb->evcb_flags);
Expand All @@ -3295,7 +3295,7 @@ event_queue_remove_active_later(struct event_base *base, struct event_callback *
EVENT_BASE_ASSERT_LOCKED(base);
if (EVUTIL_FAILURE_CHECK(!(evcb->evcb_flags & EVLIST_ACTIVE_LATER))) {
event_errx(1, "%s: %p not on queue %x", __func__,
evcb, EVLIST_ACTIVE_LATER);
(void *)evcb, EVLIST_ACTIVE_LATER);
return;
}
DECR_EVENT_COUNT(base, evcb->evcb_flags);
Expand All @@ -3310,7 +3310,7 @@ event_queue_remove_timeout(struct event_base *base, struct event *ev)
EVENT_BASE_ASSERT_LOCKED(base);
if (EVUTIL_FAILURE_CHECK(!(ev->ev_flags & EVLIST_TIMEOUT))) {
event_errx(1, "%s: %p(fd "EV_SOCK_FMT") not on queue %x", __func__,
ev, EV_SOCK_ARG(ev->ev_fd), EVLIST_TIMEOUT);
(void *)ev, EV_SOCK_ARG(ev->ev_fd), EVLIST_TIMEOUT);
return;
}
DECR_EVENT_COUNT(base, ev->ev_flags);
Expand Down Expand Up @@ -3405,7 +3405,7 @@ event_queue_insert_inserted(struct event_base *base, struct event *ev)

if (EVUTIL_FAILURE_CHECK(ev->ev_flags & EVLIST_INSERTED)) {
event_errx(1, "%s: %p(fd "EV_SOCK_FMT") already inserted", __func__,
ev, EV_SOCK_ARG(ev->ev_fd));
(void *)ev, EV_SOCK_ARG(ev->ev_fd));
return;
}

Expand Down Expand Up @@ -3459,7 +3459,7 @@ event_queue_insert_timeout(struct event_base *base, struct event *ev)

if (EVUTIL_FAILURE_CHECK(ev->ev_flags & EVLIST_TIMEOUT)) {
event_errx(1, "%s: %p(fd "EV_SOCK_FMT") already on timeout", __func__,
ev, EV_SOCK_ARG(ev->ev_fd));
(void *)ev, EV_SOCK_ARG(ev->ev_fd));
return;
}

Expand Down
8 changes: 4 additions & 4 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ evhttp_parse_http_version(const char *version, struct evhttp_request *req)
int n = sscanf(version, "HTTP/%d.%d%c", &major, &minor, &ch);
if (n != 2 || major > 1) {
event_debug(("%s: bad version %s on message %p from %s",
__func__, version, req, req->remote_host));
__func__, version, (void *)req, req->remote_host));
return (-1);
}
req->major = major;
Expand Down Expand Up @@ -2014,7 +2014,7 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line, size_t len)

if (!type) {
event_debug(("%s: bad method %s on request %p from %s",
__func__, method, req, req->remote_host));
__func__, method, (void *)req, req->remote_host));
/* No error yet; we'll give a better error later when
* we see that req->type is unsupported. */
}
Expand Down Expand Up @@ -4433,15 +4433,15 @@ evhttp_request_set_on_complete_cb(struct evhttp_request *req,
const char *
evhttp_request_get_uri(const struct evhttp_request *req) {
if (req->uri == NULL)
event_debug(("%s: request %p has no uri\n", __func__, req));
event_debug(("%s: request %p has no uri\n", __func__, (void *)req));
return (req->uri);
}

const struct evhttp_uri *
evhttp_request_get_evhttp_uri(const struct evhttp_request *req) {
if (req->uri_elems == NULL)
event_debug(("%s: request %p has no uri elems\n",
__func__, req));
__func__, (void *)req));
return (req->uri_elems);
}

Expand Down
Loading

0 comments on commit b19af67

Please sign in to comment.