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
This commit is contained in:
parent
2dbb17d0d6
commit
37dff886f4
1 changed files with 8 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue