From nobody Fri Nov 22 13:02:53 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1718381623558749.8367628382044; Fri, 14 Jun 2024 09:13:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.740806.1147909 (Exim 4.92) (envelope-from ) id 1sI9YP-00068S-OH; Fri, 14 Jun 2024 16:13:29 +0000 Received: by outflank-mailman (output) from mailman id 740806.1147909; Fri, 14 Jun 2024 16:13:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sI9YP-00068H-LV; Fri, 14 Jun 2024 16:13:29 +0000 Received: by outflank-mailman (input) for mailman id 740806; Fri, 14 Jun 2024 16:13:29 +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 1sI9YO-0005jz-WC for xen-devel@lists.xenproject.org; Fri, 14 Jun 2024 16:13:28 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 085fe45b-2a69-11ef-b4bb-af5377834399; Fri, 14 Jun 2024 18:13:27 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-79-46-197-197.retail.telecomitalia.it [79.46.197.197]) by support.bugseng.com (Postfix) with ESMTPSA id 3516B4EE0756; Fri, 14 Jun 2024 18:13:24 +0200 (CEST) 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: 085fe45b-2a69-11ef-b4bb-af5377834399 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 2/2] x86/e820 address violations of MISRA C:2012 Rule 5.3 Date: Fri, 14 Jun 2024 18:12:26 +0200 Message-Id: <1a02a5af6c2a737bc814610d4cc684ad4a00b8dc.1718380780.git.alessandro.zucchelli@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1718381624668100001 Content-Type: text/plain; charset="utf-8" This addresses violations of MISRA C:2012 Rule 5.3 which states as following: An identifier declared in an inner scope shall not hide an identifier declared in an outer scope. No functional change. Signed-off-by: Alessandro Zucchelli Acked-by: Jan Beulich --- xen/arch/x86/e820.c | 74 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 6a3ce7e0a0..3726823e88 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -593,79 +593,79 @@ int __init e820_add_range(uint64_t s, uint64_t e, uin= t32_t type) } =20 int __init e820_change_range_type( - struct e820map *e820, uint64_t s, uint64_t e, + struct e820map *map, uint64_t s, uint64_t e, uint32_t orig_type, uint32_t new_type) { uint64_t rs =3D 0, re =3D 0; unsigned int i; =20 - for ( i =3D 0; i < e820->nr_map; i++ ) + for ( i =3D 0; i < map->nr_map; i++ ) { /* Have we found the e820 region that includes the specified range= ? */ - rs =3D e820->map[i].addr; - re =3D rs + e820->map[i].size; + rs =3D map->map[i].addr; + re =3D rs + map->map[i].size; if ( (s >=3D rs) && (e <=3D re) ) break; } =20 - if ( (i =3D=3D e820->nr_map) || (e820->map[i].type !=3D orig_type) ) + if ( (i =3D=3D map->nr_map) || (map->map[i].type !=3D orig_type) ) return 0; =20 if ( (s =3D=3D rs) && (e =3D=3D re) ) { - e820->map[i].type =3D new_type; + map->map[i].type =3D new_type; } else if ( (s =3D=3D rs) || (e =3D=3D re) ) { - if ( (e820->nr_map + 1) > ARRAY_SIZE(e820->map) ) + if ( (map->nr_map + 1) > ARRAY_SIZE(map->map) ) goto overflow; =20 - memmove(&e820->map[i+1], &e820->map[i], - (e820->nr_map-i) * sizeof(e820->map[0])); - e820->nr_map++; + memmove(&map->map[i+1], &map->map[i], + (map->nr_map-i) * sizeof(map->map[0])); + map->nr_map++; =20 if ( s =3D=3D rs ) { - e820->map[i].size =3D e - s; - e820->map[i].type =3D new_type; - e820->map[i+1].addr =3D e; - e820->map[i+1].size =3D re - e; + map->map[i].size =3D e - s; + map->map[i].type =3D new_type; + map->map[i+1].addr =3D e; + map->map[i+1].size =3D re - e; } else { - e820->map[i].size =3D s - rs; - e820->map[i+1].addr =3D s; - e820->map[i+1].size =3D e - s; - e820->map[i+1].type =3D new_type; + map->map[i].size =3D s - rs; + map->map[i+1].addr =3D s; + map->map[i+1].size =3D e - s; + map->map[i+1].type =3D new_type; } } else { - if ( (e820->nr_map + 2) > ARRAY_SIZE(e820->map) ) + if ( (map->nr_map + 2) > ARRAY_SIZE(map->map) ) goto overflow; =20 - memmove(&e820->map[i+2], &e820->map[i], - (e820->nr_map-i) * sizeof(e820->map[0])); - e820->nr_map +=3D 2; + memmove(&map->map[i+2], &map->map[i], + (map->nr_map-i) * sizeof(map->map[0])); + map->nr_map +=3D 2; =20 - e820->map[i].size =3D s - rs; - e820->map[i+1].addr =3D s; - e820->map[i+1].size =3D e - s; - e820->map[i+1].type =3D new_type; - e820->map[i+2].addr =3D e; - e820->map[i+2].size =3D re - e; + map->map[i].size =3D s - rs; + map->map[i+1].addr =3D s; + map->map[i+1].size =3D e - s; + map->map[i+1].type =3D new_type; + map->map[i+2].addr =3D e; + map->map[i+2].size =3D re - e; } =20 /* Finally, look for any opportunities to merge adjacent e820 entries.= */ - for ( i =3D 0; i < (e820->nr_map - 1); i++ ) + for ( i =3D 0; i < (map->nr_map - 1); i++ ) { - if ( (e820->map[i].type !=3D e820->map[i+1].type) || - ((e820->map[i].addr + e820->map[i].size) !=3D e820->map[i+1].= addr) ) + if ( (map->map[i].type !=3D map->map[i+1].type) || + ((map->map[i].addr + map->map[i].size) !=3D map->map[i+1].add= r) ) continue; - e820->map[i].size +=3D e820->map[i+1].size; - memmove(&e820->map[i+1], &e820->map[i+2], - (e820->nr_map-i-2) * sizeof(e820->map[0])); - e820->nr_map--; + map->map[i].size +=3D map->map[i+1].size; + memmove(&map->map[i+1], &map->map[i+2], + (map->nr_map-i-2) * sizeof(map->map[0])); + map->nr_map--; i--; } =20 @@ -678,9 +678,9 @@ int __init e820_change_range_type( } =20 /* Set E820_RAM area (@s,@e) as RESERVED in specified e820 map. */ -int __init reserve_e820_ram(struct e820map *e820, uint64_t s, uint64_t e) +int __init reserve_e820_ram(struct e820map *map, uint64_t s, uint64_t e) { - return e820_change_range_type(e820, s, e, E820_RAM, E820_RESERVED); + return e820_change_range_type(map, s, e, E820_RAM, E820_RESERVED); } =20 unsigned long __init init_e820(const char *str, struct e820map *raw) --=20 2.34.1