public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
  • [parent not found: <20260310-b4-is_err_or_null-v1-61-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-18-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-57-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-46-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-30-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-24-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-15-bd63b656022d@avm.de>]
  • * Re: [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor
           [not found] <20260310-b4-is_err_or_null-v1-0-bd63b656022d@avm.de>
                       ` (7 preceding siblings ...)
           [not found] ` <20260310-b4-is_err_or_null-v1-15-bd63b656022d@avm.de>
    @ 2026-03-10 14:14 ` Steven Rostedt
      2026-03-10 14:23 ` Theodore Tso
                       ` (23 subsequent siblings)
      32 siblings, 0 replies; 57+ messages in thread
    From: Steven Rostedt @ 2026-03-10 14:14 UTC (permalink / raw)
      To: Philipp Hahn
      Cc: amd-gfx, apparmor, bpf, ceph-devel, cocci, dm-devel, dri-devel,
    	gfs2, intel-gfx, intel-wired-lan, iommu, kvm, linux-arm-kernel,
    	linux-block, linux-bluetooth, linux-btrfs, linux-cifs, linux-clk,
    	linux-erofs, linux-ext4, linux-fsdevel, linux-gpio, linux-hyperv,
    	linux-input, linux-kernel, linux-leds, linux-media, linux-mips,
    	linux-mm, linux-modules, linux-mtd, linux-nfs, linux-omap,
    	linux-phy, linux-pm, linux-rockchip, linux-s390, linux-scsi,
    	linux-sctp, linux-security-module, linux-sh, linux-sound,
    	linux-stm32, linux-trace-kernel, linux-usb, linux-wireless,
    	netdev, ntfs3, samba-technical, sched-ext, target-devel,
    	tipc-discussion, v9fs, Julia Lawall, Nicolas Palix, Chris Mason,
    	David Sterba, Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
    	Theodore Ts'o, Andreas Dilger, Steve French, Paulo Alcantara,
    	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Bharath SM,
    	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
    	Christian Schoenebeck, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
    	Sandeep Dhavale, Hongbo Li, Chunhai Guo, Miklos Szeredi,
    	Konstantin Komarov, Andreas Gruenbacher, Kees Cook, Tony Luck,
    	Guilherme G. Piccoli, Jan Kara, Phillip Lougher, Alexander Viro,
    	Christian Brauner, Jan Kara, Masami Hiramatsu, Mathieu Desnoyers,
    	Tejun Heo, David Vernet, Andrea Righi, Changwoo Min, Ingo Molnar,
    	Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
    	Ben Segall, Mel Gorman, Valentin Schneider, Luis Chamberlain,
    	Petr Pavlu, Daniel Gomez, Sami Tolvanen, Aaron Tomlin,
    	Sylwester Nawrocki, Liam Girdwood, Mark Brown, Jaroslav Kysela,
    	Takashi Iwai, Max Filippov, Paolo Bonzini, John Johansen,
    	Paul Moore, James Morris, Serge E. Hallyn, Andrew Morton,
    	Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
    	Benjamin Marzinski, David S. Miller, David Ahern, Eric Dumazet,
    	Jakub Kicinski, Paolo Abeni, Simon Horman, Marcel Holtmann,
    	Johan Hedberg, Luiz Augusto von Dentz, Alexei Starovoitov,
    	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
    	Stanislav Fomichev, Jamal Hadi Salim, Jiri Pirko,
    	Marcelo Ricardo Leitner, Xin Long, Trond Myklebust,
    	Anna Schumaker, Chuck Lever, Jeff Layton, NeilBrown,
    	Olga Kornievskaia, Dai Ngo, Jon Maloy, Johannes Berg,
    	Catalin Marinas, Russell King, John Crispin, Thomas Bogendoerfer,
    	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
    	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
    	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
    	Thomas Zimmermann, David Airlie, Simona Vetter, Zhenyu Wang,
    	Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
    	Tvrtko Ursulin, Alex Deucher, Christian König, Sandy Huang,
    	Heiko Stübner, Andy Yan, Igor Russkikh, Andrew Lunn,
    	Pavan Chebbi, Michael Chan, Potnuri Bharat Teja, Tony Nguyen,
    	Przemek Kitszel, Taras Chornyi, Maxime Coquelin, Alexandre Torgue,
    	Iyappan Subramanian, Keyur Chudgar, Quan Nguyen, Heiner Kallweit,
    	Marc Zyngier, Thomas Gleixner, Andrew Lunn, Gregory Clement,
    	Sebastian Hesselbarth, Vinod Koul, Linus Walleij, Ulf Hansson,
    	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
    	Christian Borntraeger, Sven Schnelle, Martin K. Petersen,
    	Eduardo Valentin, Keerthy, Rafael J. Wysocki, Daniel Lezcano,
    	Zhang Rui, Lukasz Luba, Alex Williamson, Mark Greer,
    	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
    	Shuah Khan, Kieran Bingham, Mauro Carvalho Chehab, Joerg Roedel,
    	Will Deacon, Robin Murphy, Lee Jones, Pavel Machek, Dave Penkler,
    	K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
    	Justin Sanders, Jens Axboe, Georgi Djakov, Michael Turquette,
    	Stephen Boyd, Philipp Zabel, Borislav Petkov, Dave Hansen, x86,
    	H. Peter Anvin, Pali Rohár, Dmitry Torokhov
    
    On Tue, 10 Mar 2026 12:48:26 +0100
    Philipp Hahn <phahn-oss@avm.de> wrote:
    
    > While doing some static code analysis I stumbled over a common pattern,
    > where IS_ERR() is combined with a NULL check. For that there is
    > IS_ERR_OR_NULL().
    > 
    > I've written a Coccinelle patch to find and patch those instances.
    > The patches follow grouped by subsystem.
    
    
    Honestly, the IS_ERR_OR_NULL() looks worse in a lot of the locations you
    updated. Just because we have IS_ERR_OR_NULL() doesn't mean we need to go
    and replace every location that can use it.
    
    NAK for any code this touches that I'm responsible for.
    
    -- Steve
    
    ^ permalink raw reply	[flat|nested] 57+ messages in thread
  • * Re: [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor
           [not found] <20260310-b4-is_err_or_null-v1-0-bd63b656022d@avm.de>
                       ` (8 preceding siblings ...)
      2026-03-10 14:14 ` [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor Steven Rostedt
    @ 2026-03-10 14:23 ` Theodore Tso
           [not found] ` <20260310-b4-is_err_or_null-v1-17-bd63b656022d@avm.de>
                       ` (22 subsequent siblings)
      32 siblings, 0 replies; 57+ messages in thread
    From: Theodore Tso @ 2026-03-10 14:23 UTC (permalink / raw)
      To: Philipp Hahn
      Cc: amd-gfx, apparmor, bpf, ceph-devel, cocci, dm-devel, dri-devel,
    	gfs2, intel-gfx, intel-wired-lan, iommu, kvm, linux-arm-kernel,
    	linux-block, linux-bluetooth, linux-btrfs, linux-cifs, linux-clk,
    	linux-erofs, linux-ext4, linux-fsdevel, linux-gpio, linux-hyperv,
    	linux-input, linux-kernel, linux-leds, linux-media, linux-mips,
    	linux-mm, linux-modules, linux-mtd, linux-nfs, linux-omap,
    	linux-phy, linux-pm, linux-rockchip, linux-s390, linux-scsi,
    	linux-sctp, linux-security-module, linux-sh, linux-sound,
    	linux-stm32, linux-trace-kernel, linux-usb, linux-wireless,
    	netdev, ntfs3, samba-technical, sched-ext, target-devel,
    	tipc-discussion, v9fs, Julia Lawall, Nicolas Palix, Chris Mason,
    	David Sterba, Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
    	Andreas Dilger, Steve French, Paulo Alcantara, Ronnie Sahlberg,
    	Shyam Prasad N, Tom Talpey, Bharath SM, Eric Van Hensbergen,
    	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
    	Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale, Hongbo Li,
    	Chunhai Guo, Miklos Szeredi, Konstantin Komarov,
    	Andreas Gruenbacher, Kees Cook, Tony Luck, Guilherme G. Piccoli,
    	Jan Kara, Phillip Lougher, Alexander Viro, Christian Brauner,
    	Jan Kara, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
    	Tejun Heo, David Vernet, Andrea Righi, Changwoo Min, Ingo Molnar,
    	Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
    	Ben Segall, Mel Gorman, Valentin Schneider, Luis Chamberlain,
    	Petr Pavlu, Daniel Gomez, Sami Tolvanen, Aaron Tomlin,
    	Sylwester Nawrocki, Liam Girdwood, Mark Brown, Jaroslav Kysela,
    	Takashi Iwai, Max Filippov, Paolo Bonzini, John Johansen,
    	Paul Moore, James Morris, Serge E. Hallyn, Andrew Morton,
    	Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
    	Benjamin Marzinski, David S. Miller, David Ahern, Eric Dumazet,
    	Jakub Kicinski, Paolo Abeni, Simon Horman, Marcel Holtmann,
    	Johan Hedberg, Luiz Augusto von Dentz, Alexei Starovoitov,
    	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
    	Stanislav Fomichev, Jamal Hadi Salim, Jiri Pirko,
    	Marcelo Ricardo Leitner, Xin Long, Trond Myklebust,
    	Anna Schumaker, Chuck Lever, Jeff Layton, NeilBrown,
    	Olga Kornievskaia, Dai Ngo, Jon Maloy, Johannes Berg,
    	Catalin Marinas, Russell King, John Crispin, Thomas Bogendoerfer,
    	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
    	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
    	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
    	Thomas Zimmermann, David Airlie, Simona Vetter, Zhenyu Wang,
    	Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
    	Tvrtko Ursulin, Alex Deucher, Christian König, Sandy Huang,
    	Heiko Stübner, Andy Yan, Igor Russkikh, Andrew Lunn,
    	Pavan Chebbi, Michael Chan, Potnuri Bharat Teja, Tony Nguyen,
    	Przemek Kitszel, Taras Chornyi, Maxime Coquelin, Alexandre Torgue,
    	Iyappan Subramanian, Keyur Chudgar, Quan Nguyen, Heiner Kallweit,
    	Marc Zyngier, Thomas Gleixner, Andrew Lunn, Gregory Clement,
    	Sebastian Hesselbarth, Vinod Koul, Linus Walleij, Ulf Hansson,
    	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
    	Christian Borntraeger, Sven Schnelle, Martin K. Petersen,
    	Eduardo Valentin, Keerthy, Rafael J. Wysocki, Daniel Lezcano,
    	Zhang Rui, Lukasz Luba, Alex Williamson, Mark Greer,
    	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
    	Shuah Khan, Kieran Bingham, Mauro Carvalho Chehab, Joerg Roedel,
    	Will Deacon, Robin Murphy, Lee Jones, Pavel Machek, Dave Penkler,
    	K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
    	Justin Sanders, Jens Axboe, Georgi Djakov, Michael Turquette,
    	Stephen Boyd, Philipp Zabel, Borislav Petkov, Dave Hansen, x86,
    	H. Peter Anvin, Pali Rohár, Dmitry Torokhov
    
    On Tue, Mar 10, 2026 at 12:48:26PM +0100, Philipp Hahn wrote:
    > While doing some static code analysis I stumbled over a common pattern,
    > where IS_ERR() is combined with a NULL check. For that there is
    > IS_ERR_OR_NULL().
    > 
    > I've written a Coccinelle patch to find and patch those instances.
    > The patches follow grouped by subsystem.
    
    I'm going to gently suggest that you *not* try to do this as a
    tree-wide change, since we don't need to change some interface
    requiring a global, flag day change.  This is instead a cleanup, which
    maybe makes the code slightly better, but which also has a the
    downside of breaking lots of inflight development patches by
    potentially causing merge or patch conflicts.
    
    So why don't you send it to each subsystem as a separate patch or
    small patch series, instead of spamming a dozen-plus mailing lists,
    are probably hundreds of developers, most of whom aren't going to
    care about changs in some far flung part of the kernel?
    
    Regards,
    
    						- Ted
    
    ^ permalink raw reply	[flat|nested] 57+ messages in thread
  • [parent not found: <20260310-b4-is_err_or_null-v1-17-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-38-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-3-bd63b656022d@avm.de>]
  • * Re: [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor
           [not found] <20260310-b4-is_err_or_null-v1-0-bd63b656022d@avm.de>
                       ` (12 preceding siblings ...)
           [not found] ` <20260310-b4-is_err_or_null-v1-3-bd63b656022d@avm.de>
    @ 2026-03-10 18:40 ` Kuan-Wei Chiu
      2026-03-12 12:57   ` Jason Gunthorpe
      2026-03-11  0:09 ` Russell King (Oracle)
                       ` (18 subsequent siblings)
      32 siblings, 1 reply; 57+ messages in thread
    From: Kuan-Wei Chiu @ 2026-03-10 18:40 UTC (permalink / raw)
      To: Philipp Hahn
      Cc: amd-gfx, apparmor, bpf, ceph-devel, cocci, dm-devel, dri-devel,
    	gfs2, intel-gfx, intel-wired-lan, iommu, kvm, linux-arm-kernel,
    	linux-block, linux-bluetooth, linux-btrfs, linux-cifs, linux-clk,
    	linux-erofs, linux-ext4, linux-fsdevel, linux-gpio, linux-hyperv,
    	linux-input, linux-kernel, linux-leds, linux-media, linux-mips,
    	linux-mm, linux-modules, linux-mtd, linux-nfs, linux-omap,
    	linux-phy, linux-pm, linux-rockchip, linux-s390, linux-scsi,
    	linux-sctp, linux-security-module, linux-sh, linux-sound,
    	linux-stm32, linux-trace-kernel, linux-usb, linux-wireless,
    	netdev, ntfs3, samba-technical, sched-ext, target-devel,
    	tipc-discussion, v9fs
    
    Hi Philipp,
    
    On Tue, Mar 10, 2026 at 12:48:26PM +0100, Philipp Hahn wrote:
    > While doing some static code analysis I stumbled over a common pattern,
    > where IS_ERR() is combined with a NULL check. For that there is
    > IS_ERR_OR_NULL().
    > 
    > I've written a Coccinelle patch to find and patch those instances.
    > The patches follow grouped by subsystem.
    > 
    > Patches 55-58 may be dropped as they have a (minor?) semantic change:
    > They use WARN_ON() or WARN_ON_ONCE(), but only in the IS_ERR() path, not
    > for the NULL check. Iff it is okay to print the warning also for NULL,
    > then the patches can be applied.
    > 
    > While generating the patch set `checkpatch` complained about mixing
    > [un]likely() with IS_ERR_OR_NULL(), which already uses likely()
    > internally. I found and fixed several locations, where that combination
    > has been used.
    
    Thanks for the patchset. However, I think we need a explanation for why
    switching to IS_ERR_OR_NULL() is an improvement over the existing code.
    
    IMHO, the necessity of IS_ERR_OR_NULL() often highlights a confusing or
    flawed API design. It usually implies that the caller is unsure whether
    a failure results in an error pointer or a NULL pointer. Rather than
    doing a treewide conversion of this pattern, I believe it would be much
    more meaningful to review these instances case-by-case and fix the
    underlying APIs or caller logic instead.
    
    Additionally, a treewide refactoring like this has the practical
    drawback of creating unnecessary merge conflicts when backporting to
    stable trees.
    
    Regards,
    Kuan-Wei
    
    ^ permalink raw reply	[flat|nested] 57+ messages in thread
  • * Re: [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor
           [not found] <20260310-b4-is_err_or_null-v1-0-bd63b656022d@avm.de>
                       ` (13 preceding siblings ...)
      2026-03-10 18:40 ` [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor Kuan-Wei Chiu
    @ 2026-03-11  0:09 ` Russell King (Oracle)
           [not found] ` <20260310-b4-is_err_or_null-v1-56-bd63b656022d@avm.de>
                       ` (17 subsequent siblings)
      32 siblings, 0 replies; 57+ messages in thread
    From: Russell King (Oracle) @ 2026-03-11  0:09 UTC (permalink / raw)
      To: Philipp Hahn
      Cc: amd-gfx, apparmor, bpf, ceph-devel, cocci, dm-devel, dri-devel,
    	gfs2, intel-gfx, intel-wired-lan, iommu, kvm, linux-arm-kernel,
    	linux-block, linux-bluetooth, linux-btrfs, linux-cifs, linux-clk,
    	linux-erofs, linux-ext4, linux-fsdevel, linux-gpio, linux-hyperv,
    	linux-input, linux-kernel, linux-leds, linux-media, linux-mips,
    	linux-mm, linux-modules, linux-mtd, linux-nfs, linux-omap,
    	linux-phy, linux-pm, linux-rockchip, linux-s390, linux-scsi,
    	linux-sctp, linux-security-module, linux-sh, linux-sound,
    	linux-stm32, linux-trace-kernel, linux-usb, linux-wireless,
    	netdev, ntfs3, samba-technical, sched-ext, target-devel,
    	tipc-discussion, v9fs, Julia Lawall, Nicolas Palix, Chris Mason,
    	David Sterba, Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
    	Theodore Ts'o, Andreas Dilger, Steve French, Paulo Alcantara,
    	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Bharath SM,
    	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
    	Christian Schoenebeck, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
    	Sandeep Dhavale, Hongbo Li, Chunhai Guo, Miklos Szeredi,
    	Konstantin Komarov, Andreas Gruenbacher, Kees Cook, Tony Luck,
    	Guilherme G. Piccoli, Jan Kara, Phillip Lougher, Alexander Viro,
    	Christian Brauner, Jan Kara, Steven Rostedt, Masami Hiramatsu,
    	Mathieu Desnoyers, Tejun Heo, David Vernet, Andrea Righi,
    	Changwoo Min, Ingo Molnar, Peter Zijlstra, Juri Lelli,
    	Vincent Guittot, Dietmar Eggemann, Ben Segall, Mel Gorman,
    	Valentin Schneider, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
    	Sami Tolvanen, Aaron Tomlin, Sylwester Nawrocki, Liam Girdwood,
    	Mark Brown, Jaroslav Kysela, Takashi Iwai, Max Filippov,
    	Paolo Bonzini, John Johansen, Paul Moore, James Morris,
    	Serge E. Hallyn, Andrew Morton, Alasdair Kergon, Mike Snitzer,
    	Mikulas Patocka, Benjamin Marzinski, David S. Miller, David Ahern,
    	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
    	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
    	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
    	John Fastabend, Stanislav Fomichev, Jamal Hadi Salim, Jiri Pirko,
    	Marcelo Ricardo Leitner, Xin Long, Trond Myklebust,
    	Anna Schumaker, Chuck Lever, Jeff Layton, NeilBrown,
    	Olga Kornievskaia, Dai Ngo, Jon Maloy, Johannes Berg,
    	Catalin Marinas, John Crispin, Thomas Bogendoerfer,
    	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
    	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
    	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
    	Thomas Zimmermann, David Airlie, Simona Vetter, Zhenyu Wang,
    	Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
    	Tvrtko Ursulin, Alex Deucher, Christian König, Sandy Huang,
    	Heiko Stübner, Andy Yan, Igor Russkikh, Andrew Lunn,
    	Pavan Chebbi, Michael Chan, Potnuri Bharat Teja, Tony Nguyen,
    	Przemek Kitszel, Taras Chornyi, Maxime Coquelin, Alexandre Torgue,
    	Iyappan Subramanian, Keyur Chudgar, Quan Nguyen, Heiner Kallweit,
    	Marc Zyngier, Thomas Gleixner, Andrew Lunn, Gregory Clement,
    	Sebastian Hesselbarth, Vinod Koul, Linus Walleij, Ulf Hansson,
    	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
    	Christian Borntraeger, Sven Schnelle, Martin K. Petersen,
    	Eduardo Valentin, Keerthy, Rafael J. Wysocki, Daniel Lezcano,
    	Zhang Rui, Lukasz Luba, Alex Williamson, Mark Greer,
    	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
    	Shuah Khan, Kieran Bingham, Mauro Carvalho Chehab, Joerg Roedel,
    	Will Deacon, Robin Murphy, Lee Jones, Pavel Machek, Dave Penkler,
    	K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
    	Justin Sanders, Jens Axboe, Georgi Djakov, Michael Turquette,
    	Stephen Boyd, Philipp Zabel, Borislav Petkov, Dave Hansen, x86,
    	H. Peter Anvin, Pali Rohár, Dmitry Torokhov
    
    On Tue, Mar 10, 2026 at 12:48:26PM +0100, Philipp Hahn wrote:
    > While doing some static code analysis I stumbled over a common pattern,
    > where IS_ERR() is combined with a NULL check. For that there is
    > IS_ERR_OR_NULL().
    
    One thing you need to check for each of these cases is whether the tests
    are actually correct.
    
    There are certainly cases amongst those that you have identified where
    the check for NULL is redundant.
    
    For example, get_phy_device() never returns NULL, yet in your netdev
    patch, you have at least one instance where the return value of
    get_phy_device() is checked for NULL and IS_ERR() which you then
    turn into IS_ERR_OR_NULL(). Instead, the NULL check should be dropped
    (as a separate patch.)
    
    -- 
    RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
    FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
    
    ^ permalink raw reply	[flat|nested] 57+ messages in thread
  • [parent not found: <20260310-b4-is_err_or_null-v1-56-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-6-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-8-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-13-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-16-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-22-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-25-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-28-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-39-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-54-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-41-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-36-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-49-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-48-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-2-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-50-bd63b656022d@avm.de>]
  • [parent not found: <20260310-b4-is_err_or_null-v1-12-bd63b656022d@avm.de>]
  • * Re: [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor
           [not found] <20260310-b4-is_err_or_null-v1-0-bd63b656022d@avm.de>
                       ` (31 preceding siblings ...)
           [not found] ` <20260310-b4-is_err_or_null-v1-12-bd63b656022d@avm.de>
    @ 2026-04-09 18:16 ` Al Viro
      32 siblings, 0 replies; 57+ messages in thread
    From: Al Viro @ 2026-04-09 18:16 UTC (permalink / raw)
      To: Philipp Hahn
      Cc: amd-gfx, apparmor, bpf, ceph-devel, cocci, dm-devel, dri-devel,
    	gfs2, intel-gfx, intel-wired-lan, iommu, kvm, linux-arm-kernel,
    	linux-block, linux-bluetooth, linux-btrfs, linux-cifs, linux-clk,
    	linux-erofs, linux-ext4, linux-fsdevel, linux-gpio, linux-hyperv,
    	linux-input, linux-kernel, linux-leds, linux-media, linux-mips,
    	linux-mm, linux-modules, linux-mtd, linux-nfs, linux-omap,
    	linux-phy, linux-pm, linux-rockchip, linux-s390, linux-scsi,
    	linux-sctp, linux-security-module, linux-sh, linux-sound,
    	linux-stm32, linux-trace-kernel, linux-usb, linux-wireless,
    	netdev, ntfs3, samba-technical, sched-ext, target-devel,
    	tipc-discussion, v9fs, Julia Lawall, Nicolas Palix, Chris Mason,
    	David Sterba, Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
    	Theodore Ts'o, Andreas Dilger, Steve French, Paulo Alcantara,
    	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Bharath SM,
    	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
    	Christian Schoenebeck, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
    	Sandeep Dhavale, Hongbo Li, Chunhai Guo, Miklos Szeredi,
    	Konstantin Komarov, Andreas Gruenbacher, Kees Cook, Tony Luck,
    	Guilherme G. Piccoli, Jan Kara, Phillip Lougher,
    	Christian Brauner, Jan Kara, Steven Rostedt, Masami Hiramatsu,
    	Mathieu Desnoyers, Tejun Heo, David Vernet, Andrea Righi,
    	Changwoo Min, Ingo Molnar, Peter Zijlstra, Juri Lelli,
    	Vincent Guittot, Dietmar Eggemann, Ben Segall, Mel Gorman,
    	Valentin Schneider, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
    	Sami Tolvanen, Aaron Tomlin, Sylwester Nawrocki, Liam Girdwood,
    	Mark Brown, Jaroslav Kysela, Takashi Iwai, Max Filippov,
    	Paolo Bonzini, John Johansen, Paul Moore, James Morris,
    	Serge E. Hallyn, Andrew Morton, Alasdair Kergon, Mike Snitzer,
    	Mikulas Patocka, Benjamin Marzinski, David S. Miller, David Ahern,
    	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
    	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
    	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
    	John Fastabend, Stanislav Fomichev, Jamal Hadi Salim, Jiri Pirko,
    	Marcelo Ricardo Leitner, Xin Long, Trond Myklebust,
    	Anna Schumaker, Chuck Lever, Jeff Layton, NeilBrown,
    	Olga Kornievskaia, Dai Ngo, Jon Maloy, Johannes Berg,
    	Catalin Marinas, Russell King, John Crispin, Thomas Bogendoerfer,
    	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
    	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
    	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
    	Thomas Zimmermann, David Airlie, Simona Vetter, Zhenyu Wang,
    	Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
    	Tvrtko Ursulin, Alex Deucher, Christian König, Sandy Huang,
    	Heiko Stübner, Andy Yan, Igor Russkikh, Andrew Lunn,
    	Pavan Chebbi, Michael Chan, Potnuri Bharat Teja, Tony Nguyen,
    	Przemek Kitszel, Taras Chornyi, Maxime Coquelin, Alexandre Torgue,
    	Iyappan Subramanian, Keyur Chudgar, Quan Nguyen, Heiner Kallweit,
    	Marc Zyngier, Thomas Gleixner, Andrew Lunn, Gregory Clement,
    	Sebastian Hesselbarth, Vinod Koul, Linus Walleij, Ulf Hansson,
    	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
    	Christian Borntraeger, Sven Schnelle, Martin K. Petersen,
    	Eduardo Valentin, Keerthy, Rafael J. Wysocki, Daniel Lezcano,
    	Zhang Rui, Lukasz Luba, Alex Williamson, Mark Greer,
    	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
    	Shuah Khan, Kieran Bingham, Mauro Carvalho Chehab, Joerg Roedel,
    	Will Deacon, Robin Murphy, Lee Jones, Pavel Machek, Dave Penkler,
    	K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
    	Justin Sanders, Jens Axboe, Georgi Djakov, Michael Turquette,
    	Stephen Boyd, Philipp Zabel, Borislav Petkov, Dave Hansen, x86,
    	H. Peter Anvin, Pali Rohár, Dmitry Torokhov
    
    On Tue, Mar 10, 2026 at 12:48:26PM +0100, Philipp Hahn wrote:
    > While doing some static code analysis I stumbled over a common pattern,
    > where IS_ERR() is combined with a NULL check. For that there is
    > IS_ERR_OR_NULL().
    
    ... and valid uses of IS_ERR_OR_NULL are rare as hen teeth.
    Most of those are "I'm not sure how this function returns an
    error, let's use that just in case".
    
    Please, do not introduce more of that crap.
    
    ^ permalink raw reply	[flat|nested] 57+ messages in thread

  • end of thread, other threads:[~2026-04-10 15:26 UTC | newest]
    
    Thread overview: 57+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <20260310-b4-is_err_or_null-v1-0-bd63b656022d@avm.de>
         [not found] ` <20260310-b4-is_err_or_null-v1-37-bd63b656022d@avm.de>
    2026-03-10 12:08   ` [cocci] [PATCH 37/61] drm: Prefer IS_ERR_OR_NULL over manual NULL check Christian König
         [not found] ` <20260310-b4-is_err_or_null-v1-61-bd63b656022d@avm.de>
    2026-03-10 12:23   ` [cocci] [PATCH 61/61] file: Drop unlikely() around IS_ERR_OR_NULL() Jeff Layton
         [not found] ` <20260310-b4-is_err_or_null-v1-18-bd63b656022d@avm.de>
    2026-03-10 12:28   ` [cocci] [PATCH 18/61] sound: Prefer IS_ERR_OR_NULL over manual NULL check Mark Brown
         [not found] ` <20260310-b4-is_err_or_null-v1-57-bd63b656022d@avm.de>
    2026-03-10 12:43   ` [cocci] [PATCH 57/61] reset: " Philipp Zabel
    2026-03-11  4:59   ` Masami Hiramatsu
         [not found] ` <20260310-b4-is_err_or_null-v1-46-bd63b656022d@avm.de>
    2026-03-10 12:53   ` [cocci] [PATCH 46/61] vfio: " Pranjal Shrivastava
    2026-03-11  9:25   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
    2026-03-16 22:10   ` [cocci] " Alex Williamson
         [not found] ` <20260310-b4-is_err_or_null-v1-30-bd63b656022d@avm.de>
    2026-03-10 12:23   ` [cocci] [PATCH 30/61] net/sunrpc: " Jeff Layton
    2026-03-10 13:23   ` Chuck Lever
    2026-03-11  9:22   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-24-bd63b656022d@avm.de>
    2026-03-10 13:47   ` [cocci] [PATCH 24/61] net/9p: " Christian Schoenebeck
    2026-03-11  9:19   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-15-bd63b656022d@avm.de>
    2026-03-10 14:07   ` [cocci] [PATCH 15/61] trace: " Steven Rostedt
    2026-03-11  5:13     ` Masami Hiramatsu
    2026-03-11 14:03       ` Steven Rostedt
    2026-03-11 14:06         ` Geert Uytterhoeven
    2026-03-10 14:14 ` [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor Steven Rostedt
    2026-03-10 14:23 ` Theodore Tso
         [not found] ` <20260310-b4-is_err_or_null-v1-17-bd63b656022d@avm.de>
    2026-03-10 14:45   ` [cocci] [PATCH 17/61] module: Prefer IS_ERR_OR_NULL over manual NULL check Aaron Tomlin
    2026-03-11  9:18   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-38-bd63b656022d@avm.de>
    2026-03-10 15:07   ` [cocci] [EXTERNAL] [PATCH 38/61] net: " Elad Nachman
    2026-03-11  0:16   ` [cocci] " Russell King (Oracle)
    2026-03-11  9:24   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
    2026-03-12 16:11   ` [cocci] " Przemek Kitszel
         [not found] ` <20260310-b4-is_err_or_null-v1-3-bd63b656022d@avm.de>
    2026-03-10 18:13   ` [cocci] [PATCH 03/61] ceph: " Viacheslav Dubeyko
    2026-03-11  8:16   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
    2026-03-10 18:40 ` [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor Kuan-Wei Chiu
    2026-03-12 12:57   ` Jason Gunthorpe
    2026-03-12 15:32     ` James Bottomley
    2026-03-12 16:54       ` Jason Gunthorpe
    2026-03-11  0:09 ` Russell King (Oracle)
         [not found] ` <20260310-b4-is_err_or_null-v1-56-bd63b656022d@avm.de>
    2026-03-10 13:21   ` [cocci] [PATCH 56/61] clk: Prefer IS_ERR_OR_NULL over manual NULL check Brian Masney
    2026-03-11  2:07   ` Chen-Yu Tsai
         [not found] ` <20260310-b4-is_err_or_null-v1-6-bd63b656022d@avm.de>
    2026-03-10 13:45   ` [cocci] [PATCH 06/61] 9p: " Christian Schoenebeck
    2026-03-11  8:17   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
    2026-03-11  8:29   ` [cocci] " Dominique Martinet
         [not found] ` <20260310-b4-is_err_or_null-v1-8-bd63b656022d@avm.de>
    2026-03-11  8:18   ` [cocci] [Intel-wired-lan] [PATCH 08/61] fuse: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-13-bd63b656022d@avm.de>
    2026-03-11  8:19   ` [cocci] [Intel-wired-lan] [PATCH 13/61] squashfs: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-16-bd63b656022d@avm.de>
    2026-03-11  9:16   ` [cocci] [Intel-wired-lan] [PATCH 16/61] sched: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-22-bd63b656022d@avm.de>
    2026-03-11  9:19   ` [cocci] [Intel-wired-lan] [PATCH 22/61] md: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-25-bd63b656022d@avm.de>
    2026-03-10 13:55   ` [cocci] [PATCH 25/61] net/bluetooth: " Bastien Nocera
    2026-03-11  9:21   ` [cocci] [Intel-wired-lan] " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-28-bd63b656022d@avm.de>
    2026-03-11  9:22   ` [cocci] [Intel-wired-lan] [PATCH 28/61] net/sched: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-39-bd63b656022d@avm.de>
    2026-03-11  9:24   ` [cocci] [Intel-wired-lan] [PATCH 39/61] irqchip: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-54-bd63b656022d@avm.de>
    2026-03-11  9:26   ` [cocci] [Intel-wired-lan] [PATCH 54/61] aoe: " Loktionov, Aleksandr
         [not found] ` <20260310-b4-is_err_or_null-v1-41-bd63b656022d@avm.de>
    2026-03-11  9:32   ` [cocci] [PATCH 41/61] pinctrl: " Linus Walleij
         [not found] ` <20260310-b4-is_err_or_null-v1-36-bd63b656022d@avm.de>
    2026-03-11 13:15   ` [cocci] [PATCH 36/61] arch/sh: " Geert Uytterhoeven
         [not found] ` <20260310-b4-is_err_or_null-v1-49-bd63b656022d@avm.de>
    2026-03-11  9:25   ` [cocci] [Intel-wired-lan] [PATCH 49/61] media: " Loktionov, Aleksandr
    2026-03-11 23:03   ` [cocci] " Kieran Bingham
         [not found] ` <20260310-b4-is_err_or_null-v1-48-bd63b656022d@avm.de>
    2026-03-12 19:33   ` [cocci] [PATCH 48/61] mtd: " Richard Weinberger
         [not found] ` <20260310-b4-is_err_or_null-v1-2-bd63b656022d@avm.de>
    2026-03-13 19:22   ` [cocci] [PATCH 02/61] btrfs: " David Sterba
         [not found] ` <20260310-b4-is_err_or_null-v1-50-bd63b656022d@avm.de>
    2026-03-11  9:26   ` [cocci] [Intel-wired-lan] [PATCH 50/61] iommu: " Loktionov, Aleksandr
    2026-03-16 13:30   ` [cocci] " Robin Murphy
         [not found] ` <20260310-b4-is_err_or_null-v1-12-bd63b656022d@avm.de>
    2026-03-11  8:19   ` [cocci] [Intel-wired-lan] [PATCH 12/61] quota: " Loktionov, Aleksandr
    2026-03-19 14:13   ` [cocci] " Jan Kara
    2026-04-09 18:16 ` [cocci] [PATCH 00/61] treewide: Use IS_ERR_OR_NULL over manual NULL check - refactor Al Viro
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox