Re: [PATCH] ecryptfs: streamline offset formatting in ecryptfs_derive_iv

From: Thorsten Blum

Date: Mon Mar 30 2026 - 04:04:55 EST


On Mon, Mar 30, 2026 at 03:00:04AM +0200, Thorsten Blum wrote:
> On Sun, Mar 29, 2026 at 03:05:05PM -0700, Eric Biggers wrote:
> > This isn't exactly "streamlining" the code. memset(p, 0, 16) tends to
> > get compiled into just two instructions. In contrast, a variable-length
> > memset tends to be several instructions to set up, plus a call
> > instruction, and the instructions inside memset() itself. scnprintf()
> > is also a few more instructions than snprintf().
> >
> > So I'd say the old version is more "streamlined", actually. Granted,
> > the difference is probably only a few cycles, but it sounds like the
> > motivation for this patch is that you assumed the new version is faster?
>
> I meant "streamline" as in write bytes once.
>
> Maybe we should just zero-initialize the 32 bytes in 'src' instead and
> keep snprintf(). That removes the need to keep track of 'len' and also
> gets rid of the explicit memset(0).

Let's drop this patch and I'll send a new one to fix the typo and remove
the TODO. Keeping the explicit memset(0) is probably best here. Thanks!