From patchwork Fri Nov 1 08:11:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178262 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp142900ill; Fri, 1 Nov 2019 01:13:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxP8YCbluXg2QeYFNtFaibiH1UE2sCPiPIr1wU6sz9KpB6BugpA99Z4CMe1Oj2ukUTugcR8 X-Received: by 2002:a50:9f65:: with SMTP id b92mr11107175edf.63.1572596034042; Fri, 01 Nov 2019 01:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572596034; cv=none; d=google.com; s=arc-20160816; b=I9NE3XdmAcYUF2XFBEsWfE1/3w3gSVEDRrcIFfqa3NFv/KJ7pWDR4RmB9MM/Q6AtFL KKo0uK2MXrEx6YxJAbqnHQn9w54lC/AJrm5SH0WtmdJ+Xj8shBsU3rkMVI+vM8bCyEkb 4NtcwXH2tE1XteSwMZcul+5/4WI2JrcYu+eX4LK16YSDK9WiluQhsFOMRnJn0qDobYVZ MaLgDK5L7TTNFNUEQ6EIEJdm+9tPaCWhu0dK8AucB6tw9K8PLoiLYkY2xkrygmLLwKsY HK+pe0k+4xOaKFeq888CIhV6L105PDHQfIa0ctuULjR2vEEgC/WRCseVLG3vDVv9KMbR R1wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=dMOvEpUrv3gUpGiwcs/+Eb8AZVQbVFB1v4ogmdr2bko=; b=ADEG110UW6q9DX4Uen5DuBeVX58PRQnu+kqYzYXR+4pZOY7CgE7XMzT8ilx8ZXZQ8O KoQJkyovV+Zq0AOmxDBjPs+yDfRoI0F6WWUY2eugE1zQlvbRVUVcaXX6zcXDIsUtZXrS TGYBFObAw8MvGcR3hvJJib0MyR21G4KE4e7Wx3A3IR31xSy4XlbL54nG7OWdrFUziD8/ pNA+3svTl7SRkhjeQxe0iCvM7fXn+4zMbYXau6DlDq8MieUvKIfK6uVm8oPzEW68LVMP I7pPerbhdkZq9gciqKsBHtWEKOSQKnk505DLoKV3BQ3kpPtnjeVvscIihrC6j/pjlEfx H7nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=24wqhJT7; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si5235312ejw.272.2019.11.01.01.13.53; Fri, 01 Nov 2019 01:13:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=24wqhJT7; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730276AbfKAINx (ORCPT + 8 others); Fri, 1 Nov 2019 04:13:53 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:32221 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730157AbfKAINx (ORCPT ); Fri, 1 Nov 2019 04:13:53 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id xA18BsBQ023869; Fri, 1 Nov 2019 17:11:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xA18BsBQ023869 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572595923; bh=dMOvEpUrv3gUpGiwcs/+Eb8AZVQbVFB1v4ogmdr2bko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=24wqhJT7RJMf50vgPNVtuOw7sfdCTIBCGMN1/+85H2fjdBWjCBMgKq4Gi/Zo8KO2Y VlgD461HyHetk8JzsJ7Ekalb9WtIQBjoIaG78+XXVkIjX89OQ/6jth0bvnMY7mY/Zy kZ1FsZLs884Twsxjffd5wE/JArN05kQGyzXNHNkQnzTcfwsuqyMuM02JwDm5mdrvDY 5imCL2rnn/7JQ+QTDtFB+kbwLTgcoxcrAjnIIPElUvBT0solhQTWvr+EhskjVm4OS1 vqipju34mMQPwLWkDveV8HSaTxr8C3ugI1gbtT2+b+racWCIlXeZnHt+T/q7S8T8kL VV3/6jEArBPKQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: devicetree@vger.kernel.org, Rob Herring , Frank Rowand Cc: linux-arm-kernel@lists.infradead.org, David Gibson , linuxppc-dev@lists.ozlabs.org, Masahiro Yamada , Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h Date: Fri, 1 Nov 2019 17:11:48 +0900 Message-Id: <20191101081148.23274-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101081148.23274-1-yamada.masahiro@socionext.com> References: <20191101081148.23274-1-yamada.masahiro@socionext.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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, 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 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 --- Changes in v2: - Fix ppc libfdt_env.h arch/powerpc/boot/libfdt_env.h | 2 ++ include/linux/libfdt_env.h | 3 +++ 2 files changed, 5 insertions(+) -- 2.17.1 diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h index 2abc8e83b95e..9757d4f6331e 100644 --- a/arch/powerpc/boot/libfdt_env.h +++ b/arch/powerpc/boot/libfdt_env.h @@ -6,6 +6,8 @@ #include #define INT_MAX ((int)(~0U>>1)) +#define UINT32_MAX ((u32)~0U) +#define INT32_MAX ((s32)(UINT32_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)