diff mbox series

[net-next] net: constify net_class

Message ID 1d59986e-8ac0-4b9c-9006-ad1f41784a08@gmail.com (mailing list archive)
State Accepted
Commit 9382b4f338d261494aad7eeffef0b13ff663b542
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: constify net_class | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 928 this patch: 928
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 938 this patch: 938
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 939 this patch: 939
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-13--15-00 (tests: 960)

Commit Message

Heiner Kallweit April 12, 2024, 10:17 a.m. UTC
AFAICS all users of net_class take a const struct class * argument.
Therefore fully constify net_class.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/core/net-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Hemminger April 12, 2024, 4:38 p.m. UTC | #1
On Fri, 12 Apr 2024 12:17:57 +0200
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> AFAICS all users of net_class take a const struct class * argument.
> Therefore fully constify net_class.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

PS: net_class_attr can be const as well?
Heiner Kallweit April 12, 2024, 7:14 p.m. UTC | #2
On 12.04.2024 18:38, Stephen Hemminger wrote:
> On Fri, 12 Apr 2024 12:17:57 +0200
> Heiner Kallweit <hkallweit1@gmail.com> wrote:
> 
>> AFAICS all users of net_class take a const struct class * argument.
>> Therefore fully constify net_class.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> PS: net_class_attr can be const as well?

No, this results in warnings, because the const is at least discarded.

struct attribute_group {
	const char		*name;
	umode_t			(*is_visible)(struct kobject *,
					      struct attribute *, int);
	umode_t			(*is_bin_visible)(struct kobject *,
						  struct bin_attribute *, int);
	struct attribute	**attrs;
	struct bin_attribute	**bin_attrs;
};
patchwork-bot+netdevbpf@kernel.org April 15, 2024, 9:50 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri, 12 Apr 2024 12:17:57 +0200 you wrote:
> AFAICS all users of net_class take a const struct class * argument.
> Therefore fully constify net_class.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  net/core/net-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - [net-next] net: constify net_class
    https://git.kernel.org/netdev/net-next/c/9382b4f338d2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index e3d7a8cfa..427185c24 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -2046,7 +2046,7 @@  static void net_get_ownership(const struct device *d, kuid_t *uid, kgid_t *gid)
 	net_ns_get_ownership(net, uid, gid);
 }
 
-static struct class net_class __ro_after_init = {
+static const struct class net_class = {
 	.name = "net",
 	.dev_release = netdev_release,
 	.dev_groups = net_class_groups,