[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH 1/6] x86: rename variable 'e820' to address MISRA C:2012 Rule 5.3


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 7 Aug 2023 11:10:16 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0iULD9PC1B4z/uqDN24cZIQpu5EoEqPNqEs47fA33AE=; b=E6aVrCSae04D5C7iyTypXzH/328765PhfliwKiZAxl+hjqy7IEUBuPqIrJoqs6auu8+0JymCmkAP8QAuCVINvpWiJrvsgdgvu1Ht8gKDU0m/J7HOtD32d5yiYImo+4sNdFPKQJ4tKppfJ2+6Xdke6SVdJew+8cRDUTO/ggop+Hod7ArQ8RiqoIYbk0wHUnkAFPm/mcA52CNGauPqISqtHl3HmgiiJCfjHXDYQAsgS9Fz0BHDStmvIGhCODbl1l1PZOxlqnHpCmFoZje/njZxbGx0K/rxXlafqimDF1BnqRKdoSKrxLaEN72wxqQW4kY6gZ9UbSojnn+/4F2JDo1MRg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PqydhE+CMnm8Fd6FOG68yjeLpfRiVBiENtXpCZkYYU79PM5tfZDaola3gGrHL8SNf6jtWAmbHk0ijoqK50Rq4y5NwhHYMfxP8zPikwKafkk21BpCW/8B4nmZa6azvoCQxyhzkUAuLXlF1qqALq6OHQD06Ym5pdIDOsItGhBlDzHtvmLD3qs1FNexeXWtTIEL85uAu1dEcg+qDM/ga8wGdQGfMQFFBB9NJZKvRyI+2Z9LDwlD1HE6xr1pMOO+nEGgDvXN69a4ql/J9rSkivngds8neg5ROyu76xkEZopv/3c3zFhWoctB1wwIGqaVRp7xRT3JnTC0Srx/hwUIAqM4Iw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 07 Aug 2023 09:10:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.08.2023 10:59, Nicola Vetrini wrote:
> On 07/08/2023 10:09, Jan Beulich wrote:
>> On 04.08.2023 17:27, Nicola Vetrini wrote:
>>> The variable declared in the header file 
>>> 'xen/arch/x86/include/asm/e820.h'
>>> is shadowed by many function parameters, so it is renamed to avoid 
>>> these
>>> violations.
>>>
>>> No functional changes.
>>>
>>> Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
>>> ---
>>> This patch is similar to other renames done on previous patches, and 
>>> the
>>> preferred strategy there was to rename the global variable. This one
>>> has more occurrences that are spread in various files, but
>>> the general pattern is the same.
>>
>> Still I think it would be better done the other way around, and perhaps 
>> in
>> more than a single patch. It looks like "many == 3", i.e.
>> - e820_add_range(), which is only ever called with "e820" as its 
>> argument,
>>   and hence the parameter could be dropped,
>> - e820_change_range_type(), which is in the same situation, and
>> - reserve_e820_ram(), which wants its parameter renamed.
>> Alternatively, if we really were to change the name of the global, we'd
>> want to take a more complete approach: Right now we have e820_raw[],
>> boot_e820[], and e820[]. We'd want them to follow a uniform naming 
>> scheme
>> then (e820_ first or _e820 last), with the other part of the name 
>> suitably
>> describing the purpose (which "map" doesn't do).
> 
> Besides the one you listed, there are these other occurrences:
> - xen/arch/x86/mm.c:4678 in 'arch_memory_op' as local variable 'struct 
> e820entry'

This probably wants renaming; my suggestion would be just "e" here.

> - xen/arch/x86/include/asm/guest/hypervisor.h:55 in 
> 'hypervisor_e820_fixup'
> - xen/arch/x86/include/asm/pv/shim.h:88 in 'pv_shim_fixup'

These can likely again have their parameters dropped, for it only
ever being the "e820" global which is passed. (Really I think in such
cases the names being the same should be permitted.)

> - xen/arch/x86/setup.c:689 in 'kexec_reserve_area'

This surely can quite sensibly have boot_e820 use moved into the
function itself.

> We can take the first approach you suggested (which was my original 
> attempt, but then upon feedback on other
> patches I reworked this patch before submitting). My doubt about it was 
> that it would introduce a naming
> inconsistency with other e820-related objects/types. Anyway, if e820_map 
> is not a good name, could e820_arr be it?

But how does "arr" describe the purpose? I would have suggested a name,
but none I can think of (e820_real, e820_final) I'd be really happy with.
Just e820 is pretty likely the best name we can have here.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.