From f726f119740373a01bef6e26e5c1f02dd277033f 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 --- codecs/codec_dahdi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'codecs') diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c index f207b6486..edf5038ca 100644 --- a/codecs/codec_dahdi.c +++ b/codecs/codec_dahdi.c @@ -615,7 +615,6 @@ static int dahdi_translate(struct ast_trans_pvt *pvt, uint32_t dst_dahdi_fmt, ui /* Request translation through zap if possible */ int fd; struct codec_dahdi_pvt *dahdip = pvt->pvt; - int flags; int tried_once = 0; const char *dev_filename = "/dev/dahdi/transcode"; @@ -661,11 +660,7 @@ retry: return -1; } - flags = fcntl(fd, F_GETFL); - if (flags > - 1) { - if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) - ast_log(LOG_WARNING, "Could not set non-block mode!\n"); - } + ast_fd_set_flags(fd, O_NONBLOCK); dahdip->fd = fd; -- cgit v1.2.3