Thread (124 messages) 124 messages, 35 authors, 2026-04-16

Re: [PATCH 01/61] Coccinelle: Prefer IS_ERR_OR_NULL over manual NULL check

From: Markus Elfring <hidden>
Date: 2026-03-10 15:47:49
Also in: amd-gfx, bpf, ceph-devel, cocci, dm-devel, dri-devel, gfs2, intel-gfx, intel-wired-lan, kvm, linux-block, linux-bluetooth, linux-btrfs, linux-cifs, linux-clk, linux-ext4, linux-fsdevel, linux-gpio, linux-hyperv, linux-input, linux-iommu, linux-leds, linux-media, linux-mips, linux-mm, linux-modules, linux-nfs, linux-omap, linux-phy, linux-pm, linux-rockchip, linux-s390, linux-scsi, linux-sctp, linux-security-module, linux-sh, linux-sound, linux-trace-kernel, linux-usb, linux-wireless, lkml, ntfs3, sched-ext, target-devel, v9fs

Find and convert uses of IS_ERR() plus NULL check to IS_ERR_OR_NULL().
…

Can this information trigger any more consequences on corresponding summary phrases?


…
quoted hunk ↗ jump to hunk
+++ b/scripts/coccinelle/api/is_err_or_null.cocci
@@ -0,0 +1,125 @@
+virtual patch
+virtual report
+virtual org
How will interests evolve further for the support of the operation mode “context”?

+@p1 depends on patch@
+expression E;
+@@
+(
+-	E != NULL && !IS_ERR(E)
++	!IS_ERR_OR_NULL(E)
+|
+-	E == NULL || IS_ERR(E)
++	IS_ERR_OR_NULL(E)
+|
+-	!IS_ERR(E) && E != NULL
++	!IS_ERR_OR_NULL(E)
+|
+-	IS_ERR(E) || E == NULL
++	IS_ERR_OR_NULL(E)
+)
Did you eventually check probabilities for the occurrence of mentioned case distinctions?

+@p2 depends on patch@
…

I suggest to reconsider “side effects” according to the splitting of these SmPL rules
once more.


…
+@r2 depends on report || org@
+identifier I;
+expression E;
+position p;
+@@
+(
+*	(I = E) != NULL && ... && !IS_ERR@p(I)
+|
+*	(I = E) == NULL || ... || IS_ERR@p(I)
+)
I doubt that the usage of SmPL asterisks fits to these two operation modes.


…
+@p5 depends on patch disable unlikely @
+expression E;
+@@
+-\( likely \| unlikely \)(
+(
+ IS_ERR_OR_NULL(E)
+|
+ !IS_ERR_OR_NULL(E)
+)
+-)
* Would it be nicer to move such SmPL code to the end of the patch rule listing?

* Can this source code search pattern matter also for further operation modes?


Regards,
Markus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help