rust: remove unnecessary #includes
Subsystems (2)
PATCH 1/1 rust: remove unnecessary #includes
Commit e26fa546042a ("rust: kbuild: auto generate helper exports") removed the need for these by automatically generating the exports; it removed the explicit uses of EXPORT_SYMBOL_GPL but didn't remove the header includes.
--- rust/exports.c | 6 +++--- rust/helpers/build_bug.c | 1 - rust/helpers/err.c | 1 - rust/helpers/kunit.c | 1 - rust/helpers/mutex.c | 1 - rust/helpers/refcount.c | 1 - rust/helpers/signal.c | 1 - rust/helpers/spinlock.c | 1 - rust/helpers/task.c | 1 - rust/helpers/wait.c | 1 - rust/helpers/workqueue.c | 1 - 11 files changed, 3 insertions(+), 13 deletions(-)
rust/exports.c +3 -3
@@ -3,9 +3,9 @@* A hack to export Rust symbols for loadable modules without having to redo * the entire `include/linux/export.h` logic in Rust. * -* This requires the Rust's new/future `v0` mangling scheme because the default -* one ("legacy") uses invalid characters for C identifiers (thus we cannot use -* the `EXPORT_SYMBOL_*` macros). +* This requires Rust's new/future `v0` mangling scheme because the default one +* ("legacy") uses invalid characters for C identifiers (thus we cannot use the +* `EXPORT_SYMBOL_*` macros). * * All symbols are exported as GPL-only to guarantee no GPL-only feature is * accidentally exposed.
rust/helpers/build_bug.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/errname.h> const char *rust_helper_errname (int err)
rust/helpers/err.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/err.h> -#include <linux/export.h> __force void *rust_helper_ERR_PTR (long err) {
rust/helpers/kunit.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <kunit/test-bug.h> -#include <linux/export.h> struct kunit *rust_helper_kunit_get_current_test (void ) {
rust/helpers/mutex.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/mutex.h> void rust_helper_mutex_lock (struct mutex *lock)
rust/helpers/refcount.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/refcount.h> refcount_t rust_helper_REFCOUNT_INIT (int n)
rust/helpers/signal.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/signal.h> int rust_helper_signal_pending (struct task_struct *t)
rust/helpers/spinlock.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/spinlock.h> void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
rust/helpers/task.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/task.h> struct task_struct *rust_helper_get_current (void )
rust/helpers/wait.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/wait.h> void rust_helper_init_wait (struct wait_queue_entry *wq_entry)
rust/helpers/workqueue.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/workqueue.h> void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
Signature · 1 line
2.47.0
Am 09.10.24 um 17:09 schrieb Tamir Duberstein:
Quoted 4 lines
Commit
e26fa546042a("rust: kbuild: auto generate helper exports") removed the need for these by automatically generating the exports; it removed the explicit uses ofEXPORT_SYMBOL_GPLbut didn't remove the header includes.
I was about to send the same patch. You have been faster. Thanks! :)
Two nits:
* Theoretically the grammer fix in exports.c could go into an independent patch. But if not it at least should be mentioned in the commit message. Let Miguel decide if he wants an extra patch or not ;)
* Maybe a
tag could be added? Even though Miguel might route it through rust-next as its not urgent for routing through rust-fixes.
Anyhow, regarding the main change:
Quoted 144 lines
Signed-off-by Tamir Duberstein <[email protected]>--- rust/exports.c | 6 +++--- rust/helpers/build_bug.c | 1 - rust/helpers/err.c | 1 - rust/helpers/kunit.c | 1 - rust/helpers/mutex.c | 1 - rust/helpers/refcount.c | 1 - rust/helpers/signal.c | 1 - rust/helpers/spinlock.c | 1 - rust/helpers/task.c | 1 - rust/helpers/wait.c | 1 - rust/helpers/workqueue.c | 1 - 11 files changed, 3 insertions(+), 13 deletions(-)rust/exports.c +3
-3@@ -3,9 +3,9 @@* A hack to export Rust symbols for loadable modules without having to redo * the entire `include/linux/export.h` logic in Rust. * -* This requires the Rust's new/future `v0` mangling scheme because the default -* one ("legacy") uses invalid characters for C identifiers (thus we cannot use -* the `EXPORT_SYMBOL_*` macros). +* This requires Rust's new/future `v0` mangling scheme because the default one +* ("legacy") uses invalid characters for C identifiers (thus we cannot use the +* `EXPORT_SYMBOL_*` macros). * * All symbols are exported as GPL-only to guarantee no GPL-only feature is * accidentally exposed. rust/helpers/build_bug.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/errname.h> const char *rust_helper_errname (int err)rust/helpers/err.c +0
-1@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/err.h> -#include <linux/export.h> __force void *rust_helper_ERR_PTR (long err) {rust/helpers/kunit.c +0
-1@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <kunit/test-bug.h> -#include <linux/export.h> struct kunit *rust_helper_kunit_get_current_test (void ) {rust/helpers/mutex.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/mutex.h> void rust_helper_mutex_lock (struct mutex *lock)rust/helpers/refcount.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/refcount.h> refcount_t rust_helper_REFCOUNT_INIT (int n)rust/helpers/signal.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/signal.h> int rust_helper_signal_pending (struct task_struct *t)rust/helpers/spinlock.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/spinlock.h> void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,rust/helpers/task.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/task.h> struct task_struct *rust_helper_get_current (void )rust/helpers/wait.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/wait.h> void rust_helper_init_wait (struct wait_queue_entry *wq_entry)rust/helpers/workqueue.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/workqueue.h> void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
Quoted 4 lines · Dirk Behme
* Theoretically the grammer fix in
exports.ccould go into an independent patch. But if not it at least should be mentioned in the commit message. Let Miguel decide if he wants an extra patch or not ;)
Indeed, in general, one should not have unstated/unrelated changes.
Quoted 6 lines
* Maybe a
Fixes e26fa546042a ("rust: kbuild: auto generate helper exports")tag could be added? Even though Miguel might route it through rust-next as its not urgent for routing through rust-fixes.
I think this is a cleanup, i.e. just unnecessary #includes being present, right? In other words, there is no "bug" apart from not being optimal (one could see cleanups as things that should have been done, but I guess we should draw the line somewhere).
Andreas: was there a reason to keep those #includes, just in case?
Thanks!
Cheers,
Miguel
Quoted 2 lines · Miguel Ojeda
Andreas: was there a reason to keep those
#includes, just in case?
FWIW already not all files in rust/helpers/ had these #includes, e.g. uaccess.c.
Thanks for calling out the grammar fix, I'll state that in v2. Should I split it into a separate patch?
Quoted 3 lines · Tamir Duberstein
Thanks for calling out the grammar fix, I'll state that in v2. Should I split it into a separate patch?
Yes, please (ideally as an independent patch, i.e. it does not need to be in the same series).
Cheers,
Miguel
PATCH v2 1/1 rust: remove unnecessary header includes
Commit e26fa546042a ("rust: kbuild: auto generate helper exports") removed the need for these by automatically generating the exports; it removed the explicit uses of EXPORT_SYMBOL_GPL but didn't remove the #include <linux/export.h>s.
---
V1 -> V2: Split grammar improvement into separate patch.
rust/helpers/build_bug.c | 1 - rust/helpers/err.c | 1 - rust/helpers/kunit.c | 1 - rust/helpers/mutex.c | 1 - rust/helpers/refcount.c | 1 - rust/helpers/signal.c | 1 - rust/helpers/spinlock.c | 1 - rust/helpers/task.c | 1 - rust/helpers/wait.c | 1 - rust/helpers/workqueue.c | 1 - 10 files changed, 10 deletions(-)
rust/helpers/build_bug.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/errname.h> const char *rust_helper_errname (int err)
rust/helpers/err.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/err.h> -#include <linux/export.h> __force void *rust_helper_ERR_PTR (long err) {
rust/helpers/kunit.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <kunit/test-bug.h> -#include <linux/export.h> struct kunit *rust_helper_kunit_get_current_test (void ) {
rust/helpers/mutex.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/mutex.h> void rust_helper_mutex_lock (struct mutex *lock)
rust/helpers/refcount.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/refcount.h> refcount_t rust_helper_REFCOUNT_INIT (int n)
rust/helpers/signal.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/signal.h> int rust_helper_signal_pending (struct task_struct *t)
rust/helpers/spinlock.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/spinlock.h> void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
rust/helpers/task.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/task.h> struct task_struct *rust_helper_get_current (void )
rust/helpers/wait.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/wait.h> void rust_helper_init_wait (struct wait_queue_entry *wq_entry)
rust/helpers/workqueue.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/workqueue.h> void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
Signature · 1 line
2.47.0
Re: [PATCH v2] rust: remove unnecessary header includes
Quoted 6 lines · Tamir Duberstein
Commit
e26fa546042a("rust: kbuild: auto generate helper exports") removed the need for these by automatically generating the exports; it removed the explicit uses ofEXPORT_SYMBOL_GPLbut didn't remove the#include <linux/export.h>s.Signed-off-by Tamir Duberstein <[email protected]>
Re: [PATCH v2] rust: remove unnecessary header includes
In reply to Tamir DubersteinQuoted 6 lines · On Wed, 9 Oct 2024 12:25:30 -0400 Tamir Duberstein <[email protected]> wrote:
Commit
e26fa546042a("rust: kbuild: auto generate helper exports") removed the need for these by automatically generating the exports; it removed the explicit uses ofEXPORT_SYMBOL_GPLbut didn't remove the#include <linux/export.h>s.Signed-off-by Tamir Duberstein <[email protected]>
Quoted 127 lines
---
V1 -> V2: Split grammar improvement into separate patch.rust/helpers/build_bug.c | 1 - rust/helpers/err.c | 1 - rust/helpers/kunit.c | 1 - rust/helpers/mutex.c | 1 - rust/helpers/refcount.c | 1 - rust/helpers/signal.c | 1 - rust/helpers/spinlock.c | 1 - rust/helpers/task.c | 1 - rust/helpers/wait.c | 1 - rust/helpers/workqueue.c | 1 - 10 files changed, 10 deletions(-)rust/helpers/build_bug.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/errname.h> const char *rust_helper_errname (int err)rust/helpers/err.c +0
-1@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/err.h> -#include <linux/export.h> __force void *rust_helper_ERR_PTR (long err) {rust/helpers/kunit.c +0
-1@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <kunit/test-bug.h> -#include <linux/export.h> struct kunit *rust_helper_kunit_get_current_test (void ) {rust/helpers/mutex.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/mutex.h> void rust_helper_mutex_lock (struct mutex *lock)rust/helpers/refcount.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/refcount.h> refcount_t rust_helper_REFCOUNT_INIT (int n)rust/helpers/signal.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/signal.h> int rust_helper_signal_pending (struct task_struct *t)rust/helpers/spinlock.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/spinlock.h> void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,rust/helpers/task.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/sched/task.h> struct task_struct *rust_helper_get_current (void )rust/helpers/wait.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/wait.h> void rust_helper_init_wait (struct wait_queue_entry *wq_entry)rust/helpers/workqueue.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/export.h> #include <linux/workqueue.h> void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
Miguel Ojeda
AppliedRe: [PATCH v2] rust: remove unnecessary header includes
In reply to Tamir DubersteinQuoted 7 lines · Tamir Duberstein
Commit
e26fa546042a("rust: kbuild: auto generate helper exports") removed the need for these by automatically generating the exports; it removed the explicit uses ofEXPORT_SYMBOL_GPLbut didn't remove the#include <linux/export.h>s.Signed-off-by Tamir Duberstein <[email protected]>
Applied to rust-next -- thanks everyone!
[ Reworded title. - Miguel ]
Cheers,
Miguel
Andreas Hindborg
reviewerQuoted 15 lines · Miguel Ojeda
Quoted 4 lines · Dirk Behme
* Theoretically the grammer fix in
exports.ccould go into an independent patch. But if not it at least should be mentioned in the commit message. Let Miguel decide if he wants an extra patch or not ;)Indeed, in general, one should not have unstated/unrelated changes.
Quoted 6 lines
* Maybe a
Fixes e26fa546042a ("rust: kbuild: auto generate helper exports")tag could be added? Even though Miguel might route it through rust-next as its not urgent for routing through rust-fixes.
Quoted 6 lines
I think this is a cleanup, i.e. just unnecessary
#includes being present, right? In other words, there is no "bug" apart from not being optimal (one could see cleanups as things that should have been done, but I guess we should draw the line somewhere).Andreas: was there a reason to keep those
#includes, just in case?
I don't think so, it looks like they should have been removed with Gary's patch that did the auto export.
BR Andreas