All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Jan Beulich <jbeulich@suse.com>,
	consulting@bugseng.com, Andrew Cooper <andrew.cooper3@citrix.com>,
	Julien Grall <julien@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [RFC PATCH 17/17] CODING_STYLE: Add a section on header guards naming conventions
Date: Mon, 22 Jul 2024 08:56:09 +0200	[thread overview]
Message-ID: <3c447599a60dba86764bf20b8ff71f02@bugseng.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2407190820510.4857@ubuntu-linux-20-04-desktop>

On 2024-07-19 17:21, Stefano Stabellini wrote:
> On Fri, 19 Jul 2024, Jan Beulich wrote:
>> On 19.07.2024 00:01, Stefano Stabellini wrote:
>> > On Thu, 18 Jul 2024, Jan Beulich wrote:
>> >> On 18.07.2024 01:02, Stefano Stabellini wrote:
>> >>> On Wed, 17 Jul 2024, Jan Beulich wrote:
>> >>>> On 17.07.2024 02:20, Stefano Stabellini wrote:
>> >>>>> On Tue, 16 Jul 2024, Jan Beulich wrote:
>> >>>>>> On 16.07.2024 02:43, Stefano Stabellini wrote:
>> >>>>>>> On Mon, 15 Jul 2024, Jan Beulich wrote:
>> >>>>>>>> On 13.07.2024 00:38, Stefano Stabellini wrote:
>> >>>>>>>>> On Wed, 3 Jul 2024, Jan Beulich wrote:
>> >>>>>>>>>> I further have to note that, as indicated during the earlier discussion,
>> >>>>>>>>>> I still cannot see how occasional ambiguity is going to be dealt with.
>> >>>>>>>>>> IOW from the rules above two different headers could still end up with
>> >>>>>>>>>> the same guard identifier.
>> >>>>>>>>>
>> >>>>>>>>> Maybe something like this?
>> >>>>>>>>>
>> >>>>>>>>> "In the event of naming collisions, exceptions to the coding style may
>> >>>>>>>>> be made at the discretion of the contributor and maintainers."
>> >>>>>>>>
>> >>>>>>>> Hmm, maybe I wasn't clear enough then. My take is that the scheme should
>> >>>>>>>> simply not allow for possible collisions. Neither the contributor nor the
>> >>>>>>>> reviewer may spot such a collision, and it may therefore take until the
>> >>>>>>>> first full scan that one is actually noticed. Which I consider too late
>> >>>>>>>> in the process, even if we already were at the point where commits were
>> >>>>>>>> checked pre-push.
>> >>>>>>>
>> >>>>>>> Looking at the proposal, copy/pasted here for convenience:
>> >>>>>>>
>> >>>>>>> - private headers -> <dir>_<filename>_H
>> >>>>>>> - asm-generic headers -> ASM_GENERIC_<filename>_H
>> >>>>>>>     - #ifndef ASM_GENERIC_X86_PERCPU_H
>> >>>>>>>       #define ASM_GENERIC_X86_PERCPU_H
>> >>>>>>>       //...
>> >>>>>>>       #endif /* ASM_GENERIC_X86_PERCPU_H */
>> >>>>>>> - arch/<architecture>/include/asm/<subdir>/<filename>.h -> ASM_<architecture>_<subdir>_<filename>_H
>> >>>>>>>     - #ifndef ASM_X86_DOMAIN_H
>> >>>>>>>       #define ASM_X86_DOMAIN_H
>> >>>>>>>       //...
>> >>>>>>>       #endif /* ASM_X86_DOMAIN_H */
>> >>>>>>> - xen/include/xen/<filename>.h -> XEN_<filename>_H
>> >>>>>>> - xen/include/xen/<subdir>/<filename>.h -> XEN_<subdir>_<filename>_H
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> The only possibility for collision that I can see is from the first
>> >>>>>>> point:
>> >>>>>>>
>> >>>>>>> - private headers -> <dir>_<filename>_H
>> >>>>>>
>> >>>>>> I don't think this is the only possibility of collisions. The <subdir>_<filename>
>> >>>>>> parts can similarly cause problems if either of the two involved names contains
>> >>>>>> e.g. a dash (which would need converting to an underscore) or an underscore. To
>> >>>>>> avoid this, the name separators (slashes in the actual file names) there may need
>> >>>>>> representing by double underscores.
>> >>>>>
>> >>>>> I am OK with you two underscores as name separator (slashes in the
>> >>>>> actual file names). Would you do it for all levels like this?
>> >>>>>
>> >>>>> - arch/arm/arm64/lib/something.h -> ARM__ARM64__LIB__SOMETHING_H
>> >>>>> - arch/arm/arm32/lib/something.h -> ARM__ARM32__LIB__SOMETHING_H
>> >>>>> - arch/x86/lib/something.h -> X86__LIB__SOMETHING_H
>> >>>>>
>> >>>>>
>> >>>>> I think it is better than the below:
>> >>>>>
>> >>>>> - arch/arm/arm64/lib/something.h -> ARM_ARM64__LIB__SOMETHING_H
>> >>>>> - arch/arm/arm32/lib/something.h -> ARM_ARM32__LIB__SOMETHING_H
>> >>>>> - arch/x86/lib/something.h -> X86_LIB__SOMETHING_H
>> >>>>
>> >>>> Hmm, maybe it's indeed better to do it entirely uniformly then.
>> >>>
>> >>>
>> >>> Do we have agreement on the naming convention then?
>> >>>
>> >>>
>> >>> - private headers -> <dir>__<filename>__H
>> >>>     - arch/arm/arm64/lib/something.h -> ARM__ARM64__LIB__SOMETHING_H
>> >>>     - arch/arm/arm32/lib/something.h -> ARM__ARM32__LIB__SOMETHING_H
>> >>>     - arch/x86/lib/something.h -> X86__LIB__SOMETHING_H
>> >>>
>> >>> - asm-generic headers -> ASM_GENERIC_<filename>_H
>> >>>     - include/asm-generic/percpu.h -> ASM_GENERIC_X86_PERCPU_H
>> >>>
>> >>> - arch/<architecture>/include/asm/<subdir>/<filename>.h -> ASM_<architecture>_<subdir>_<filename>_H
>> >>>     - arch/x86/include/asm/domain.h -> ASM_X86_DOMAIN_H
>> >>>
>> >>> - include/xen -> XEN_<filename>_H
>> >>>     - include/xen/percpu.h -> XEN_PERCPU_H
>> >>>
>> >>>
>> >>> Or do you prefer the double underscore __  in all cases?
>> >>
>> >> It's not so much prefer, but a requirement if we want to be future proof.
>> >> Even for ASM_GENERIC_* that'll be needed, as your outline above simply
>> >> doesn't mention the (future) case of there being subdir-s there (see how
>> >> Linux already has some). Imo the question doesn't even arise for XEN_*,
>> >> as xen/ has subdir-s already.
>> >
>> > OK. So it becomes:
>> >
>> > - private headers -> <dir>__<filename>_H
>> >     - arch/arm/arm64/lib/something.h -> ARM__ARM64__LIB__SOMETHING_H
>> >     - arch/arm/arm32/lib/something.h -> ARM__ARM32__LIB__SOMETHING_H
>> >     - arch/x86/lib/something.h -> X86__LIB__SOMETHING_H
>> >
>> > - asm-generic headers -> ASM_GENERIC__<filename>_H
>> >     - include/asm-generic/percpu.h -> ASM_GENERIC__X86__PERCPU_H
>> 
>> Nit: There's still a stray _X86_ in here.
> 
> yes, good point.
> 
> Alessandro, let us know if we are good to go ahead or if we are missing
> anything.

