aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean McGovern <gseanmcg@gmail.com>2012-04-26 14:56:24 -0400
committerDiego Biurrun <diego@biurrun.de>2012-05-06 17:44:59 +0200
commitbe6009d32c1398b331a85a27984c287ba178b7a7 (patch)
treee4874109b888950c8caf8c29c0853e2ed785df57
parentd4ac703c7f5f024732be67ace1c8c62fba87360b (diff)
downloadffmpeg-be6009d32c1398b331a85a27984c287ba178b7a7.tar.gz
tests/utils: don't ignore the return value of fwrite()
Signed-off-by: Diego Biurrun <diego@biurrun.de>
-rw-r--r--tests/utils.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/utils.c b/tests/utils.c
index 2a85bd8e06..5310a114f5 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -16,13 +16,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#define SCALEBITS 8
#define ONE_HALF (1 << (SCALEBITS - 1))
#define FIX(x) ((int) ((x) * (1L << SCALEBITS) + 0.5))
+#define err_if(expr) do { \
+ if (expr) { \
+ fprintf(stderr, "%s\n", strerror(errno)); \
+ exit(1); \
+ } \
+} while (0)
+
static void rgb24_to_yuv420p(unsigned char *lum, unsigned char *cb,
unsigned char *cr, unsigned char *src,
int width, int height)
@@ -108,14 +117,14 @@ static void pgmyuv_save(const char *filename, int w, int h,
f = fopen(filename, "wb");
fprintf(f, "P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
- fwrite(lum_tab, 1, w * h, f);
+ err_if(fwrite(lum_tab, 1, w * h, f) != w * h);
h2 = h / 2;
w2 = w / 2;
cb = cb_tab;
cr = cr_tab;
for (i = 0; i < h2; i++) {
- fwrite(cb, 1, w2, f);
- fwrite(cr, 1, w2, f);
+ err_if(fwrite(cb, 1, w2, f) != w2);
+ err_if(fwrite(cr, 1, w2, f) != w2);
cb += w2;
cr += w2;
}