From 0a1fd4b8f7b253b81cb53f64574989d35e1ec24f Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Sat, 1 Jan 2022 17:57:55 +0100 Subject: [PATCH] Revert "src/topology/parser.c: drop duplicate safe_strtol_base" This reverts commit 47252054b4a2d5c8382cb1342f5d4eb89dabf95f. --- src/topology/parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/topology/parser.c b/src/topology/parser.c index e70173f6..01c95afa 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -21,6 +21,25 @@ #include "list.h" #include "tplg_local.h" +/* + * Safe strtol call + */ +int safe_strtol_base(const char *str, long *val, int base) +{ + char *end; + long v; + if (!*str) + return -EINVAL; + errno = 0; + v = strtol(str, &end, base); + if (errno) + return -errno; + if (*end) + return -EINVAL; + *val = v; + return 0; +} + /* * Get integer value */