]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
libfdt: fix error code of fdt_count_strings()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 14 Jul 2015 16:08:44 +0000 (01:08 +0900)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:34:20 +0000 (13:34 +0200)
Currently, this function returns a positive value on error,
so we never know whether this function has succeeded or failed.

For example, if the given property is not found, fdt_getprop()
returns -FDT_ERR_NOTFOUND, and then this function inverts it,
i.e., returns FDT_ERR_NOTFOUND (=1).

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Fixes: bc4147ab2d69 ("fdt: Add a function to count strings")
Acked-by: Simon Glass <sjg@chromium.org>
lib/libfdt/fdt_ro.c

index 38bfcbdcd53d2b4d150b429e6fe38ddbfb1a91a4..7b0777b67eb3cbb92609ae81366ef4bf66d1944b 100644 (file)
@@ -517,7 +517,7 @@ int fdt_count_strings(const void *fdt, int node, const char *property)
 
        list = fdt_getprop(fdt, node, property, &length);
        if (!list)
-               return -length;
+               return length;
 
        for (i = 0; i < length; i++) {
                int len = strlen(list);