summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Meerwald-Stadler <pmeerw@pmeerw.net>2017-03-07 14:29:12 +0100
committerPeter Meerwald-Stadler <pmeerw@pmeerw.net>2017-03-08 14:31:29 +0100
commit74abce331b8423219911de33f99c0870f871633d (patch)
tree9b2db8142cb22837dd8beeed81e38e35ff11bb12
parent6b7b70c47298bf76d4509e85658b37c2b1f67378 (diff)
raop: Fix check for invalid file descriptor
file descriptor 0 is valid Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
-rw-r--r--src/modules/raop/raop-client.c30
-rw-r--r--src/modules/raop/raop-sink.c2
2 files changed, 16 insertions, 16 deletions
diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 1bd4c4a0..f23cf93a 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -968,10 +968,10 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
break;
annonce_error:
- if (c->udp_cfd > 0)
+ if (c->udp_cfd >= 0)
pa_close(c->udp_cfd);
c->udp_cfd = -1;
- if (c->udp_tfd > 0)
+ if (c->udp_tfd >= 0)
pa_close(c->udp_tfd);
c->udp_tfd = -1;
@@ -1073,11 +1073,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
break;
setup_error:
- if (c->tcp_sfd > 0)
+ if (c->tcp_sfd >= 0)
pa_close(c->tcp_sfd);
c->tcp_sfd = -1;
- if (c->udp_sfd > 0)
+ if (c->udp_sfd >= 0)
pa_close(c->udp_sfd);
c->udp_sfd = -1;
@@ -1135,11 +1135,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
case STATE_TEARDOWN: {
pa_log_debug("RAOP: TEARDOWN");
- if (c->tcp_sfd > 0)
+ if (c->tcp_sfd >= 0)
pa_close(c->tcp_sfd);
c->tcp_sfd = -1;
- if (c->udp_sfd > 0)
+ if (c->udp_sfd >= 0)
pa_close(c->udp_sfd);
c->udp_sfd = -1;
@@ -1163,11 +1163,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
c->is_recording = false;
- if (c->tcp_sfd > 0)
+ if (c->tcp_sfd >= 0)
pa_close(c->tcp_sfd);
c->tcp_sfd = -1;
- if (c->udp_sfd > 0)
+ if (c->udp_sfd >= 0)
pa_close(c->udp_sfd);
c->udp_sfd = -1;
@@ -1507,11 +1507,11 @@ bool pa_raop_client_is_alive(pa_raop_client *c) {
switch (c->protocol) {
case PA_RAOP_PROTOCOL_TCP:
- if (c->tcp_sfd > 0)
+ if (c->tcp_sfd >= 0)
return true;
break;
case PA_RAOP_PROTOCOL_UDP:
- if (c->udp_sfd > 0)
+ if (c->udp_sfd >= 0)
return true;
break;
default:
@@ -1531,11 +1531,11 @@ bool pa_raop_client_can_stream(pa_raop_client *c) {
switch (c->protocol) {
case PA_RAOP_PROTOCOL_TCP:
- if (c->tcp_sfd > 0 && c->is_recording)
+ if (c->tcp_sfd >= 0 && c->is_recording)
return true;
break;
case PA_RAOP_PROTOCOL_UDP:
- if (c->udp_sfd > 0 && c->is_recording)
+ if (c->udp_sfd >= 0 && c->is_recording)
return true;
break;
default:
@@ -1557,14 +1557,14 @@ int pa_raop_client_stream(pa_raop_client *c) {
switch (c->protocol) {
case PA_RAOP_PROTOCOL_TCP:
- if (c->tcp_sfd > 0 && !c->is_recording) {
+ if (c->tcp_sfd >= 0 && !c->is_recording) {
c->is_recording = true;
c->is_first_packet = true;
c->sync_count = 0;
}
break;
case PA_RAOP_PROTOCOL_UDP:
- if (c->udp_sfd > 0 && !c->is_recording) {
+ if (c->udp_sfd >= 0 && !c->is_recording) {
c->is_recording = true;
c->is_first_packet = true;
c->sync_count = 0;
@@ -1722,7 +1722,7 @@ pa_volume_t pa_raop_client_adjust_volume(pa_raop_client *c, pa_volume_t volume)
void pa_raop_client_handle_oob_packet(pa_raop_client *c, const int fd, const uint8_t packet[], ssize_t size) {
pa_assert(c);
- pa_assert(fd > 0);
+ pa_assert(fd >= 0);
pa_assert(packet);
if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index d321a2d2..c5ff8b9c 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -247,7 +247,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
if (u->rtpoll_item) {
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, &nbfds);
for (i = 0; i < nbfds; i++) {
- if (pollfd && pollfd->fd > 0)
+ if (pollfd && pollfd->fd >= 0)
pa_close(pollfd->fd);
pollfd++;
}