From 2ffe52a116ad05d060cbedda93c48cf5a4415ca3 Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Thu, 7 Dec 2017 10:52:39 -0500 Subject: utils: Add convenience function for setting fd flags There are many places in the code base where we ignore the return value of fcntl() when getting/setting file descriptior flags. This patch introduces a convenience function that allows setting or clearing file descriptor flags and will also log an error on failure for later analysis. Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7 --- channels/chan_phone.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'channels/chan_phone.c') diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 76891ac98..832f28b49 100644 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -1191,7 +1191,6 @@ static struct phone_pvt *mkif(const char *iface, int mode, int txgain, int rxgai { /* Make a phone_pvt structure for this interface */ struct phone_pvt *tmp; - int flags; tmp = ast_calloc(1, sizeof(*tmp)); if (tmp) { @@ -1224,8 +1223,7 @@ static struct phone_pvt *mkif(const char *iface, int mode, int txgain, int rxgai ioctl(tmp->fd, PHONE_VAD, tmp->silencesupression); #endif tmp->mode = mode; - flags = fcntl(tmp->fd, F_GETFL); - fcntl(tmp->fd, F_SETFL, flags | O_NONBLOCK); + ast_fd_set_flags(tmp->fd, O_NONBLOCK); tmp->owner = NULL; ao2_cleanup(tmp->lastformat); tmp->lastformat = NULL; -- cgit v1.2.3