diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_alsa.c | 25 | ||||
-rw-r--r-- | channels/chan_dahdi.c | 14 | ||||
-rw-r--r-- | channels/chan_iax2.c | 26 | ||||
-rw-r--r-- | channels/chan_oss.c | 19 | ||||
-rw-r--r-- | channels/chan_skinny.c | 6 |
5 files changed, 62 insertions, 28 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index c45740ef1..eae5b6fa5 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -327,7 +327,9 @@ static void *sound_thread(void *unused) } #endif if (FD_ISSET(sndcmd[0], &rfds)) { - read(sndcmd[0], &cursound, sizeof(cursound)); + if (read(sndcmd[0], &cursound, sizeof(cursound)) < 0) { + ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); + } silencelen = 0; offset = 0; sampsent = 0; @@ -532,7 +534,9 @@ static int alsa_call(struct ast_channel *c, char *dest, int timeout) ast_queue_frame(alsa.owner, &f); ast_mutex_unlock(&alsa.owner->lock); } - write(sndcmd[1], &res, sizeof(res)); + if (write(sndcmd[1], &res, sizeof(res)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } } snd_pcm_prepare(alsa.icard); snd_pcm_start(alsa.icard); @@ -543,10 +547,12 @@ static int alsa_call(struct ast_channel *c, char *dest, int timeout) static void answer_sound(void) { int res; + nosound = 1; res = 4; - write(sndcmd[1], &res, sizeof(res)); - + if (write(sndcmd[1], &res, sizeof(res)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } } static int alsa_answer(struct ast_channel *c) @@ -576,7 +582,9 @@ static int alsa_hangup(struct ast_channel *c) if (!autoanswer) { /* Congestion noise */ res = 2; - write(sndcmd[1], &res, sizeof(res)); + if (write(sndcmd[1], &res, sizeof(res)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } } } snd_pcm_drop(alsa.icard); @@ -770,8 +778,11 @@ static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, s res = -1; } - if (res > -1) - write(sndcmd[1], &res, sizeof(res)); + if (res > -1) { + if (write(sndcmd[1], &res, sizeof(res)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } ast_mutex_unlock(&alsalock); diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index e3d73ac3f..4a26f6d36 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -8379,8 +8379,11 @@ static void dahdi_pri_message(struct pri *pri, char *s) ast_mutex_lock(&pridebugfdlock); - if (pridebugfd >= 0) - write(pridebugfd, s, strlen(s)); + if (pridebugfd >= 0) { + if (write(pridebugfd, s, strlen(s)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } ast_mutex_unlock(&pridebugfdlock); } @@ -8418,8 +8421,11 @@ static void dahdi_pri_error(struct pri *pri, char *s) ast_mutex_lock(&pridebugfdlock); - if (pridebugfd >= 0) - write(pridebugfd, s, strlen(s)); + if (pridebugfd >= 0) { + if (write(pridebugfd, s, strlen(s)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } ast_mutex_unlock(&pridebugfdlock); } diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 5d593dd0c..cdda03ad7 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -779,7 +779,7 @@ static void jb_error_output(const char *fmt, ...) vsnprintf(buf, 1024, fmt, args); va_end(args); - ast_log(LOG_ERROR, buf); + ast_log(LOG_ERROR, "%s", buf); } static void jb_warning_output(const char *fmt, ...) @@ -791,7 +791,7 @@ static void jb_warning_output(const char *fmt, ...) vsnprintf(buf, 1024, fmt, args); va_end(args); - ast_log(LOG_WARNING, buf); + ast_log(LOG_WARNING, "%s", buf); } static void jb_debug_output(const char *fmt, ...) @@ -803,7 +803,7 @@ static void jb_debug_output(const char *fmt, ...) vsnprintf(buf, 1024, fmt, args); va_end(args); - ast_verbose(buf); + ast_verbose("%s", buf); } /* XXX We probably should use a mutex when working with this XXX */ @@ -5864,9 +5864,13 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies) dp->flags |= matchmore; } /* Wake up waiters */ - for (x=0;x<sizeof(dp->waiters) / sizeof(dp->waiters[0]); x++) - if (dp->waiters[x] > -1) - write(dp->waiters[x], "asdf", 4); + for (x = 0; x < ARRAY_LEN(dp->waiters); x++) { + if (dp->waiters[x] > -1) { + if (write(dp->waiters[x], "asdf", 4) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } + } } prev = dp; dp = dp->peer; @@ -10503,9 +10507,13 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat /* Expire after only 60 seconds now. This is designed to help reduce backlog in heavily loaded systems without leaving it unavailable once the server comes back online */ dp->expiry.tv_sec = dp->orig.tv_sec + 60; - for (x=0;x<sizeof(dp->waiters) / sizeof(dp->waiters[0]); x++) - if (dp->waiters[x] > -1) - write(dp->waiters[x], "asdf", 4); + for (x = 0; x < ARRAY_LEN(dp->waiters); x++) { + if (dp->waiters[x] > -1) { + if (write(dp->waiters[x], "asdf", 4) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } + } } } /* Our caller will obtain the rest */ diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 7e27e7696..1a6cfd0b6 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -601,7 +601,8 @@ static void *sound_thread(void *arg) * Just in case, kick the driver by trying to read from it. * Ignore errors - this read is almost guaranteed to fail. */ - read(o->sounddev, ign, sizeof(ign)); + if (read(o->sounddev, ign, sizeof(ign)) < 0) { + } for (;;) { fd_set rfds, wfds; int maxfd, res; @@ -635,7 +636,10 @@ static void *sound_thread(void *arg) /* read which sound to play from the pipe */ int i, what = -1; - read(o->sndcmd[0], &what, sizeof(what)); + if (read(o->sndcmd[0], &what, sizeof(what)) != sizeof(what)) { + ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); + continue; + } for (i = 0; sounds[i].ind != -1; i++) { if (sounds[i].ind == what) { o->cursound = i; @@ -649,7 +653,8 @@ static void *sound_thread(void *arg) } if (o->sounddev > -1) { if (FD_ISSET(o->sounddev, &rfds)) /* read and ignore errors */ - read(o->sounddev, ign, sizeof(ign)); + if (read(o->sounddev, ign, sizeof(ign)) < 0) { + } if (FD_ISSET(o->sounddev, &wfds)) send_sound(o); } @@ -783,7 +788,9 @@ static int oss_text(struct ast_channel *c, const char *text) /* Play ringtone 'x' on device 'o' */ static void ring(struct chan_oss_pvt *o, int x) { - write(o->sndcmd[1], &x, sizeof(x)); + if (write(o->sndcmd[1], &x, sizeof(x)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } } @@ -1787,7 +1794,9 @@ static struct chan_oss_pvt *store_config(struct ast_config *cfg, char *ctg) asprintf(&cmd, "mixer %s", o->mixer_cmd); ast_log(LOG_WARNING, "running [%s]\n", cmd); - system(cmd); + if (system(cmd) < 0) { + ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno)); + } free(cmd); } if (o == &oss_default) /* we are done with the default */ diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 51b1839d5..657163398 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -3587,8 +3587,8 @@ static int handle_speed_dial_stat_req_message(struct skinny_req *req, struct ski return -1; req->data.speeddialreq.speedDialNumber = htolel(instance); - snprintf(req->data.speeddial.speedDialDirNumber, sizeof(req->data.speeddial.speedDialDirNumber), sd->exten); - snprintf(req->data.speeddial.speedDialDisplayName, sizeof(req->data.speeddial.speedDialDisplayName), sd->label); + ast_copy_string(req->data.speeddial.speedDialDirNumber, sd->exten, sizeof(req->data.speeddial.speedDialDirNumber)); + ast_copy_string(req->data.speeddial.speedDialDisplayName, sd->label, sizeof(req->data.speeddial.speedDialDisplayName)); transmit_response(s, req); return 1; @@ -3764,7 +3764,7 @@ static int handle_version_req_message(struct skinny_req *req, struct skinnysessi if (!(req = req_alloc(sizeof(struct version_res_message), VERSION_RES_MESSAGE))) return -1; - snprintf(req->data.version.version, sizeof(req->data.version.version), d->version_id); + ast_copy_string(req->data.version.version, d->version_id, sizeof(req->data.version.version)); transmit_response(s, req); return 1; } |