public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: david laight <david.laight@runbox.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>, Chris Mason <clm@fb.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: Replace memcpy + NUL termination in _btrfs_printk
Date: Wed, 3 Dec 2025 14:45:58 +0100	[thread overview]
Message-ID: <20251203134558.GG13846@suse.cz> (raw)
In-Reply-To: <20251130110640.21eadec5@pumpkin>

On Sun, Nov 30, 2025 at 11:06:40AM +0000, david laight wrote:
> On Sun, 30 Nov 2025 01:55:17 +0100
> Thorsten Blum <thorsten.blum@linux.dev> wrote:
> 
> > Use strscpy() to copy the NUL-terminated source string 'fmt' to the
> > destination buffer 'lvl' instead of using memcpy() followed by a manual
> > NUL termination.  No functional changes.
> 
> Why?
> The code has just got the length of part of the format string, it wants
> a copy of it with a '\0' terminator.
> So memcpy() is correct and strscpy() just expensive.
> The code is actually strange (and strangely written), but 'size' is always 2.
> 
> One might question why btrfs has to invent its own 'printk' scheme...

The first code of the printk helper was added in 2012 as 4da35113426d
("btrfs: add varargs to btrfs_error") and since then it evolved a lot
and I'm not sure we still need it.

Own helpers for messages insert the filesystem identification in front
of the message. There's per-level ratelimit which needs the parsing
added in commit 35f4e5e6f198 ("btrfs: Add ratelimit to btrfs printing").
This can be possibly removed as we can ratelimit specific messages if
they're known to be noisy.

  reply	other threads:[~2025-12-03 13:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-30  0:55 [PATCH] btrfs: Replace memcpy + NUL termination in _btrfs_printk Thorsten Blum
2025-11-30 11:06 ` david laight
2025-12-03 13:45   ` David Sterba [this message]
2025-12-15 20:22     ` David Sterba

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=20251203134558.GG13846@suse.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=david.laight@runbox.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    /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