Skip to contentSkip to conversation

Add missing netlink error message macros to coccinelle test

PATCH Applied Gal Pressman 4 participants 9 messages Feb 26, 2025 – Feb 28, 2025

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

cover Add missing netlink error message macros to coccinelle test

The newline_in_nl_msg.cocci test is missing some variants in the list of checked macros, add them and fix all reported issues.

Thanks,
Gal

Gal Pressman (5):
coccinelle: Add missing (GE)NL_SET_ERR_MSG_* to strings ending with
newline test
net/mlx5: Remove newline at the end of a netlink error message
sfc: Remove newline at the end of a netlink error message
net: sched: Remove newline at the end of a netlink error message
ice: dpll: Remove newline at the end of a netlink error message

 drivers/net/ethernet/intel/ice/ice_dpll.c          | 14 +++++++-------
 drivers/net/ethernet/mellanox/mlx5/core/dpll.c     |  2 +-
 .../ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c  |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/esw/bridge.c   |  6 +++---
 drivers/net/ethernet/sfc/mae.c                     |  2 +-
 drivers/net/ethernet/sfc/tc.c                      |  6 +++---
 net/sched/sch_qfq.c                                |  2 +-
 scripts/coccinelle/misc/newline_in_nl_msg.cocci    | 13 ++++++++-----
 9 files changed, 26 insertions(+), 23 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/5 coccinelle: Add missing (GE)NL_SET_ERR_MSG_* to strings ending with newline test

Add missing (GE)NL_SET_ERR_MSG_*() variants to the list of macros checked for strings ending with a newline.

---
 scripts/coccinelle/misc/newline_in_nl_msg.cocci | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/newline_in_nl_msg.cocci +8 -5
index 9baffe55d917..2814f6b205b9 100644
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 ///
-/// Catch strings ending in newline with GENL_SET_ERR_MSG, NL_SET_ERR_MSG,
-/// NL_SET_ERR_MSG_MOD.
+/// Catch strings ending in newline with (GE)NL_SET_ERR_MSG*.
 ///
 // Confidence: Very High
 // Copyright: (C) 2020 Intel Corporation
@@ -17,7 +16,11 @@ expression e;
 constant m;
 position p;
 @@
-  \(GENL_SET_ERR_MSG\|NL_SET_ERR_MSG\|NL_SET_ERR_MSG_MOD\)(e,m@p)
+  \(GENL_SET_ERR_MSG\|GENL_SET_ERR_MSG_FMT\|NL_SET_ERR_MSG\|NL_SET_ERR_MSG_MOD\|
+  NL_SET_ERR_MSG_FMT\|NL_SET_ERR_MSG_FMT_MOD\|NL_SET_ERR_MSG_WEAK\|
+  NL_SET_ERR_MSG_WEAK_MOD\|NL_SET_ERR_MSG_ATTR_POL\|
+  NL_SET_ERR_MSG_ATTR_POL_FMT\|NL_SET_ERR_MSG_ATTR\|
+  NL_SET_ERR_MSG_ATTR_FMT\)(e,m@p,...)
 
 @script:python@
 m << r.m;
@@ -32,7 +35,7 @@ expression r.e;
 constant r.m;
 position r.p;
 @@
-  fname(e,m@p)
+  fname(e,m@p,...)
 
 //----------------------------------------------------------
 //  For context mode
@@ -43,7 +46,7 @@ identifier r1.fname;
 expression r.e;
 constant r.m;
 @@
-* fname(e,m)
+* fname(e,m,...)
 
 //----------------------------------------------------------
 //  For org mode
Signature · 1 line
2.40.1
#2 lore raw

PATCH 2/5 net/mlx5: Remove newline at the end of a netlink error message

In reply to Gal Pressman

Netlink error messages should not have a newline at the end of the string.

---
 drivers/net/ethernet/mellanox/mlx5/core/dpll.c            | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c      | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/dpll.c +1 -1
index 31142f6cc372..1e5522a19483 100644
@@ -242,7 +242,7 @@ static int mlx5_dpll_clock_quality_level_get(const struct dpll_device *dpll,
 		return 0;
 	}
 errout:
