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

Re: [XEN PATCH 01/13] xen/x86: fixed violations of MISRA C:2012 Rule 7.2


  • To: Simone Ballarin <simone.ballarin@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 20 Jun 2023 14:26:38 +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=q4sjQLRBClxiXNGEnkIMqHlg0Kr3Ya7D3lQGaZuocMY=; b=ZVvGPLsoL5uuDUXh7F2PZDGBAk7Fkog5P8V3htPDaXusa7tH4D0G/lWXVlZy+xshiBszoTfYZgh3L9bfo2z1DehZJ5csC9DOIkfFXcrTKuSBrJWyIs3JSYDOD22wSOkfgamFn3LgqITyp0MnmqhYXtjFxjvFHDxOxvYaN2N/ZQbRDwOopW/bPjtvKUGzID2JqEG9VQ4NCg+EAdqqD0i/jj0qiTFMmFSzdZ43+eYI5ot4WS8J/UiWo7lDlRYgASh0mGp5/L7dYkCEZC15s8Z3jATlwu569porKjsh9COEtn3rDNzdG7iOPGGx2J8TruZKr789VEyRDYyphaYOwomZaw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IkfMvKEjj48RBwfmS0pRRHFonSyRuvmxaaIYTM0b06ez2s+bNVmBC0Hj4NVrE4CrkarNoP/D6HiBrwGHu5cJrk0NrZWdWFJCvGWrN1hnJdrXObx6qEnfR4X2skY/pDD48T+GohuneKm/RqR79frqOCweG8f3muHlJO2IO/zbSZyNdQ1cFtzH4S4FCP+IejKYYnKXR6BK0AQli+tcj30CTksL6d1dac10hrYM8+SnjXWxcGZ48jxSN1D0HcyYoSt9GE9zo3ddprkT2B3SSVkKzFD9/CwUmb5r9N6Mrb4LDvKLPBkqK0S7w7tpEhxJyQskbosab6789SIQoaKGJIgWmw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: consulting@xxxxxxxxxxx, Gianluca Luparini <gianluca.luparini@xxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Xenia Ragiadakou <Xenia.Ragiadakou@xxxxxxx>, Ayan Kumar <ayan.kumar.halder@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 20 Jun 2023 12:27:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.06.2023 12:34, Simone Ballarin wrote:
> From: Gianluca Luparini <gianluca.luparini@xxxxxxxxxxx>
> 
> The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline 
> states:
> "A "u" or "U" suffix shall be applied to all integer constants that are 
> represented in an unsigned type".
> 
> I propose to use "U" as a suffix to explicitly state when an integer constant 
> is represented in an unsigned type.

The code adjustments here are certainly fine, but I'd like to ask that
patch descriptions be written as such. "I propose ..." in particular
may be okay in an upfront discussion, but for a patch you want to
describe what the patch does, and why (the latter part you're dealing
with already).

Furthermore I continue to have trouble with the wording "is represented
in an unsigned type": As previously pointed out, what type a constant
is going to be represented in depends on the ABI and eventual variables
(specifically their types) that the value might then be assigned to, or
expressions that the value might be used in. A possible future
architecture with "int" wider than 32 bits would represent all the
constants touched here in a signed type. I think what is meant instead
(despite Misra's imo unhelpful wording) is that you add suffixes for
constants which are meant to have unsigned values (no matter what type
variable they would be stored in, or what expression they would appear
in, and hence independent of their eventual representation).

Furthermore the U suffix (as an example) doesn't help at all when the
value then is assigned to a variable of type long, and long is wider
than int. The value would then _still_ be represented in a signed type.

Taken together, how about 'Use "U" as a suffix to explicitly state when
an integer constant is intended to be an unsigned one'?

I expect both remarks will apply throughout the series, so I'm not
going to repeat them for later patches.

Jan



 


Rackspace

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