]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
utils: successfully parse the string teminated by '\n'
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 22 Jun 2022 03:05:26 +0000 (12:05 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 22 Jun 2022 03:05:26 +0000 (12:05 +0900)
It requires to parse the literal from sysfs node.

Fixes: cc92f5ca9478 ("utils: add utility to compute integer value from string literal")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/utils/string.c

index fe0ab13c2706a500c2140276dc86f6e2761c3973..f04fb95674e4af949d6558e7db27a1fd71d10f4b 100644 (file)
@@ -13,7 +13,7 @@ long long_from_string(const char *literal, long *number)
     val = strtol(literal, &endptr, 10);
     if (errno > 0)
         return -errno;
-    if (!endptr || endptr == literal || *endptr != 0)
+    if (!endptr || endptr == literal || (*endptr != 0 && *endptr != '\n'))
         return -EINVAL;
     *number = val;
     return 0;