ref: bbcc1334e0b4d1b58b7ee679b296a8e8eb1bf8fd
parent: d8a4fc5b2a332d0e03294c2ad170663df0482e07
author: Ralph Giles <giles@mozilla.com>
date: Fri Aug 24 12:17:16 EDT 2012
Check the return value of fwrite. Fixes a gcc warning.
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -133,6 +133,7 @@
int ogg_write(state *params)
{
ogg_page page;
+ size_t written;
if (!params || !params->stream || !params->out) {
return -1;
@@ -139,8 +140,16 @@
}
while (ogg_stream_pageout(params->stream, &page)) {
- fwrite(page.header, 1, page.header_len, params->out);
- fwrite(page.body, 1, page.body_len, params->out);
+ written = fwrite(page.header, 1, page.header_len, params->out);
+ if (written != page.header_len) {
+ fprintf(stderr, "Error writing Ogg page header\n");
+ return -2;
+ }
+ written = fwrite(page.body, 1, page.body_len, params->out);
+ if (written != page.body_len) {
+ fprintf(stderr, "Error writing Ogg page body\n");
+ return -3;
+ }
}
return 0;
@@ -150,6 +159,7 @@
int ogg_flush(state *params)
{
ogg_page page;
+ size_t written;
if (!params || !params->stream || !params->out) {
return -1;
@@ -156,8 +166,16 @@
}
while (ogg_stream_flush(params->stream, &page)) {
- fwrite(page.header, 1, page.header_len, params->out);
- fwrite(page.body, 1, page.body_len, params->out);
+ written = fwrite(page.header, 1, page.header_len, params->out);
+ if (written != page.header_len) {
+ fprintf(stderr, "Error writing Ogg page header\n");
+ return -2;
+ }
+ written = fwrite(page.body, 1, page.body_len, params->out);
+ if (written != page.body_len) {
+ fprintf(stderr, "Error writing Ogg page body\n");
+ return -3;
+ }
}
return 0;