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 --- misc-utils/docfdisk.c | 6 +++++- misc-utils/ftl_check.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'misc-utils') diff --git a/misc-utils/docfdisk.c b/misc-utils/docfdisk.c index 9956de5..b363662 100644 --- a/misc-utils/docfdisk.c +++ b/misc-utils/docfdisk.c @@ -275,7 +275,11 @@ int main(int argc, char **argv) show_header(mhoffs); printf("\nReady to update device. Type 'yes' to proceed, anything else to abort: "); - fgets(line, sizeof(line), stdin); + if (!fgets(line, sizeof(line), stdin)) { + printf("Failed to retrieve input chars!\n"); + return 1; + } + if (strcmp("yes\n", line)) return 0; printf("Updating MediaHeader...\n"); diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c index d7d2e8b..970d968 100644 --- a/misc-utils/ftl_check.c +++ b/misc-utils/ftl_check.c @@ -95,7 +95,7 @@ static void check_partition(int fd) perror("seek failed"); break; } - read(fd, &hdr, sizeof(hdr)); + read_nocheck(fd, &hdr, sizeof(hdr)); if ((le32_to_cpu(hdr.FormattedSize) > 0) && (le32_to_cpu(hdr.FormattedSize) <= mtd.size) && (le16_to_cpu(hdr.NumEraseUnits) > 0) && -- cgit v1.2.3