mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: dm-devel@lists.linux.dev, Alasdair Kergon <agk@redhat.com>,
	 Benjamin Marzinski <bmarzins@redhat.com>,
	 Mike Snitzer <snitzer@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 kernel-janitors@vger.kernel.org
Subject: Re: dm: Use common error handling code in three functions
Date: Thu, 11 Jun 2026 15:25:17 +0200 (CEST)	[thread overview]
Message-ID: <fd9dc2eb-5fb2-fda0-1e8d-e1c7c2f4aee9@redhat.com> (raw)
In-Reply-To: <3b8e5056-0611-43eb-9fc3-c82f0511d466@web.de>

[-- Attachment #1: Type: text/plain, Size: 1707 bytes --]



On Thu, 11 Jun 2026, Markus Elfring wrote:

> >> Use additional labels so that a bit of exception handling can be better
> >> reused at the end of three if branches.
> >>
> >> This issue was detected by using the Coccinelle software.
> > 
> > Hi
> > 
> > I think that jumping into a nested block isn't good practice and it makes 
> > the code harder to read and maintain. I would redo the patches so that 
> > they jump to the end of the topmost function block, for example:
> Thanks for your constructive feedback.
> 
> Can any further adjustments become feasible for the design goal “Centralized exiting of functions”?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.1-rc7#n526

I think that this document is OK.

> Would you find goto chains applicable for another while?
> https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/recommendations/memory-management-mem/mem12-c/

I think goto chains are ok if there are few variables to free.

> How do you think about to increase the application of scope-based resource management?
> https://elixir.bootlin.com/linux/v7.1-rc7/source/include/linux/cleanup.h

I am not a fan of these. I think that goto is OK if there are few 
variables to clean-up. If there is a large number of variables to clean 
up, it's better to zero-fill the whole structure and free the entries 
unconditionally (kfree does noting if it gets NULL) - see for example 
dm_integrity_ctr - it allocates the structure with kzalloc_obj and on any 
error it jumps to the label "bad" that calls dm_integrity_dtr - and 
dm_integrity_dtr frees all non-NULL entries.

Mikulas

> Regards,
> Markus

      reply	other threads:[~2026-06-11 13:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 20:00 [PATCH] " Markus Elfring
2026-06-10 19:49 ` Mikulas Patocka
2026-06-11  5:33   ` Markus Elfring
2026-06-11 13:25     ` Mikulas Patocka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fd9dc2eb-5fb2-fda0-1e8d-e1c7c2f4aee9@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=Markus.Elfring@web.de \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®