I think we are good right now, I will provide the patch series v5 with 
all the
fixes and inclusion guards renamings soon.

>> > - arch/<architecture>/include/asm/<subdir>/<filename>.h -> ASM__<architecture>__<subdir>__<filename>_H
>> >     - arch/x86/include/asm/domain.h -> ASM__X86__DOMAIN_H
>> >
>> > - include/xen -> XEN__<filename>_H
>> >     - include/xen/percpu.h -> XEN__PERCPU_H
>> >
>> > If we have found agreement then Alessandro could send an update
>> 

-- 
Alessandro Zucchelli, B.Sc.

Software Engineer, BUGSENG (https://bugseng.com)


      reply	other threads:[~2024-07-22  6:56 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 11:10 [PATCH 00/17] xen: address violation of MISRA C:2012 Directive 4.10 Alessandro Zucchelli
2024-07-01 11:10 ` [PATCH 01/17] misra: add deviation for headers that explicitly avoid guards Alessandro Zucchelli
2024-07-03 12:46   ` Jan Beulich
2024-07-01 11:10 ` [PATCH 02/17] misra: modify deviations for empty and generated headers Alessandro Zucchelli
2024-07-01 11:10 ` [PATCH 03/17] misra: add deviations for direct inclusion guards Alessandro Zucchelli
2024-07-01 14:16   ` Jan Beulich
2024-07-12 22:00     ` Stefano Stabellini
2024-07-01 13:35 ` [PATCH 04/17] xen/arm: address violations of MISRA C:2012 Directive 4.10 Alessandro Zucchelli
2024-07-12 22:09   ` Stefano Stabellini
2024-07-01 13:36 ` [PATCH 05/17] xen/x86: " Alessandro Zucchelli
2024-07-01 14:21   ` Jan Beulich
2024-07-09  7:38     ` Alessandro Zucchelli
2024-07-09  7:45       ` Jan Beulich
2024-07-12 22:09         ` Stefano Stabellini
2024-07-15  7:27           ` Jan Beulich
2024-07-01 13:36 ` [PATCH 06/17] x86/EFI: " Alessandro Zucchelli
2024-07-01 14:09   ` Marek Marczykowski-Górecki
2024-07-01 14:36     ` Alessandro Zucchelli
2024-07-01 14:11   ` Jan Beulich
2024-07-12 22:10     ` Stefano Stabellini
2024-07-01 13:36 ` [PATCH 07/17] xen/common: " Alessandro Zucchelli
2024-07-01 13:36 ` [PATCH 08/17] xen/efi: " Alessandro Zucchelli
2024-07-01 13:36 ` [PATCH 09/17] xen: " Alessandro Zucchelli
2024-07-03 12:30   ` Jan Beulich
2024-07-12 22:16     ` Stefano Stabellini
2024-07-01 13:36 ` [PATCH 10/17] x86/asm: " Alessandro Zucchelli
2024-07-03 12:49   ` Jan Beulich
2024-07-04  7:50     ` Alessandro Zucchelli
2024-07-01 13:43 ` [PATCH 11/17] xen/arm: " Alessandro Zucchelli
2024-07-12 22:19   ` Stefano Stabellini
2024-07-01 13:43 ` [PATCH 12/17] xen: " Alessandro Zucchelli
2024-07-03 12:51   ` Jan Beulich
2024-07-04  8:14     ` Alessandro Zucchelli
2024-07-01 13:45 ` [PATCH 13/17] xen: add deviations for MISRA C 2012 Dir D4.10 Alessandro Zucchelli
2024-07-12 22:22   ` Stefano Stabellini
2024-07-01 13:45 ` [PATCH 14/17] xen: add SAF deviation for MISRA C Dir 4.10 Alessandro Zucchelli
2024-07-03 13:23   ` Jan Beulich
2024-07-12 22:28     ` Stefano Stabellini
2024-07-22  8:54       ` Alessandro Zucchelli
2024-07-22  9:14         ` Jan Beulich
2024-07-01 13:46 ` [PATCH 15/17] xen/x86: rename inclusion guards for consistency Alessandro Zucchelli
2024-07-03 13:26   ` Jan Beulich
2024-07-01 13:46 ` [PATCH 16/17] xen/build: address violation of MISRA C Directive 4.10 Alessandro Zucchelli
2024-07-03 13:32   ` Jan Beulich
2024-07-01 13:46 ` [RFC PATCH 17/17] CODING_STYLE: Add a section on header guards naming conventions Alessandro Zucchelli
2024-07-03 13:48   ` Jan Beulich
2024-07-12 22:38     ` Stefano Stabellini
2024-07-15  7:23       ` Jan Beulich
2024-07-15  9:08         ` Alessandro Zucchelli
2024-07-16  0:43         ` Stefano Stabellini
2024-07-16  7:17           ` Jan Beulich
2024-07-17  0:20             ` Stefano Stabellini
2024-07-17 10:24               ` Jan Beulich
2024-07-17 23:02                 ` Stefano Stabellini
2024-07-18  8:59                   ` Jan Beulich
2024-07-18 22:01                     ` Stefano Stabellini
2024-07-19  9:05                       ` Jan Beulich
2024-07-19 15:21                         ` Stefano Stabellini
2024-07-22  6:56                           ` Alessandro Zucchelli [this message]

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=3c447599a60dba86764bf20b8ff71f02@bugseng.com \
    --to=alessandro.zucchelli@bugseng.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=consulting@bugseng.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.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.