[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191101061411.16988-4-yamada.masahiro@socionext.com>
Date: Fri, 1 Nov 2019 15:14:11 +0900
From: Masahiro Yamada <yamada.masahiro@...ionext.com>
To: devicetree@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>
Cc: linux-arm-kernel@...ts.infradead.org,
David Gibson <david@...son.dropbear.id.au>,
linuxppc-dev@...ts.ozlabs.org,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Michael Ellerman <mpe@...erman.id.au>,
Paul Mackerras <paulus@...ba.org>, linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h
The libfdt in the upstream DTC project added references to (U)INT32_MAX
by the following commits:
Commit 812b1956a076 ("libfdt: Tweak data handling to satisfy Coverity")
Commit 7fcf8208b8a9 ("libfdt: add fdt_append_addrrange()")
The kernel needs to adjust libfdt_env.h before pulling in the changes.
As for the user-space programs, <stdint.h> defines (U)INT32_MAX along
with (u)int32_t.
In the kernel, on the other hand, we usually use s32 / u32 instead of
(u)int32_t for the fixed-width types.
Accordingly, we already have S32_MAX / U32_MAX for their max values.
So, we won't add (U)INT32_MAX to <linux/limits.h> any more.
Instead, add them to the in-kernel libfdt_env.h to compile fdt.c and
fdt_addresses.c
Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
---
arch/powerpc/boot/libfdt_env.h | 2 ++
include/linux/libfdt_env.h | 3 +++
2 files changed, 5 insertions(+)
diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h
index 2abc8e83b95e..a4a386114ef5 100644
--- a/arch/powerpc/boot/libfdt_env.h
+++ b/arch/powerpc/boot/libfdt_env.h
@@ -6,6 +6,8 @@
#include <string.h>
#define INT_MAX ((int)(~0U>>1))
+#define INT32_MAX ((u32)~0U)
+#define UINT32_MAX ((s32)(INT_MAX >> 1))
#include "of.h"
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
index edb0f0c30904..0bd83bdb2482 100644
--- a/include/linux/libfdt_env.h
+++ b/include/linux/libfdt_env.h
@@ -11,6 +11,9 @@ typedef __be16 fdt16_t;
typedef __be32 fdt32_t;
typedef __be64 fdt64_t;
+#define INT32_MAX S32_MAX
+#define UINT32_MAX U32_MAX
+
#define fdt32_to_cpu(x) be32_to_cpu(x)
#define cpu_to_fdt32(x) cpu_to_be32(x)
#define fdt64_to_cpu(x) be64_to_cpu(x)
--
2.17.1
Powered by blists - more mailing lists