-	NL_SET_ERR_MSG_MOD(extack, "Invalid clock quality level obtained from firmware\n");
+	NL_SET_ERR_MSG_MOD(extack, "Invalid clock quality level obtained from firmware");
 	return -EINVAL;
 }
 
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c +1 -1
index e4e487c8431b..5c762a71818d 100644
@@ -140,7 +140,7 @@ static int mlx5e_tc_tun_parse_vxlan_gbp_option(struct mlx5e_priv *priv,
 	gbp_mask = (u32 *)&enc_opts.mask->data[0];
 
 	if (*gbp_mask & ~VXLAN_GBP_MASK) {
-		NL_SET_ERR_MSG_FMT_MOD(extack, "Wrong VxLAN GBP mask(0x%08X)\n", *gbp_mask);
+		NL_SET_ERR_MSG_FMT_MOD(extack, "Wrong VxLAN GBP mask(0x%08X)", *gbp_mask);
 		return -EINVAL;
 	}
 
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +1 -1
index f9113cb13a0c..a4b2e57b3f80 100644
@@ -2040,7 +2040,7 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,
 		if (size_read < 0) {
 			NL_SET_ERR_MSG_FMT_MOD(
 				extack,
-				"Query module eeprom by page failed, read %u bytes, err %d\n",
+				"Query module eeprom by page failed, read %u bytes, err %d",
 				i, size_read);
 			return i;
 		}
drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c +3 -3
index 5f647358a05c..76e35c827da0 100644
@@ -1863,7 +1863,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_
 			 "Failed to lookup bridge port to add MDB (MAC=%pM,vport=%u)\n",
 			 addr, vport_num);
 		NL_SET_ERR_MSG_FMT_MOD(extack,
-				       "Failed to lookup bridge port to add MDB (MAC=%pM,vport=%u)\n",
+				       "Failed to lookup bridge port to add MDB (MAC=%pM,vport=%u)",
 				       addr, vport_num);
 		return -EINVAL;
 	}
@@ -1876,7 +1876,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_
 				 "Failed to lookup bridge port vlan metadata to create MDB (MAC=%pM,vid=%u,vport=%u)\n",
 				 addr, vid, vport_num);
 			NL_SET_ERR_MSG_FMT_MOD(extack,
-					       "Failed to lookup vlan metadata for MDB (MAC=%pM,vid=%u,vport=%u)\n",
+					       "Failed to lookup vlan metadata for MDB (MAC=%pM,vid=%u,vport=%u)",
 					       addr, vid, vport_num);
 			return -EINVAL;
 		}
