[PATCH 12/11] pragma once: scripted treewide conversion

STALE1963d

2 messages, 2 authors, 2021-03-02 · open the first message on its own page

[PATCH 12/11] pragma once: scripted treewide conversion

From: Alexey Dobriyan <hidden>
Date: 2021-02-28 17:13:01

[  Bcc a lot of lists so that people understand what's this is all         ]
[  about without creating uber-cc-thread.                                  ]
[  Apologies if I missed your subsystem                                    ]
[  Please see [PATCH 11/11: pragma once: conversion script (in Python 2)]  ]

Hi, Linus.

Please run the script below from top-level directory, it will convert
most kernel headers to #pragma once directive advancing them into
21-st century.

The advantages are:

* less LOC

	18087 files changed, 18878 insertions(+), 99804 deletions(-)
	= -81 kLOC (give or take)

* less mental tax on developers forced to name things which aren't even
  real code

* less junk in preprocessor hashtables and editors/IDEs autocompletion
  lists

There are two bit exceptions: UAPI headers and ACPICA.
Given ubiquity of #pragma once, I personally think even these subsystems
should be converted in the future.

Compile tested on alpha, arc, arm, arm64, h8300, ia64, m68k, microblaze,
mips, nios2, parisc, powerpc, riscv, s390, sh, sparc, um-i386, um-x86_64,
i386, x86_64, xtensa (allnoconfig, all defconfigs, allmodconfig with or
without SMP/DEBUG_KERNEL + misc stuff).

Not compile tested on csky, hexagon, nds32, openrisc. 

Love,
	Alexey

Signed-off-by: Alexey Dobriyan <redacted>



#!/bin/sh -x
find . -type f -name '*.h' -print	|\
LC_ALL=C sort				|\
sed -e 's#^./##g'			|\
xargs ./scripts/pragma-once.py

find . -type d -name 'uapi' | xargs git checkout -f
git checkout -f arch/alpha/include/asm/cmpxchg.h
git checkout -f arch/arm/mach-imx/hardware.h
git checkout -f arch/arm/mach-ixp4xx/include/mach/hardware.h
git checkout -f arch/arm/mach-sa1100/include/mach/hardware.h
git checkout -f arch/mips/include/asm/mips-cps.h
git checkout -f arch/x86/boot/boot.h
git checkout -f arch/x86/boot/ctype.h
git checkout -f arch/x86/include/asm/cpufeatures.h
git checkout -f arch/x86/include/asm/disabled-features.h
git checkout -f arch/x86/include/asm/required-features.h
git checkout -f arch/x86/include/asm/vmxfeatures.h
git checkout -f arch/x86/include/asm/vvar.h
git checkout -f drivers/acpi/acpica/
git checkout -f drivers/gpu/drm/amd/pm/inc/vega10_ppsmc.h
git checkout -f drivers/gpu/drm/amd/pm/powerplay/ppsmc.h
git checkout -f drivers/input/misc/yealink.h
git checkout -f drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
git checkout -f drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
git checkout -f drivers/pcmcia/yenta_socket.h
git checkout -f drivers/staging/rtl8723bs/include/hal_com_h2c.h
git checkout -f include/linux/acpi.h
git checkout -f include/linux/bitops.h
git checkout -f include/linux/compiler_types.h
git checkout -f include/linux/device.h
git checkout -f include/linux/kbuild.h
git checkout -f include/linux/libfdt_env.h
git checkout -f include/linux/local_lock.h
git checkout -f include/linux/spinlock.h
git checkout -f include/linux/spinlock_api_smp.h
git checkout -f include/linux/spinlock_types.h
git checkout -f include/linux/tracepoint.h
git checkout -f mm/gup_test.h
git checkout -f net/batman-adv/main.h
git checkout -f scripts/dtc/
git checkout -f tools/include/linux/bitops.h
git checkout -f tools/include/linux/compiler.h
git checkout -f tools/testing/selftests/clone3/clone3_selftests.h
git checkout -f tools/testing/selftests/futex/include/atomic.h
git checkout -f tools/testing/selftests/futex/include/futextest.h
git checkout -f tools/testing/selftests/futex/include/logging.h
git checkout -f tools/testing/selftests/kselftest.h
git checkout -f tools/testing/selftests/kselftest_harness.h
git checkout -f tools/testing/selftests/pidfd/pidfd.h
git checkout -f tools/testing/selftests/x86/helpers.h

Re: [PATCH 12/11] pragma once: scripted treewide conversion

From: "Darrick J. Wong" <djwong@kernel.org>
Date: 2021-03-02 00:58:30

On Sun, Feb 28, 2021 at 08:11:54PM +0300, Alexey Dobriyan wrote:
[  Bcc a lot of lists so that people understand what's this is all         ]
[  about without creating uber-cc-thread.                                  ]
[  Apologies if I missed your subsystem                                    ]
[  Please see [PATCH 11/11: pragma once: conversion script (in Python 2)]  ]

Hi, Linus.

Please run the script below from top-level directory, it will convert
most kernel headers to #pragma once directive advancing them into
21-st century.

The advantages are:

* less LOC

	18087 files changed, 18878 insertions(+), 99804 deletions(-)
	= -81 kLOC (give or take)

* less mental tax on developers forced to name things which aren't even
  real code
I don't find include guards to be much of a mental tax, but it sure
would be nice to see exactly what the changes would look like...
* less junk in preprocessor hashtables and editors/IDEs autocompletion
  lists

There are two bit exceptions: UAPI headers and ACPICA.
Given ubiquity of #pragma once, I personally think even these subsystems
should be converted in the future.

Compile tested on alpha, arc, arm, arm64, h8300, ia64, m68k, microblaze,
mips, nios2, parisc, powerpc, riscv, s390, sh, sparc, um-i386, um-x86_64,
i386, x86_64, xtensa (allnoconfig, all defconfigs, allmodconfig with or
without SMP/DEBUG_KERNEL + misc stuff).

Not compile tested on csky, hexagon, nds32, openrisc. 

Love,
	Alexey

Signed-off-by: Alexey Dobriyan <redacted>



#!/bin/sh -x
find . -type f -name '*.h' -print	|\
LC_ALL=C sort				|\
sed -e 's#^./##g'			|\
xargs ./scripts/pragma-once.py
...because I can't find this script in upstream git, so I can't really
tell for myself what the changes to xfs would look like.  The thing I
need to know is, what will changes to fs/xfs/libxfs/ look like when we
port that to userspace?

Does this introduce any minimum compiler version requirements?

--D
find . -type d -name 'uapi' | xargs git checkout -f
git checkout -f arch/alpha/include/asm/cmpxchg.h
git checkout -f arch/arm/mach-imx/hardware.h
git checkout -f arch/arm/mach-ixp4xx/include/mach/hardware.h
git checkout -f arch/arm/mach-sa1100/include/mach/hardware.h
git checkout -f arch/mips/include/asm/mips-cps.h
git checkout -f arch/x86/boot/boot.h
git checkout -f arch/x86/boot/ctype.h
git checkout -f arch/x86/include/asm/cpufeatures.h
git checkout -f arch/x86/include/asm/disabled-features.h
git checkout -f arch/x86/include/asm/required-features.h
git checkout -f arch/x86/include/asm/vmxfeatures.h
git checkout -f arch/x86/include/asm/vvar.h
git checkout -f drivers/acpi/acpica/
git checkout -f drivers/gpu/drm/amd/pm/inc/vega10_ppsmc.h
git checkout -f drivers/gpu/drm/amd/pm/powerplay/ppsmc.h
git checkout -f drivers/input/misc/yealink.h
git checkout -f drivers/media/usb/dvb-usb-v2/mxl111sf-demod.h
git checkout -f drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
git checkout -f drivers/pcmcia/yenta_socket.h
git checkout -f drivers/staging/rtl8723bs/include/hal_com_h2c.h
git checkout -f include/linux/acpi.h
git checkout -f include/linux/bitops.h
git checkout -f include/linux/compiler_types.h
git checkout -f include/linux/device.h
git checkout -f include/linux/kbuild.h
git checkout -f include/linux/libfdt_env.h
git checkout -f include/linux/local_lock.h
git checkout -f include/linux/spinlock.h
git checkout -f include/linux/spinlock_api_smp.h
git checkout -f include/linux/spinlock_types.h
git checkout -f include/linux/tracepoint.h
git checkout -f mm/gup_test.h
git checkout -f net/batman-adv/main.h
git checkout -f scripts/dtc/
git checkout -f tools/include/linux/bitops.h
git checkout -f tools/include/linux/compiler.h
git checkout -f tools/testing/selftests/clone3/clone3_selftests.h
git checkout -f tools/testing/selftests/futex/include/atomic.h
git checkout -f tools/testing/selftests/futex/include/futextest.h
git checkout -f tools/testing/selftests/futex/include/logging.h
git checkout -f tools/testing/selftests/kselftest.h
git checkout -f tools/testing/selftests/kselftest_harness.h
git checkout -f tools/testing/selftests/pidfd/pidfd.h
git checkout -f tools/testing/selftests/x86/helpers.h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help