All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simone Ballarin <simone.ballarin@bugseng.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: "Jan Beulich" <jbeulich@suse.com>,
	consulting@bugseng.com,
	"Gianluca Luparini" <gianluca.luparini@bugseng.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"Paul Durrant" <paul@xen.org>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Xenia Ragiadakou" <Xenia.Ragiadakou@amd.com>,
	"Ayan Kumar Halder" <ayan.kumar.halder@amd.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH v2 12/13] xen/x86: fix violations of MISRA C:2012 Rule 7.2
Date: Mon, 10 Jul 2023 18:09:32 +0200	[thread overview]
Message-ID: <CAFHJcJsBP=_Lki=JMyzS=gr3kSMZJisJZmAWYX8H1cDHtWweFA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2307071432200.761183@ubuntu-linux-20-04-desktop>

[-- Attachment #1: Type: text/plain, Size: 4537 bytes --]

Il giorno ven 7 lug 2023 alle ore 23:53 Stefano Stabellini <
sstabellini@kernel.org> ha scritto:

> On Fri, 7 Jul 2023, Jan Beulich wrote:
> > On 07.07.2023 10:04, Simone Ballarin wrote:
> > > Il giorno ven 7 lug 2023 alle ore 09:04 Jan Beulich <jbeulich@suse.com>
> ha
> > > scritto:
> > >
> > >> On 07.07.2023 08:50, Simone Ballarin wrote:
> > >>> Il giorno gio 6 lug 2023 alle ore 18:22 Jan Beulich <
> jbeulich@suse.com>
> > >> ha
> > >>> scritto:
> > >>>
> > >>>> On 06.07.2023 18:08, Simone Ballarin wrote:
> > >>>>> Il giorno gio 6 lug 2023 alle ore 10:26 Jan Beulich <
> jbeulich@suse.com
> > >>>
> > >>>> ha
> > >>>>> scritto:
> > >>>>>
> > >>>>>> On 05.07.2023 17:26, Simone Ballarin wrote:
> > >>>>>>> --- a/xen/arch/x86/apic.c
> > >>>>>>> +++ b/xen/arch/x86/apic.c
> > >>>>>>> @@ -1211,7 +1211,7 @@ static void __init
> calibrate_APIC_clock(void)
> > >>>>>>>       * Setup the APIC counter to maximum. There is no way the
> lapic
> > >>>>>>>       * can underflow in the 100ms detection time frame.
> > >>>>>>>       */
> > >>>>>>> -    __setup_APIC_LVTT(0xffffffff);
> > >>>>>>> +    __setup_APIC_LVTT(0xffffffffU);
> > >>>>>>
> > >>>>>> While making the change less mechanical, we want to consider to
> switch
> > >>>>>> to ~0 in this and similar cases.
> > >>>>>>
> > >>>>>
> > >>>>> Changing ~0U is more than not mechanical: it is possibly dangerous.
> > >>>>> The resulting value could be different depending on the
> architecture,
> > >>>>> I prefer to not make such kind of changes in a MISRA-related patch.
> > >>>>
> > >>>> What do you mean by "depending on the architecture", when this is
> > >>>> x86-only code _and_ you can check what type parameter the called
> > >>>> function has?
> > >>>
> > >>> Ok, I will change these literals in ~0U in the next submission.
> > >>
> > >> Except that I specifically meant ~0, not ~0U. We mean "maximum value"
> > >> here, and at the call site it doesn't matter how wide the function
> > >> parameter's type is. If it was 64-bit, ~0U would not do what is
> wanted.
> > >
> > > ~0 is not a MISRA-compliant solution since bitwise operations on signed
> > > integers have implementation-defined behavior. This solution
> definitively
> > > violates Rule 10.1.
> >
> > So if we adopted that rule (we didn't so far), we'd have to e.g. change
> > all literal number shift counts to have U suffixes, no matter that
> > without the suffix it is still entirely obvious that the numbers are
> > unsigned? I'm afraid that'll face my opposition ...
>
> Indeed we have not adopted Rule 10.1. However, may I suggest that we
> don't make things potentially worse, just in case we end up deciding in
> favor of 10.1? We might not adopt 10.1 at all, but still... The code is
> already 0xffffffff, let's make things easier for all of us and just do
> 0xffffffffU ?
>
> Let's put Rule 10.1 and the whole of MISRA C aside for a second.
>
>
> Jan, let's say that you prefer ~0 or a different function parameter name
> or something else on any of these patches. You do realize that you don't
> need Simone or Federico or anyone else to make that change for you? You
> can make the change, submit a patch, and in your case anyone can ack
> it. Roger, Andrew, me, Bertrand, Julien, and almost anyone else could
> ack it and it would go in. As I wrote yesterday, feel free to CC me and
> I'll help you get in all the changes that you want.
>
> If you submitted that patch to switch to ~0 it might already be
> committed by now.
>
> I am trying to highlight that suggesting changes on these mechanical
> patches end up with more work for both the contributor and also the
> maintainer compared to do the change yourself.
>
> I think we should try to accept these patches as
> mechanical-changes-only. This is the only way to scale up this effort.
> If you spot something that you'd rather be done differently, do one of
> the following:
>
> a) Accept the patch as-is and submit a patch afterwards. Yes the line
>    gets changed twice but it is the easiest solution.
>
> b) Ask the contribitor to drop the single change you would rather do
>    differently, or even better drop it yourself on commit. Then submit a
>    patch with the change that you prefer.
>
> c) For trivial things, like code style changes, do the change directly
>    on commit.
>
>
> I know emails encourage English replies, but to make this work we need
> to do more code changes together and less English.
>


