From 7e9d651b5f5b718a1f75ec32da3d1ea5e7e54816 Mon Sep 17 00:00:00 2001 From: Nick Kelsey Date: Mon, 8 Feb 2016 16:48:59 -0800 Subject: [PATCH] fix false-success bug in posix sock send code --- Makefile | 2 +- hdhomerun_sock_posix.c | 8 ++++---- hdhomerun_video.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2b7682d..20dc096 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ LIBSRCS += hdhomerun_video.c CC := $(CROSS_COMPILE)gcc STRIP := $(CROSS_COMPILE)strip -CFLAGS += -Wall -O2 -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith +CFLAGS += -O2 -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wno-unused-parameter LDFLAGS += -lpthread SHARED = -shared -Wl,-soname,libhdhomerun$(LIBEXT) diff --git a/hdhomerun_sock_posix.c b/hdhomerun_sock_posix.c index e93bebd..f81b254 100644 --- a/hdhomerun_sock_posix.c +++ b/hdhomerun_sock_posix.c @@ -347,7 +347,7 @@ bool_t hdhomerun_sock_send(struct hdhomerun_sock_t *sock, const void *data, size { const uint8_t *ptr = (const uint8_t *)data; ssize_t ret = send(sock->sock, ptr, length, MSG_NOSIGNAL); - if (ret >= length) { + if (ret >= (ssize_t)length) { return TRUE; } @@ -377,7 +377,7 @@ bool_t hdhomerun_sock_send(struct hdhomerun_sock_t *sock, const void *data, size } ret = send(sock->sock, ptr, length, MSG_NOSIGNAL); - if (ret >= length) { + if (ret >= (ssize_t)length) { return TRUE; } @@ -409,7 +409,7 @@ bool_t hdhomerun_sock_sendto(struct hdhomerun_sock_t *sock, uint32_t remote_addr const uint8_t *ptr = (const uint8_t *)data; ssize_t ret = sendto(sock->sock, ptr, length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr)); - if (ret >= length) { + if (ret >= (ssize_t)length) { return TRUE; } @@ -439,7 +439,7 @@ bool_t hdhomerun_sock_sendto(struct hdhomerun_sock_t *sock, uint32_t remote_addr } ret = sendto(sock->sock, ptr, length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr)); - if (ret >= length) { + if (ret >= (ssize_t)length) { return TRUE; } diff --git a/hdhomerun_video.c b/hdhomerun_video.c index 85c4dfd..80f5d64 100644 --- a/hdhomerun_video.c +++ b/hdhomerun_video.c @@ -236,7 +236,7 @@ static THREAD_FUNC_PREFIX hdhomerun_video_thread_execute(void *arg) if (length == VIDEO_RTP_DATA_PACKET_SIZE) { hdhomerun_video_parse_rtp(vs, pkt); - length = (int)(pkt->end - pkt->pos); + length = pkt->end - pkt->pos; } if (length != VIDEO_DATA_PACKET_SIZE) {