diff options
author | zfl9 <zfl9.com@gmail.com> | 2020-03-07 16:13:34 +0800 |
---|---|---|
committer | zfl9 <zfl9.com@gmail.com> | 2020-03-07 16:13:34 +0800 |
commit | 924650039110ed1b7725e290d67740c8fe2bcbe0 (patch) | |
tree | e3176c078c9f958ea6e9979542285aa1ac548441 | |
parent | remove `-no-pie` gcc option (diff) | |
download | dns2tcp-924650039110ed1b7725e290d67740c8fe2bcbe0.tar.gz dns2tcp-924650039110ed1b7725e290d67740c8fe2bcbe0.tar.bz2 dns2tcp-924650039110ed1b7725e290d67740c8fe2bcbe0.zip |
suppress gcc warning in code
-rw-r--r-- | dns2tcp.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -390,7 +390,8 @@ static void udp_recvmsg_cb(evloop_t *evloop, evio_t *watcher __attribute__((unus parse_socket_addr(&tcpw->srcaddr, g_ipstr_buf, &portno); LOGINF("[udp_recvmsg_cb] recv from %s#%hu, nrecv:%zd", g_ipstr_buf, portno, nrecv); } - *(uint16_t *)tcpw->buffer = htons(nrecv); + uint16_t *msglen_ptr = (void *)tcpw->buffer; + *msglen_ptr = htons(nrecv); /* msg length */ nrecv += 2; /* msglen + msgbuf */ tcpw->nrcvsnd = 0; @@ -457,7 +458,8 @@ static void tcp_connect_cb(evloop_t *evloop, evio_t *watcher, int events __attri static void tcp_sendmsg_cb(evloop_t *evloop, evio_t *watcher, int events __attribute__((unused))) { tcpwatcher_t *tcpw = (void *)watcher; - uint16_t datalen = 2 + ntohs(*(uint16_t *)tcpw->buffer); + uint16_t *msglen_ptr = (void *)tcpw->buffer; + uint16_t datalen = 2 + ntohs(*msglen_ptr); ssize_t nsend = send(watcher->fd, (void *)tcpw->buffer + tcpw->nrcvsnd, datalen - tcpw->nrcvsnd, 0); if (nsend < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) return; |