I agree.

-- 
Simone Ballarin, M.Sc.

Field Application Engineer, BUGSENG (https://bugseng.com
<http://bugseng.com>)

[-- Attachment #2: Type: text/html, Size: 6319 bytes --]

  reply	other threads:[~2023-07-10 16:10 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 15:26 [XEN PATCH v2 00/13] xen: fix violations of MISRA C:2012 Rule 7.2 Simone Ballarin
2023-07-05 15:26 ` [XEN PATCH v2 01/13] x86/cpufreq: " Simone Ballarin
2023-07-05 23:29   ` Stefano Stabellini
2023-07-06  7:44     ` Jan Beulich
2023-07-05 15:26 ` [XEN PATCH v2 02/13] AMD/IOMMU: " Simone Ballarin
2023-07-05 23:31   ` Stefano Stabellini
2023-07-06  7:48     ` Jan Beulich
2023-07-05 15:26 ` [XEN PATCH v2 03/13] x86/svm: " Simone Ballarin
2023-07-06  7:52   ` Jan Beulich
2023-07-05 15:26 ` [XEN PATCH v2 04/13] xen/arm: " Simone Ballarin
2023-07-05 16:27   ` Luca Fancellu
2023-07-05 16:42     ` Julien Grall
2023-07-05 15:26 ` [XEN PATCH v2 05/13] xen/device-tree: " Simone Ballarin
2023-07-05 16:28   ` Luca Fancellu
2023-07-05 23:32   ` Stefano Stabellini
2023-07-06  8:01   ` Julien Grall
2023-07-05 15:26 ` [XEN PATCH v2 06/13] xen/efi: " Simone Ballarin
2023-07-05 16:34   ` Luca Fancellu
2023-07-05 23:37   ` Stefano Stabellini
2023-07-06  7:55     ` Jan Beulich
2023-07-06 22:14       ` Stefano Stabellini
2023-07-05 15:26 ` [XEN PATCH v2 07/13] x86/vmx: " Simone Ballarin
2023-07-05 23:39   ` Stefano Stabellini
2023-07-06  8:04   ` Jan Beulich
2023-07-06 22:17     ` Stefano Stabellini
2023-07-07  6:44       ` Jan Beulich
2023-07-07  8:18     ` Simone Ballarin
2023-07-05 15:26 ` [XEN PATCH v2 08/13] xen/pci: " Simone Ballarin
2023-07-06  8:05   ` Jan Beulich
2023-07-05 15:26 ` [XEN PATCH v2 09/13] xen/public: " Simone Ballarin
2023-07-05 15:33   ` Juergen Gross
2023-07-06  7:43     ` Jan Beulich
2023-07-06  7:57       ` Juergen Gross
2023-07-06  8:43         ` Jan Beulich
2023-07-06  9:10           ` Juergen Gross
2023-07-05 23:42   ` Stefano Stabellini
2023-07-05 15:26 ` [XEN PATCH v2 10/13] x86/monitor: " Simone Ballarin
2023-07-05 15:26 ` [XEN PATCH v2 11/13] xen/vpci: " Simone Ballarin
2023-07-06  8:07   ` Jan Beulich
2023-07-05 15:26 ` [XEN PATCH v2 12/13] xen/x86: " Simone Ballarin
2023-07-06  0:11   ` Stefano Stabellini
2023-07-06  8:26   ` Jan Beulich
2023-07-06 16:08     ` Simone Ballarin
2023-07-06 16:22       ` Jan Beulich
2023-07-07  6:50         ` Simone Ballarin
2023-07-07  7:04           ` Jan Beulich
2023-07-07  8:04             ` Simone Ballarin
2023-07-07  9:46               ` Jan Beulich
2023-07-07 21:53                 ` Stefano Stabellini
2023-07-10 16:09                   ` Simone Ballarin [this message]
2023-07-06 16:22       ` Jan Beulich
2023-07-05 15:26 ` [XEN PATCH v2 13/13] xen: " Simone Ballarin
2023-07-05 16:43   ` Luca Fancellu
2023-07-05 18:42     ` Simone Ballarin
2023-07-05 19:32       ` Simone Ballarin
2023-07-06  8:28         ` Jan Beulich
2023-07-05 23:49   ` Stefano Stabellini
2023-07-06  8:34     ` Jan Beulich
2023-07-06  8:40   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFHJcJsBP=_Lki=JMyzS=gr3kSMZJisJZmAWYX8H1cDHtWweFA@mail.gmail.com' \
    --to=simone.ballarin@bugseng.com \
    --cc=Xenia.Ragiadakou@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ayan.kumar.halder@amd.com \
    --cc=consulting@bugseng.com \
    --cc=gianluca.luparini@bugseng.com \
    --cc=jbeulich@suse.com \
    --cc=michal.orzel@amd.com \
    --cc=paul@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.