Message ID | 20240725101841.574-2-michal.wajdeczko@intel.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | 9b97452bcce77f8ef29b20c9662d95988b5990e4 |
Headers | show |
Series | [1/2] lib/string_choices: Add str_up_down() helper | expand |
On Thu, Jul 25, 2024 at 12:18:41PM +0200, Michal Wajdeczko wrote: > Add rules for finding places where str_up_down() can be used. > This currently finds over 20 locations. This would be need an update as well in accordance with the review comment on patch 1.
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci index a71966c0494e..d517f6bc850b 100644 --- a/scripts/coccinelle/api/string_choices.cocci +++ b/scripts/coccinelle/api/string_choices.cocci @@ -39,3 +39,26 @@ e << str_plural_r.E; @@ coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e) + +@str_up_down depends on patch@ +expression E; +@@ +( +- ((E) ? "up" : "down") ++ str_up_down(E) +) + +@str_up_down_r depends on !patch exists@ +expression E; +position P; +@@ +( +* ((E@P) ? "up" : "down") +) + +@script:python depends on report@ +p << str_up_down_r.P; +e << str_up_down_r.E; +@@ + +coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
Add rules for finding places where str_up_down() can be used. This currently finds over 20 locations. Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> --- Cc: Kees Cook <keescook@chromium.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- ./drivers/net/bonding/bond_sysfs.c:511:32-38: opportunity for str_up_down(active) ./drivers/net/bonding/bond_procfs.c:101:37-64: opportunity for str_up_down(netif_carrier_ok ( bond -> dev )) ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:6088:5-36: opportunity for str_up_down(e -> flags & BRCMF_EVENT_MSG_LINK) ./drivers/media/platform/ti/cal/cal-camerarx.c:194:3-9: opportunity for str_up_down(enable) ./drivers/net/dsa/mv88e6xxx/port.c:178:2-38: opportunity for str_up_down(reg & MV88E6XXX_PORT_MAC_CTL_LINK_UP) ./drivers/net/ethernet/faraday/ftgmac100.c:1737:5-16: opportunity for str_up_down(nd -> link_up) ./drivers/pinctrl/pinctrl-stmfx.c:382:7-11: opportunity for str_up_down(pupd) ./drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:2175:6-14: opportunity for str_up_down(state . up) ./drivers/block/aoe/aoeblk.c:40:4-23: opportunity for str_up_down(d -> flags & DEVFL_UP) ./drivers/ntb/test/ntb_perf.c:1224:3-39: opportunity for str_up_down(test_bit ( PERF_STS_LNKUP , & peer -> sts )) ./drivers/crypto/intel/qat/qat_common/adf_sysfs.c:28:9-35: opportunity for str_up_down(adf_dev_started ( accel_dev )) ./drivers/fsi/fsi-sbefifo.c:459:39-41: opportunity for str_up_down(up) ./net/ncsi/ncsi-manage.c:1282:8-26: opportunity for str_up_down(ncm -> data [ 2 ] & 0x1) ./net/ncsi/ncsi-aen.c:78:13-23: opportunity for str_up_down(data & 0x1) ./drivers/net/phy/phylink.c:1788:49-51: opportunity for str_up_down(up) ./drivers/net/phy/phylink.c:2109:39-41: opportunity for str_up_down(up) ./drivers/ntb/test/ntb_tool.c:299:2-4: opportunity for str_up_down(up) ./drivers/ufs/core/ufshcd.c:1186:4-12: opportunity for str_up_down(scale_up) ./drivers/ufs/core/ufshcd.c:1559:3-11: opportunity for str_up_down(scale_up) ./drivers/ntb/hw/mscc/ntb_hw_switchtec.c:513:4-12: opportunity for str_up_down(link_sta) ./drivers/ata/sata_via.c:362:8-14: opportunity for str_up_down(online) ./drivers/usb/host/oxu210hp-hcd.c:2784:39-44: opportunity for str_up_down(is_on) ./drivers/net/ethernet/smsc/smc91x.c:1178:8-19: opportunity for str_up_down(new_carrier) --- scripts/coccinelle/api/string_choices.cocci | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+)