@@ -1884,7 +1884,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_
 
 	err = mlx5_esw_bridge_port_mdb_attach(dev, port, addr, vid);
 	if (err) {
-		NL_SET_ERR_MSG_FMT_MOD(extack, "Failed to add MDB (MAC=%pM,vid=%u,vport=%u)\n",
+		NL_SET_ERR_MSG_FMT_MOD(extack, "Failed to add MDB (MAC=%pM,vid=%u,vport=%u)",
 				       addr, vid, vport_num);
 		return err;
 	}
Signature · 1 line
2.40.1
#3 lore raw

PATCH 3/5 sfc: Remove newline at the end of a netlink error message

In reply to Gal Pressman

Netlink error messages should not have a newline at the end of the string.

---
 drivers/net/ethernet/sfc/mae.c | 2 +-
 drivers/net/ethernet/sfc/tc.c  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/sfc/mae.c +1 -1
index 50f097487b14..6fd0c1e9a7d5 100644
@@ -755,7 +755,7 @@ int efx_mae_match_check_caps_lhs(struct efx_nic *efx,
 	rc = efx_mae_match_check_cap_typ(supported_fields[MAE_FIELD_INGRESS_PORT],
 					 ingress_port_mask_type);
 	if (rc) {
-		NL_SET_ERR_MSG_FMT_MOD(extack, "No support for %s mask in field %s\n",
+		NL_SET_ERR_MSG_FMT_MOD(extack, "No support for %s mask in field %s",
 				       mask_type_name(ingress_port_mask_type),
 				       "ingress_port");
 		return rc;
drivers/net/ethernet/sfc/tc.c +3 -3
index 0d93164988fc..fa94aa3cd5fe 100644
@@ -1043,7 +1043,7 @@ static int efx_tc_flower_handle_lhs_actions(struct efx_nic *efx,
 				return -EOPNOTSUPP;
 			}
 			if (fa->ct.action) {
-				NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled ct.action %u for LHS rule\n",
+				NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled ct.action %u for LHS rule",
 						       fa->ct.action);
 				return -EOPNOTSUPP;
 			}
@@ -1056,7 +1056,7 @@ static int efx_tc_flower_handle_lhs_actions(struct efx_nic *efx,
 			act->zone = ct_zone;
 			break;
 		default:
-			NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled action %u for LHS rule\n",
+			NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled action %u for LHS rule",
 					       fa->id);
 			return -EOPNOTSUPP;
 		}
@@ -1581,7 +1581,7 @@ static int efx_tc_flower_replace_foreign_lhs(struct efx_nic *efx,
 
 	type = efx_tc_indr_netdev_type(net_dev);
 	if (type == EFX_ENCAP_TYPE_NONE) {
-		NL_SET_ERR_MSG_MOD(extack, "Egress encap match on unsupported tunnel device\n");
+		NL_SET_ERR_MSG_MOD(extack, "Egress encap match on unsupported tunnel device");
 		return -EOPNOTSUPP;
 	}
 
Signature · 1 line
2.40.1
#4 lore raw

PATCH 4/5 net: sched: Remove newline at the end of a netlink error message

In reply to Gal Pressman

Netlink error messages should not have a newline at the end of the string.

---
 net/sched/sch_qfq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_qfq.c +1 -1
index 6a07cdbdb9e1..2cfbc977fe6d 100644
@@ -447,7 +447,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 
 	if (q->wsum + delta_w > QFQ_MAX_WSUM) {
 		NL_SET_ERR_MSG_FMT_MOD(extack,
-				       "total weight out of range (%d + %u)\n",
+				       "total weight out of range (%d + %u)",
 				       delta_w, q->wsum);
 		return -EINVAL;
 	}
Signature · 1 line
2.40.1
#5 lore raw

PATCH 5/5 ice: dpll: Remove newline at the end of a netlink error message

In reply to Gal Pressman

Netlink error messages should not have a newline at the end of the string.

---
 drivers/net/ethernet/intel/ice/ice_dpll.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_dpll.c +7 -7
index 8d806d8ad761..bce3ad6ca2a6 100644
@@ -95,7 +95,7 @@ ice_dpll_pin_freq_set(struct ice_pf *pf, struct ice_dpll_pin *pin,
 	}
 	if (ret) {
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to set pin freq:%u on pin:%u\n",
+				   "err:%d %s failed to set pin freq:%u on pin:%u",
 				   ret,
 				   ice_aq_str(pf->hw.adminq.sq_last_status),
 				   freq, pin->idx);
@@ -322,7 +322,7 @@ ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin,
 	}
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to enable %s pin:%u\n",
+				   "err:%d %s failed to enable %s pin:%u",
 				   ret, ice_aq_str(hw->adminq.sq_last_status),
 				   pin_type_name[pin_type], pin->idx);
 
@@ -367,7 +367,7 @@ ice_dpll_pin_disable(struct ice_hw *hw, struct ice_dpll_pin *pin,
 	}
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to disable %s pin:%u\n",
+				   "err:%d %s failed to disable %s pin:%u",
 				   ret, ice_aq_str(hw->adminq.sq_last_status),
 				   pin_type_name[pin_type], pin->idx);
 
@@ -479,7 +479,7 @@ ice_dpll_pin_state_update(struct ice_pf *pf, struct ice_dpll_pin *pin,
 err:
 	if (extack)
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to update %s pin:%u\n",
+				   "err:%d %s failed to update %s pin:%u",
 				   ret,
 				   ice_aq_str(pf->hw.adminq.sq_last_status),
 				   pin_type_name[pin_type], pin->idx);
@@ -518,7 +518,7 @@ ice_dpll_hw_input_prio_set(struct ice_pf *pf, struct ice_dpll *dpll,
 				      (u8)prio);
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to set pin prio:%u on pin:%u\n",
+				   "err:%d %s failed to set pin prio:%u on pin:%u",
 				   ret,
 				   ice_aq_str(pf->hw.adminq.sq_last_status),
 				   prio, pin->idx);
@@ -1004,7 +1004,7 @@ ice_dpll_pin_phase_adjust_set(const struct dpll_pin *pin, void *pin_priv,
 	mutex_unlock(&pf->dplls.lock);
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to set pin phase_adjust:%d for pin:%u on dpll:%u\n",
+				   "err:%d %s failed to set pin phase_adjust:%d for pin:%u on dpll:%u",
 				   ret,
 				   ice_aq_str(pf->hw.adminq.sq_last_status),
 				   phase_adjust, p->idx, d->dpll_idx);
