Skip to contentSkip to conversation

cifs: Constify static struct genl_ops

PATCH Applied Rikard Falkeborn 2 participants 2 messages May 26, 2021 – Jun 5, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Constify static struct genl_ops

The only usage of cifs_genl_ops[] is to assign its address to the ops field in the genl_family struct, which is a pointer to const. Make it const to allow the compiler to put it in read-only memory.

---
 fs/cifs/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/netlink.c +1 -1
index 5aaabe4cc0a7..291cb606f149 100644
@@ -30,7 +30,7 @@ static const struct nla_policy cifs_genl_policy[CIFS_GENL_ATTR_MAX + 1] = {
 	[CIFS_GENL_ATTR_SWN_RESOURCE_NAME]	= { .type = NLA_STRING},
 };
 
-static struct genl_ops cifs_genl_ops[] = {
+static const struct genl_ops cifs_genl_ops[] = {
 	{
 		.cmd = CIFS_GENL_CMD_SWN_NOTIFY,
 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
Signature · 1 line
2.31.1
Applied
#1 lore raw

merged into cifs-2.6.git for-next

Quoted 26 lines · Rikard Falkeborn

The only usage of cifs_genl_ops[] is to assign its address to the ops field in the genl_family struct, which is a pointer to const. Make it const to allow the compiler to put it in read-only memory.

---
 fs/cifs/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/netlink.c +1 -2
index 5aaabe4cc0a7..291cb606f149 100644
@@ -30,7 +30,7 @@ static const struct nla_policy cifs_genl_policy[CIFS_GENL_ATTR_MAX + 1] = {
        [CIFS_GENL_ATTR_SWN_RESOURCE_NAME]      = { .type = NLA_STRING},
 };
 
-static struct genl_ops cifs_genl_ops[] = {
+static const struct genl_ops cifs_genl_ops[] = {
        {
                .cmd = CIFS_GENL_CMD_SWN_NOTIFY,
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
--

2.31.1

Signature · 3 lines
Thanks,

Steve