Commit 2eac35d4 authored by conrad's avatar conrad

Fix compile warnings on fwrite returns etc. throughout

parent 78667863
......@@ -133,14 +133,16 @@ write_page (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
}
/* Write out this page, but no following ones */
fwrite (og->header, 1, og->header_len, fixer->out);
fwrite (og->body, 1, og->body_len, fixer->out);
if (fwrite (og->header, 1, og->header_len, fixer->out) == (size_t)og->header_len)
if (fwrite (og->body, 1, og->body_len, fixer->out) != (size_t)og->body_len)
return -1;
data->discarding = 1;
}
if(!data->discarding) {
fwrite (og->header, 1, og->header_len, fixer->out);
fwrite (og->body, 1, og->body_len, fixer->out);
if (fwrite (og->header, 1, og->header_len, fixer->out) == (size_t)og->header_len)
if (fwrite (og->body, 1, og->body_len, fixer->out) != (size_t)og->body_len)
return -1;
}
return 0;
......
......@@ -52,8 +52,9 @@ read_page (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
{
MHData * mhdata = (MHData *)user_data;
fwrite (og->header, 1, og->header_len, mhdata->outfile);
fwrite (og->body, 1, og->body_len, mhdata->outfile);
if (fwrite (og->header, 1, og->header_len, mhdata->outfile) == (size_t)og->header_len)
if (fwrite (og->body, 1, og->body_len, mhdata->outfile) != (size_t)og->body_len)
return OGGZ_STOP_ERR;
return OGGZ_CONTINUE;
}
......@@ -151,7 +152,8 @@ main (int argc, char ** argv)
oggz_set_read_callback (mhdata.reader, -1, read_packet, &mhdata);
while ((n = oggz_read (mhdata.reader, 1024)) > 0) {
while (oggz_write_output (mhdata.writer, buf, n) > 0) {
fwrite (buf, 1, n, mhdata.outfile);
if (fwrite (buf, 1, n, mhdata.outfile) != (size_t)n)
break;
}
}
......
......@@ -43,8 +43,9 @@ read_page (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
oggz_table_insert (tracks, serialno, NULL);
}
fwrite (og->header, 1, og->header_len, stdout);
fwrite (og->body, 1, og->body_len, stdout);
if (fwrite (og->header, 1, og->header_len, stdout) == (size_t)og->header_len)
if (fwrite (og->body, 1, og->body_len, stdout) != (size_t)og->body_len)
return OGGZ_STOP_ERR;
return 0;
}
......
......@@ -34,6 +34,8 @@
#include "oggz_private.h"
#include <oggz/oggz_stream.h>
static ogg_int64_t
oggz_metric_dirac (OGGZ * oggz, long serialno,
ogg_int64_t granulepos, void * user_data)
......
......@@ -215,7 +215,8 @@ test_flushing (int flush, char * filename)
if (filename != NULL) {
FILE * f;
f = fopen (filename, "w");
fwrite (data_buf, 1, n, f);
if (fwrite (data_buf, 1, n, f) < (size_t)n)
FAIL("Unable to write generated stream to file");
fclose (f);
}
......
......@@ -185,17 +185,20 @@ _ogg_page_set_eos (const ogg_page * og)
if (og == NULL) return;
og->header[5] |= 0x04;
ogg_page_checksum_set (OGG_PAGE_CONST(og));
ogg_page_checksum_set ((ogg_page *)og);
}
static void
fwrite_ogg_page (OCState * state, const ogg_page * og)
{
size_t n;
if (og == NULL) return;
if (!state->dry_run) {
fwrite (og->header, 1, og->header_len, state->outfile);
fwrite (og->body, 1, og->body_len, state->outfile);
n = fwrite (og->header, 1, og->header_len, state->outfile);
if (n == (size_t)og->header_len)
n = fwrite (og->body, 1, og->body_len, state->outfile);
}
}
......
......@@ -255,9 +255,11 @@ static int
read_page (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
{
OCData * ocdata = (OCData *)user_data;
size_t n;
fwrite (og->header, 1, og->header_len, ocdata->outfile);
fwrite (og->body, 1, og->body_len, ocdata->outfile);
n = fwrite (og->header, 1, og->header_len, ocdata->outfile);
if (n == (size_t)og->header_len)
n = fwrite (og->body, 1, og->body_len, ocdata->outfile);
return OGGZ_CONTINUE;
}
......@@ -340,7 +342,8 @@ edit_comments (OCData * ocdata, char * outfilename)
while ((n = oggz_read (ocdata->reader, 1024)) > 0) {
long nn;
while ((nn=oggz_write_output (ocdata->writer, buf, n)) > 0) {
fwrite (buf, 1, nn, ocdata->outfile);
if (fwrite (buf, 1, nn, ocdata->outfile) < (size_t)nn)
break;
}
}
......
......@@ -370,7 +370,8 @@ revert_packet (OGGZ * oggz, ogg_packet * op, long serialno, int flush)
}
while ((n = oggz_write_output (oggz, buf, 1024)) > 0) {
fwrite (buf, 1, n, outfile);
if (fwrite (buf, 1, n, outfile) < (size_t)n)
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment