mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
cleanup: Fix fread() and fwrite() error handling
Cleaned up some of the incorrect uses of fread() and fwrite(), mostly in the format modules. Neither of these functions will ever return a value less than 0, which we were checking for in some cases. I've introduced a fair amount of duplication in the format modules, but I plan to change how format modules work internally in a subsequent patch set, so this is simply a stop-gap. Change-Id: I8ca1cd47c20b2c0b72088bd13b9046f6977aa872
This commit is contained in:
@@ -181,10 +181,10 @@ static int ogg_vorbis_rewrite(struct ast_filestream *s,
|
||||
while (!tmp->eos) {
|
||||
if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
|
||||
break;
|
||||
if (!fwrite(tmp->og.header, 1, tmp->og.header_len, s->f)) {
|
||||
if (fwrite(tmp->og.header, 1, tmp->og.header_len, s->f) != tmp->og.header_len) {
|
||||
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
|
||||
}
|
||||
if (!fwrite(tmp->og.body, 1, tmp->og.body_len, s->f)) {
|
||||
if (fwrite(tmp->og.body, 1, tmp->og.body_len, s->f) != tmp->og.body_len) {
|
||||
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
|
||||
}
|
||||
if (ogg_page_eos(&tmp->og))
|
||||
@@ -211,10 +211,10 @@ static void write_stream(struct ogg_vorbis_desc *s, FILE *f)
|
||||
if (ogg_stream_pageout(&s->os, &s->og) == 0) {
|
||||
break;
|
||||
}
|
||||
if (!fwrite(s->og.header, 1, s->og.header_len, f)) {
|
||||
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
|
||||
if (fwrite(s->og.header, 1, s->og.header_len, f) != s->og.header_len) {
|
||||
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
|
||||
}
|
||||
if (!fwrite(s->og.body, 1, s->og.body_len, f)) {
|
||||
if (fwrite(s->og.body, 1, s->og.body_len, f) != s->og.body_len) {
|
||||
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
|
||||
}
|
||||
if (ogg_page_eos(&s->og)) {
|
||||
|
Reference in New Issue
Block a user