Blame SOURCES/9dc0d66-ndctl-fix-static-analysis-report-unchecked-sscanf.patch
|
|
4e69d4 |
ndctl: fix static analysis report, unchecked sscanf
|
|
|
4e69d4 |
|
|
|
4e69d4 |
BZ:
|
|
|
4e69d4 |
|
|
|
4e69d4 |
commit 9dc0d660414d6da0f1cd89c80c94128b90603aa7
|
|
|
4e69d4 |
Author: Dan Williams <dan.j.williams@intel.com>
|
|
|
4e69d4 |
Date: Mon Oct 2 08:59:56 2017 -0700
|
|
|
4e69d4 |
|
|
|
4e69d4 |
ndctl: fix static analysis report, unchecked sscanf
|
|
|
4e69d4 |
|
|
|
4e69d4 |
Static analysis flags some occasions of unchecked sscanf return value.
|
|
|
4e69d4 |
|
|
|
4e69d4 |
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
|
|
|
4e69d4 |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
4e69d4 |
|
|
|
4e69d4 |
diff --git a/util/json.c b/util/json.c
|
|
|
4e69d4 |
index d1ee351..0c92c3b 100644
|
|
|
4e69d4 |
--- a/util/json.c
|
|
|
4e69d4 |
+++ b/util/json.c
|
|
|
4e69d4 |
@@ -374,11 +374,12 @@ static int compare_dimm_number(const void *p1, const void *p2)
|
|
|
4e69d4 |
const char *dimm2_name = ndctl_dimm_get_devname(dimm2);
|
|
|
4e69d4 |
int num1, num2;
|
|
|
4e69d4 |
|
|
|
4e69d4 |
- sscanf(dimm1_name, "nmem%d", &num1;;
|
|
|
4e69d4 |
- sscanf(dimm2_name, "nmem%d", &num2;;
|
|
|
4e69d4 |
+ if (sscanf(dimm1_name, "nmem%d", &num1) != 1)
|
|
|
4e69d4 |
+ num1 = 0;
|
|
|
4e69d4 |
+ if (sscanf(dimm2_name, "nmem%d", &num2) != 1)
|
|
|
4e69d4 |
+ num2 = 0;
|
|
|
4e69d4 |
|
|
|
4e69d4 |
return num1 - num2;
|
|
|
4e69d4 |
-
|
|
|
4e69d4 |
}
|
|
|
4e69d4 |
|
|
|
4e69d4 |
static struct json_object *badblocks_to_jdimms(struct ndctl_region *region,
|