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

Re: [XEN PATCH 4/5] x86/x86_emulate: change parameter name from 's' to 'state'


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 7 Jul 2023 08:37:03 +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=lIWLWx8dgHcsTEVqplza6+9naUviv7sCsC3PH2iOdg4=; b=IDjVwUilQVGvp58yznrK3W71BhnVxLmD+ef9vpyW7jUKJ/Fs95sFA2+sqsCW+ao0uw4e5RbuP26Ppjg+Kd38S/PQGzMffyCldqCOmwl/maaPpWZXLb6/Dnei5CmjDLI5jl7srUFJh6TEKjBCKetM7HW1feqHO3HhikFQ2CqdQw9QZpFcaxLlHxehZxQxtqCScwReSVe/+hu7w46EOZw9uhY68CXqz4uF3mfvK2wdyVvzOjN6FfkVcHrrWnal50xJ5evuNQCJwgbdpMrzbSUDFaoTqQWfVNHHgk5+JoD6isyBzFlLndTXY2g8qVGFGe1DfEAZ0aE+heiZuRwX06SE4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8oPKj1TdOZhcikhVTUdm96Ijc00FEewbmX07JXATTnQmNUcbsEetrCX2CZR8xLLH/542OpdEVPMkCUorGtmzrBBSIUNMivMhy7RoDm6TIZJAoYi0dTM1KEpDnot2vo854+a7mL7ejuUbRS3qqeyLmEeW5P2m2XvctuHnKTr0rcn9uFNNRHy6i2AtHPYhpJnu1S2zuKo0EgmMzlETUazMCDHK++Fj40Twi8UKIQjj1XOumWJOfrN/v4pAEeWxa5jRfxQVQFBwY5LqYhXij65FhjHxZbFYaUJ6Ei0C9beKHvuxGxduBG5TfmT8stLgc9lsa8F2PXw3XWL7DK4lAMdjw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Delivery-date: Fri, 07 Jul 2023 06:37:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.07.2023 00:05, Stefano Stabellini wrote:
> On Thu, 6 Jul 2023, Jan Beulich wrote:
>> On 06.07.2023 00:49, Stefano Stabellini wrote:
>>> On Tue, 4 Jul 2023, Jan Beulich wrote:
>>>> On 29.06.2023 21:31, Stefano Stabellini wrote:
>>>>> On Thu, 29 Jun 2023, Federico Serafini wrote:
>>>>>> Change parameter name from 's' to 'state' in function definitions in
>>>>>> order to:
>>>>>> 1) keep consistency with the parameter names used in the corresponding
>>>>>>    declarations;
>>>>>> 2) keep consistency with parameter names used within x86_emulate.h;
>>>>>> 3) fix violations of MISRA C:2012 Rule 8.3.
>>>>>>
>>>>>> Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
>>>>>
>>>>> You could use x86emul: as tag in the title. I'll let Jan choose the tag
>>>>> he prefers.
>>>>
>>>> x86emul: or x86/emul: is what we commonly use. That said, I don't like
>>>> this change. The files touched are pretty new, and it was deliberate
>>>> that I used s, not state, for the names. This is shorthand much like
>>>> (globally) we use v (instead of vcpu) and d (instead of domain).
>>>
>>> Are you suggesting that the functions changed in this patch should be
>>> adapted in the other direction instead?  Meaning that the declaration is
>>> changed to match the definition instead of the opposite?
>>>
>>> If so, are you referring to all the functions changed in this patch? Or
>>> only some?
>>
>> All of the files touched here are ones which were recently introduced,
>> and which are deliberately the way they are. This "deliberately" really
>> goes as far as declarations and definitions disagreeing in names: For
>> the former, what matters are adjacent declarations in the header. For
>> the latter what matters is code readability. I'm sorry, I think the
>> Misra rule simply gets in the way of the original intentions here (and
>> I continue to disagree with there being any confusion from name
>> mismatches between declarations and definitions, the more that in the
>> case here it would be easy to avoid by simply omitting names in
>> declarations, but that is violating yet another rule I don't fully
>> agree with either, as voiced when discussing it).
>>
>> My preferred course of action here would be to simply drop the patch.
>> The least bad adjustment, if one is absolutely necessary, would be to
>> change the declarations, but then in a way that all adjacent ones
>> remain consistent (which may in turn require some _other_ definitions
>> to change). The mid- to long-term goal certainly is to use "s" more
>> where "state" may be used right now.
> 
> 
> If we drop this patch then we have the problem that Eclair and other
> scanners will detect these as violations. Also this source file would
> not be consistent with the rest of the codebase causing issues in the
> future. Any patch updating this file would trigger new MISRA C
> violations in the scanners.
> 
> So I don't think we can drop this patch but we could add deviations. I
> think your suggestion of "changing the declaration in a way that all
> adjacent ones remain consistent" is better, but let me also provide this
> option.
> 
> Basically, we would keep these declarations/definitions as is, and add
> a one-line in-code comment for each deviation. Such as:
> 
> /* SAF-2-safe R8.3 */
> bool cf_check
> x86_insn_is_mem_write(const struct x86_emulate_state *state,
>                       const struct x86_emulate_ctxt *ctxt);
> 
> Your suggestion of changing the declaration is better in my opinion. Do
> you agree?

Yes. I'm not really happy with any of the options resulting from us following
the various involved rules (also in particular 8.2), but this looks to be the
least bad of them.

Jan



 


Rackspace

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