pipewire: module-pipe-tunnel: accept file descriptor 0

As Coverity points out, `open()` returning 0 is not an error,
it should be handled just like any other valid file descriptor.
This commit is contained in:
Barnabás Pőcze 2022-06-16 17:54:18 +02:00
parent 96d0902dc8
commit 84c01bb0bc

View file

@ -377,7 +377,7 @@ static int create_fifo(struct impl *impl)
do_unlink_fifo = true; do_unlink_fifo = true;
} }
if ((fd = open(filename, O_RDWR | O_CLOEXEC | O_NONBLOCK, 0)) <= 0) { if ((fd = open(filename, O_RDWR | O_CLOEXEC | O_NONBLOCK, 0)) < 0) {
res = -errno; res = -errno;
pw_log_error("open('%s'): %s", filename, spa_strerror(res)); pw_log_error("open('%s'): %s", filename, spa_strerror(res));
goto error; goto error;
@ -408,7 +408,7 @@ static int create_fifo(struct impl *impl)
error: error:
if (do_unlink_fifo) if (do_unlink_fifo)
unlink(filename); unlink(filename);
if (fd > 0) if (fd >= 0)
close(fd); close(fd);
return res; return res;
} }
@ -453,7 +453,7 @@ static void impl_destroy(struct impl *impl)
unlink(impl->filename); unlink(impl->filename);
free(impl->filename); free(impl->filename);
} }
if (impl->fd > 0) if (impl->fd >= 0)
close(impl->fd); close(impl->fd);
pw_properties_free(impl->stream_props); pw_properties_free(impl->stream_props);