From nobody Fri Nov 29 02:51:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1650653596; cv=none; d=zohomail.com; s=zohoarc; b=lx9OilfY4Oa/uYpJZkcV8pZ1Rs2uP6l1/gqJaOZaHQlte+QKnI2ENBeSGX65adToC3XTI0WdqEVJBnztMdiA0sTJoW7TbE8b60XRcxNw1x3l5HKKxwVCdfYhHjWRxAfAikEvx56UeJEmKRemqFE+JkI7Nmk3755chWt2maLCO0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650653596; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=MzQpyWVGd6/oj99QHSaMNGw4bNEHQuphO4N+La1lNXc=; b=OxiRUep0xcWcVrDhdRbMvyoqc3+SdsHm8qEABX9tey+78Jw5z47iJI2sHKLwbQIpnpvkDvBDAw1cJbJ18HlWSxdda5ruJptYpr6R0dIJeahB11nAnt3M1iKOSya58gAPu3cgUxhXiib3VcNczXI52Ppe5Bh8OwrotoPR+Nx5dKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1650653596729725.766398793845; Fri, 22 Apr 2022 11:53:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.311187.528276 (Exim 4.92) (envelope-from ) id 1nhyOn-0002NC-3K; Fri, 22 Apr 2022 18:52:57 +0000 Received: by outflank-mailman (output) from mailman id 311187.528276; Fri, 22 Apr 2022 18:52:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhyOn-0002N5-0I; Fri, 22 Apr 2022 18:52:57 +0000 Received: by outflank-mailman (input) for mailman id 311187; Fri, 22 Apr 2022 18:52:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhyOl-0002Mx-Vz for xen-devel@lists.xenproject.org; Fri, 22 Apr 2022 18:52:56 +0000 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [2607:f8b0:4864:20::62c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6ace17eb-c26d-11ec-8fc2-03012f2f19d4; Fri, 22 Apr 2022 20:52:55 +0200 (CEST) Received: by mail-pl1-x62c.google.com with SMTP id d15so12753266pll.10 for ; Fri, 22 Apr 2022 11:52:54 -0700 (PDT) Received: from localhost ([118.33.58.98]) by smtp.gmail.com with ESMTPSA id t9-20020a17090ad50900b001cd4989feecsm6645161pju.56.2022.04.22.11.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:52:53 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6ace17eb-c26d-11ec-8fc2-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=MzQpyWVGd6/oj99QHSaMNGw4bNEHQuphO4N+La1lNXc=; b=pFKtqZ49r5qs8C1gaNPeURj/UJk2+IJc6qFTyVxesaqzLOIfAu8bAhiuqTptbqr4IO Zkp/Oy4P0zdMrAp7MlF9tYcxrVDwZayGy5MeRjnYxo8ER2BJceqW+IPxqZ+IvWvmFoz6 eILK2+hqB569neFwydPKIrRoWsPwDx3u6+JKz2/imLxIa+j1sifsG+71LCOk0cwxx7U4 e5MURCz0NNHcg7wKWnYLH5mRcUS/vc9IIAbN5BkBrVtxj51UVFPAGnkgEk8SOiQmC8ZW PivSvkLvrQxLXzOy4ARofjxN5LLJK8LKxh0tycsZyjOAWnYUKlLC+U8HpMMlqjea01Dv 2w/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=MzQpyWVGd6/oj99QHSaMNGw4bNEHQuphO4N+La1lNXc=; b=yN+w6459F716/9OHXVopw5M28ZnNA2IZsIJCtUrA0myhwHeIoIPKsNQUB1Hk+im1s+ VjaG0UfrpcZem5cQpKC7K6CxH+hLWuGQN8Jk10Z60uIGQfdOhfwSnywvTkiZSnF2fyKA c26pAd/7xCnF5WQ7fs2M2wiLhBMyBtP8Hhfaf+Thf4Wm/LLZuoUFrLCb/uunRG3O3Qn3 XY/bMsSgAal9J/3Miq3xjiFy4SlmDgURSmOFq8dBE6OT05aKsY8v4vIf1M3wr1Lcp125 lSQXLrys54ej1hLmkO7C9I8XIVchow1vi3loIEESYkbkSZCGKiZGSagL40cqHxzjWYP4 VZiw== X-Gm-Message-State: AOAM5335eKp+Kv3PW8f/+q7rssR6nh9vM3GPvdmoE7oemjSkcAVpAzKu FYRKqBnv3JT99iCUClWgHXo= X-Google-Smtp-Source: ABdhPJzmQq+ytJJZZiySqbM4zWDZvMnW+Qy8paUr8NflAfoC+EJg8LPTKGbSwFuRFL7xwxeU8LemQw== X-Received: by 2002:a17:902:9001:b0:156:a567:2683 with SMTP id a1-20020a170902900100b00156a5672683mr5953430plp.164.1650653573442; Fri, 22 Apr 2022 11:52:53 -0700 (PDT) Date: Sat, 23 Apr 2022 03:52:51 +0900 From: Paran Lee To: Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Cc: Austin Kim , xen-devel@lists.xenproject.org Subject: [PATCH] xen/arm: fdt fix duplicated ternary operator, shift operations Message-ID: <20220422185251.GA7124@DESKTOP-NK4TH6S.localdomain> MIME-Version: 1.0 Content-Disposition: inline X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1650653598898100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It doesn't seem necessary to do duplicate ternary operation and calculation of order shift using fdt32_to_cpu macro. Signed-off-by: Paran Lee Reviewed-by: Stefano Stabellini --- xen/arch/arm/bootfdt.c | 12 ++++++++++-- xen/common/libfdt/fdt.c | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index e318ef9603..e5b885a7f2 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -159,8 +159,16 @@ int __init device_tree_for_each_node(const void *fdt, = int node, continue; } =20 - as =3D depth > 0 ? address_cells[depth-1] : DT_ROOT_NODE_ADDR_CELL= S_DEFAULT; - ss =3D depth > 0 ? size_cells[depth-1] : DT_ROOT_NODE_SIZE_CELLS_D= EFAULT; + if ( depth > 0 ) + { + as =3D address_cells[depth-1]; + ss =3D size_cells[depth-1]; + } + else + { + as =3D DT_ROOT_NODE_ADDR_CELLS_DEFAULT; + ss =3D DT_ROOT_NODE_SIZE_CELLS_DEFAULT; + } =20 address_cells[depth] =3D device_tree_get_u32(fdt, node, "#address-cells", as); diff --git a/xen/common/libfdt/fdt.c b/xen/common/libfdt/fdt.c index 9fe7cf4b74..a507169d29 100644 --- a/xen/common/libfdt/fdt.c +++ b/xen/common/libfdt/fdt.c @@ -165,7 +165,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset,= unsigned int len) uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) { const fdt32_t *tagp, *lenp; - uint32_t tag; + uint32_t tag, len; int offset =3D startoffset; const char *p; =20 @@ -192,11 +192,11 @@ uint32_t fdt_next_tag(const void *fdt, int startoffse= t, int *nextoffset) if (!can_assume(VALID_DTB) && !lenp) return FDT_END; /* premature end */ /* skip-name offset, length and value */ - offset +=3D sizeof(struct fdt_property) - FDT_TAGSIZE - + fdt32_to_cpu(*lenp); + len =3D fdt32_to_cpu(*lenp); + offset +=3D sizeof(struct fdt_property) - FDT_TAGSIZE + len; if (!can_assume(LATEST) && - fdt_version(fdt) < 0x10 && fdt32_to_cpu(*lenp) >=3D 8 && - ((offset - fdt32_to_cpu(*lenp)) % 8) !=3D 0) + fdt_version(fdt) < 0x10 && len >=3D 8 && + ((offset - len) % 8) !=3D 0) offset +=3D 4; break; =20 --=20 2.25.1