[Pdbg] [PATCH] Fix build failure in target detection

Joel Stanley joel at jms.id.au
Wed Oct 24 09:51:28 AEDT 2018


CI is failing to build:

 src/options_arm.c:65:3: error: ignoring return value of 'fscanf',
 declared with attribute warn_unused_result [-Werror=unused-result]
    fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If we don't get the expected value in fscanf, display an error. The
code already will do the correct thing and fall through to the unknown
device case.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
Error is at: https://openpower.xyz/job/openpower/job/pdbg-master/7/console

 src/options_arm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/options_arm.c b/src/options_arm.c
index 88cf9c92f491..0dbc7315f52d 100644
--- a/src/options_arm.c
+++ b/src/options_arm.c
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "main.h"
 
@@ -61,8 +62,11 @@ static const char *default_kernel_target(void)
 	cfam_id_file = fopen(FSI_CFAM_ID, "r");
 	if (cfam_id_file) {
 		uint32_t cfam_id = 0;
+		int rc;
 
-		fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id);
+		rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id);
+		if (rc != 1)
+			pdbg_log(PDBG_ERROR, "%s", strerror(errno));
 		fclose(cfam_id_file);
 
 		switch((cfam_id >> 4) & 0xff) {
-- 
2.19.1



More information about the Pdbg mailing list