From 8318eeee1357e31e1c09f044a0362efe24b48b23 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 14 Feb 2020 08:26:39 +0100 Subject: [PATCH] Fix unverified sscanf result As reported by cppcheck: src/defi.c:41:7: style: Variable 're' is assigned a value that is never used. [unreadVariable] re = sscanf(buf, "%ld %ld", &one, &two); ^ --- src/defi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/defi.c b/src/defi.c index 83c5d36..c3d486b 100644 --- a/src/defi.c +++ b/src/defi.c @@ -1,6 +1,8 @@ /* vim: set sw=4 ts=4 si et: */ #include "defi.h" +#include +#include #define DEBUG 1 @@ -38,6 +40,10 @@ void defi_run(Defi_t * defi){ break; } else { re = sscanf(buf, "%ld %ld", &one, &two); + if (re < 0) { + printf("sscanf() failed: %s", strerror(errno)); + exit(1); + } pDEBUG("=== DEFI READING %ld %ld ===\n", one, two); defi->_list = connexcomponentlist_insert_edge(defi->_list, one, two);