From 37dff886f4d7b4513bc2772b33455caf2a375065 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 19 Feb 2012 14:42:11 +0100 Subject: [PATCH] Fix warn_unused_result warning. A warning triggered by attribute warn_unused_result cannot be suppressed by casting the result to void. Properly check the return value and pass it to the caller. Fix the check for the number of bytes written. The return value of fread is the number of items written, not the number of bytes. Change-Id: I8c60e23ac549e22fd3f7dd5c51c5a8e6fc517cb1 --- uisimulator/common/stubs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index a8ee5fb5ff..2a81587d83 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -188,9 +188,15 @@ int storage_write_sectors(IF_MV2(int drive,) sprintf(name,"sector%lX.bin",start+i); f=fopen(name,"wb"); if (f) { - (void)fwrite(buf,512,1,f); + if(fwrite(buf,512,1,f) != 1) { + fclose(f); + return -1; + } fclose(f); } + else { + return -1; + } } return 0; } @@ -214,7 +220,7 @@ int storage_read_sectors(IF_MV2(int drive,) if (f) { ret = fread(buf,512,1,f); fclose(f); - if (ret != 512) + if (ret != 1) return -1; } }