Fix issues found by cppcheck

- GNU treats void* as char* when doing pointer arithmetic, so let's make it clear
- Fix memory leak, save copy from malloc() and pass the original pointer to free()
- minor type mismatches

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong
2016-12-07 22:30:47 -06:00
committed by Max Lv
parent 8b358c59c7
commit baff29e970
6 changed files with 12 additions and 11 deletions
+3 -3
View File
@@ -529,7 +529,7 @@ connect_to_remote(EV_P_ struct addrinfo *res,
ERROR("bind_to_address");
close(sockfd);
return NULL;
}
}
#ifdef SET_INTERFACE
if (iface) {
@@ -542,7 +542,7 @@ connect_to_remote(EV_P_ struct addrinfo *res,
#endif
remote_t *remote = new_remote(sockfd);
#ifdef TCP_FASTOPEN
if (fast_open) {
#ifdef __APPLE__
@@ -1049,7 +1049,7 @@ block_list_clear_cb(EV_P_ ev_timer *watcher, int revents)
static void
server_timeout_cb(EV_P_ ev_timer *watcher, int revents)
{
server_ctx_t *server_ctx = (server_ctx_t *)(((void *)watcher)
server_ctx_t *server_ctx = (server_ctx_t *)(((char *)watcher)
- sizeof(ev_io));
server_t *server = server_ctx->server;
remote_t *remote = server->remote;