@@ -1362,7 +1362,7 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 					 &p->freq);
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to set pin state:%u for pin:%u on parent:%u\n",
+				   "err:%d %s failed to set pin state:%u for pin:%u on parent:%u",
 				   ret,
 				   ice_aq_str(pf->hw.adminq.sq_last_status),
 				   state, p->idx, parent->idx);
Signature · 1 line
2.40.1
maintainer Acked-by on v1 5/5
#6 lore raw

Re: [PATCH net-next 5/5] ice: dpll: Remove newline at the end of a netlink error message

Quoted 5 lines · Gal Pressman

Netlink error messages should not have a newline at the end of the string.

Quoted 14 lines
---
  drivers/net/ethernet/intel/ice/ice_dpll.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_dpll.c +1 -1
index 8d806d8ad761..bce3ad6ca2a6 100644
@@ -95,7 +95,7 @@ ice_dpll_pin_freq_set(struct ice_pf *pf, struct ice_dpll_pin *pin,
  	}
  	if (ret) {
  		NL_SET_ERR_MSG_FMT(extack,
-				   "err:%d %s failed to set pin freq:%u on pin:%u\n",
+				   "err:%d %s failed to set pin freq:%u on pin:%u",

[...]

Reviewed-by on the v1 series
#7 lore raw
In reply to Gal Pressman
Quoted 14 lines · Gal Pressman

The newline_in_nl_msg.cocci test is missing some variants in the list of checked macros, add them and fix all reported issues.

Thanks,
Gal

Gal Pressman (5):
coccinelle: Add missing (GE)NL_SET_ERR_MSG_* to strings ending with
newline test
net/mlx5: Remove newline at the end of a netlink error message
sfc: Remove newline at the end of a netlink error message
net: sched: Remove newline at the end of a netlink error message
ice: dpll: Remove newline at the end of a netlink error message

Quoted 11 lines
 drivers/net/ethernet/intel/ice/ice_dpll.c          | 14 +++++++-------
 drivers/net/ethernet/mellanox/mlx5/core/dpll.c     |  2 +-
 .../ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c  |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/esw/bridge.c   |  6 +++---
 drivers/net/ethernet/sfc/mae.c                     |  2 +-
 drivers/net/ethernet/sfc/tc.c                      |  6 +++---
 net/sched/sch_qfq.c                                |  2 +-
 scripts/coccinelle/misc/newline_in_nl_msg.cocci    | 13 ++++++++-----
 9 files changed, 26 insertions(+), 23 deletions(-)

I looked at the whole series, thanks:

Quoted 2 lines
Signature · 1 line
2.40.1
#8 lore raw
In reply to Gal Pressman
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 14 lines · On Wed, 26 Feb 2025 11:38:59 +0200 you wrote:

The newline_in_nl_msg.cocci test is missing some variants in the list of checked macros, add them and fix all reported issues.

Thanks,
Gal

Gal Pressman (5):
coccinelle: Add missing (GE)NL_SET_ERR_MSG_* to strings ending with
newline test
net/mlx5: Remove newline at the end of a netlink error message
sfc: Remove newline at the end of a netlink error message
net: sched: Remove newline at the end of a netlink error message
ice: dpll: Remove newline at the end of a netlink error message

Quoted 1 line

[...]

Here is the summary with links:
- [net-next,1/5] coccinelle: Add missing (GE)NL_SET_ERR_MSG_* to strings ending with newline test

    https://git.kernel.org/netdev/net-next/c/5ace19bd8395
  - [net-next,2/5] net/mlx5: Remove newline at the end of a netlink error message
    https://git.kernel.org/netdev/net-next/c/3a2295ff3f00
  - [net-next,3/5] sfc: Remove newline at the end of a netlink error message
    https://git.kernel.org/netdev/net-next/c/79d89fab225e
  - [net-next,4/5] net: sched: Remove newline at the end of a netlink error message
    https://git.kernel.org/netdev/net-next/c/c94fae5f1ccf
  - [net-next,5/5] ice: dpll: Remove newline at the end of a netlink error message
    https://git.kernel.org/netdev/net-next/c/e0c032d26dab

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html