From bfb33f2f46a40023aa9820f4cdd99281e41250c1 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 25 Nov 2016 18:30:41 +0100 Subject: common: Fix 'unchecked return code' warnings Several tools are simply not checking return code of functions marked with 'warn_unused_result'. Provide wrappers for the read/write functions to avoid patching old code and providing proper error handling. Fix the remaining ones (calls to fgets() and system()). Signed-off-by: Boris Brezillon --- nand-utils/nftldump.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'nand-utils/nftldump.c') diff --git a/nand-utils/nftldump.c b/nand-utils/nftldump.c index 32f4f2f..30332fe 100644 --- a/nand-utils/nftldump.c +++ b/nand-utils/nftldump.c @@ -39,6 +39,8 @@ #include #include +#include "common.h" + static struct NFTLMediaHeader MedHead[2]; static mtd_info_t meminfo; @@ -73,7 +75,7 @@ static unsigned int find_media_headers(void) NumMedHeads = 0; while (ofs < meminfo.size) { - pread(fd, &MedHead[NumMedHeads], sizeof(struct NFTLMediaHeader), ofs); + pread_nocheck(fd, &MedHead[NumMedHeads], sizeof(struct NFTLMediaHeader), ofs); if (!strncmp(MedHead[NumMedHeads].DataOrgID, "ANAND", 6)) { SWAP16(MedHead[NumMedHeads].NumEraseUnits); SWAP16(MedHead[NumMedHeads].FirstPhysicalEUN); @@ -93,7 +95,7 @@ static unsigned int find_media_headers(void) /* read BadUnitTable, I don't know why pread() does not work for larger (7680 bytes) chunks */ for (i = 0; i < MAX_ERASE_ZONES; i += 512) - pread(fd, &BadUnitTable[i], 512, ofs + 512 + i); + pread_nocheck(fd, &BadUnitTable[i], 512, ofs + 512 + i); } else printf("Second NFTL Media Header found at offset 0x%08lx\n",ofs); NumMedHeads++; @@ -233,10 +235,10 @@ static void dump_virtual_units(void) if (lastgoodEUN == 0xffff) memset(readbuf, 0, 512); else - pread(fd, readbuf, 512, + pread_nocheck(fd, readbuf, 512, (lastgoodEUN * ERASESIZE) + (j * 512)); - write(ofd, readbuf, 512); + write_nocheck(ofd, readbuf, 512); } } -- cgit v1.2.3