linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* Re: [Linux-kernel-mentees] GCC section alignment, and GCC-4.9 being a weird one
       [not found]               ` <CANiq72m+_QYtn_1gyrjXFs6yeDdiMoS4DVcWqYcTgyCFnSFXbw@mail.gmail.com>
@ 2020-10-21 18:35                 ` Joe Perches
  2020-10-21 19:27                   ` Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2020-10-21 18:35 UTC (permalink / raw)
  To: Miguel Ojeda, Nick Desaulniers, lukas.bulwahn,
	linux-kernel-mentees, dwaipayanray1, Aditya
  Cc: Jakub Jelinek, H.J. Lu, Florian Fainelli, kernel test robot,
	Peter Zijlstra, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Rasmus Villemoes, LKML, Steven Rostedt, LKP, linux-toolchains,
	Kees Cook

(adding cc's of kernel-mentees and a few checkpatch contributors)

On Wed, 2020-10-21 at 19:54 +0200, Miguel Ojeda wrote:
> On Wed, Oct 21, 2020 at 7:42 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> > If you used some of the macros from
> > include/linux/compiler_attributes.h like __section and __aligned, I
> > would prefer it.  Please consider spelling out __attribute__(()) an
> > antipattern.
> 
> +1, the shorthands should be used unless there is a reason not to (and
> please write the reason in a comment in that case).

Perhaps something to add as a generic test in checkpatch.

Right now it checks separately for each __attribute__
use with any of aligned, section, printf and scanf.

Likely it should include more of the #defines from
include/linux/compiler_attributes.h.

include/linux/compiler_attributes.h:#define __alias(symbol)                 __attribute__((__alias__(#symbol)))
include/linux/compiler_attributes.h:#define __aligned(x)                    __attribute__((__aligned__(x)))
include/linux/compiler_attributes.h:#define __aligned_largest               __attribute__((__aligned__))
include/linux/compiler_attributes.h:#define __always_inline                 inline __attribute__((__always_inline__))
include/linux/compiler_attributes.h:# define __assume_aligned(a, ...)       __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
include/linux/compiler_attributes.h:#define __cold                          __attribute__((__cold__))
include/linux/compiler_attributes.h:#define __attribute_const__             __attribute__((__const__))
include/linux/compiler_attributes.h:# define __copy(symbol)                 __attribute__((__copy__(symbol)))
include/linux/compiler_attributes.h:# define __designated_init              __attribute__((__designated_init__))
include/linux/compiler_attributes.h:# define __visible                      __attribute__((__externally_visible__))
include/linux/compiler_attributes.h:#define __printf(a, b)                  __attribute__((__format__(printf, a, b)))
include/linux/compiler_attributes.h:#define __scanf(a, b)                   __attribute__((__format__(scanf, a, b)))
include/linux/compiler_attributes.h:#define __gnu_inline                    __attribute__((__gnu_inline__))
include/linux/compiler_attributes.h:#define __malloc                        __attribute__((__malloc__))
include/linux/compiler_attributes.h:#define __mode(x)                       __attribute__((__mode__(x)))
include/linux/compiler_attributes.h:# define __no_caller_saved_registers        __attribute__((__no_caller_saved_registers__))
include/linux/compiler_attributes.h:# define __noclone                      __attribute__((__noclone__))
include/linux/compiler_attributes.h:# define fallthrough                    __attribute__((__fallthrough__))
include/linux/compiler_attributes.h:#define   noinline                      __attribute__((__noinline__))
include/linux/compiler_attributes.h:# define __nonstring                    __attribute__((__nonstring__))
include/linux/compiler_attributes.h:#define __noreturn                      __attribute__((__noreturn__))
include/linux/compiler_attributes.h:#define __packed                        __attribute__((__packed__))
include/linux/compiler_attributes.h:#define __pure                          __attribute__((__pure__))
include/linux/compiler_attributes.h:#define __section(S)                    __attribute__((__section__(#S)))
include/linux/compiler_attributes.h:#define __always_unused                 __attribute__((__unused__))
include/linux/compiler_attributes.h:#define __maybe_unused                  __attribute__((__unused__))
include/linux/compiler_attributes.h:#define __used                          __attribute__((__used__))
include/linux/compiler_attributes.h:#define __weak                          __attribute__((__weak__))


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Linux-kernel-mentees] GCC section alignment, and GCC-4.9 being a weird one
  2020-10-21 18:35                 ` [Linux-kernel-mentees] GCC section alignment, and GCC-4.9 being a weird one Joe Perches
@ 2020-10-21 19:27                   ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2020-10-21 19:27 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jakub Jelinek, H.J. Lu, Florian Fainelli, kernel test robot,
	Rasmus Villemoes, Aditya, Peter Zijlstra, dwaipayanray1,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Nick Desaulniers, LKML, Steven Rostedt, LKP, linux-toolchains,
	linux-kernel-mentees, Kees Cook

On Wed, Oct 21, 2020 at 8:35 PM Joe Perches <joe@perches.com> wrote:
>
> Perhaps something to add as a generic test in checkpatch.

Agreed! It would be nice to check all of them. Even checking for
`attribute` and `__attribute__` could be potentially reasonable (i.e.
so that people are reminded to consider adding whatever attributes
they need into `compiler_attributes.h`), although perhaps too
annoying/noisy for some (e.g. for `arch/*` devs...).

Cheers,
Miguel
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-21 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200629003127.GB5535@shao2-debian>
     [not found] ` <20200630124628.GV4817@hirez.programming.kicks-ass.net>
     [not found]   ` <20200630144905.GX4817@hirez.programming.kicks-ass.net>
     [not found]     ` <58ff47cc-dc55-e383-7a5b-37008d145aba@gmail.com>
     [not found]       ` <20201021080031.GY2628@hirez.programming.kicks-ass.net>
     [not found]         ` <20201021131806.GA2176@tucnak>
     [not found]           ` <20201021134436.GJ2628@hirez.programming.kicks-ass.net>
     [not found]             ` <CAKwvOd=qi63We=6rLapb565giCVe-8a6d=-=3VZL6RWzhwAeZg@mail.gmail.com>
     [not found]               ` <CANiq72m+_QYtn_1gyrjXFs6yeDdiMoS4DVcWqYcTgyCFnSFXbw@mail.gmail.com>
2020-10-21 18:35                 ` [Linux-kernel-mentees] GCC section alignment, and GCC-4.9 being a weird one Joe Perches
2020-10-21 19:27                   ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).