From 73bab8e1a1dd93a90ffb5a39e4dc91f194a2f063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Mon, 20 May 2019 16:34:09 +0200 Subject: [PATCH] zpcictl: Fix compile warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zpcictl.c: In function ‘sysfs_read_value’: zpcictl.c:154:2: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] fscanf(fp, "%x", &val); ^~~~~~~~~~~~~~~~~~~~~~ Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner --- zpcictl/zpcictl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zpcictl/zpcictl.c b/zpcictl/zpcictl.c index 7683e942..1c13ae01 100644 --- a/zpcictl/zpcictl.c +++ b/zpcictl/zpcictl.c @@ -151,7 +151,12 @@ static unsigned int sysfs_read_value(struct zpci_device *pdev, const char *attr) fp = fopen(path, "r"); if (!fp) fopen_err(path); - fscanf(fp, "%x", &val); + if (fscanf(fp, "%x", &val) != 1) { + fclose(fp); + warnx("Could not read file %s: %s", path, strerror(errno)); + free(path); + exit(EXIT_FAILURE); + } fclose(fp); free(path);