mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Jarkko Sakkinen <jarkko@kernel.org>,
	Stefano Garzarella <sgarzare@redhat.com>
Cc: linux-integrity@vger.kernel.org,
	Sumit Garg <sumit.garg@kernel.org>,
	 Jens Wiklander <jens.wiklander@linaro.org>,
	Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>,
	Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tpm: Make chip->{status,cancel,req_canceled} opt
Date: Thu, 27 Mar 2025 10:12:36 -0400	[thread overview]
Message-ID: <56428ff1ac4355482df881e6226518c2a62beb6d.camel@HansenPartnership.com> (raw)
In-Reply-To: <Z-VRWy8jLkA0cpow@kernel.org>

On Thu, 2025-03-27 at 15:23 +0200, Jarkko Sakkinen wrote:
> On Thu, Mar 27, 2025 at 10:58:00AM +0100, Stefano Garzarella wrote:
[...]
> > > @@ -65,6 +89,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip
> > > *chip, void *buf, size_t bufsiz)
> > > 	ssize_t len = 0;
> > > 	u32 count, ordinal;
> > > 	unsigned long stop;
> > > +	u8 status;
> > 
> > Why move `status` out of the do/while block?
> 
> I'm not a huge fan of stack allocations inside blocks, unless there
> is a particular reason to do so.

The move to scope based locking and freeing in cleanup.h necessitates
using scope based variables as well, so they're something we all have
to embrace.  They're also useful to tell the compiler when it can
reclaim the variable and they often create an extra stack frame that
allows the reclaim to be effective (even if the compiler can work out
where a variable is no longer reference, the space can't be reclaimed
if it's in the middle of an in-use stack frame).  I'd say the rule of
thumb should be only do something like this if it improves readability
or allows you to remove an additional block from the code.

Regards,

James


  reply	other threads:[~2025-03-27 14:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26 16:18 Jarkko Sakkinen
2025-03-27  9:58 ` Stefano Garzarella
2025-03-27 13:23   ` Jarkko Sakkinen
2025-03-27 14:12     ` James Bottomley [this message]
2025-03-27 15:00       ` Jarkko Sakkinen
2025-03-27 15:06         ` Jarkko Sakkinen
2025-03-27 15:37           ` Stefano Garzarella
2025-03-27 21:29             ` Jarkko Sakkinen
2025-03-27 15:33     ` Stefano Garzarella

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=56428ff1ac4355482df881e6226518c2a62beb6d.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=jarkko.sakkinen@opinsys.com \
    --cc=jarkko@kernel.org \
    --cc=jens.wiklander@linaro.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=sgarzare@redhat.com \
    --cc=sumit.garg@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®