From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43B0B3E8C46 for ; Tue, 14 Apr 2026 15:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776181615; cv=none; b=OaPxYjlxM+FM87OhDfW2QGWIBXUi+TvlQtGYHERM9uDd8F2wRHOg9pYz7Qou8YsECHMyBEYwbpezCEI8cLzpHlSiVenTRcQjTEbHy7+9LK6KNYGCjzD/rvxZ5B0N0SnrKVHmGjEDX2upQ91v7Us25YDEgzbO7Ne+acRHJq2vBwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776181615; c=relaxed/simple; bh=GiYpLqYi3P1iGFK52BCLkvZR0OF/r/eycYIK5j84Qg8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o7Yo623BN3cGTGzInIJrkXuiQYD1pxZ0gsk5Y2owCfjS5cybX3vdffTs36e1QSFO1j1w5C27w+FXLW8elvZ34imjHOQl7QAhn6lB38pBlMJMD5P97FUoOy8XnkXuxsjdSHx2YILNm6hw3moQz1SDp1rM5gW94SYzzOwXIsTWEZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lx+aK315; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lx+aK315" Date: Tue, 14 Apr 2026 17:46:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776181611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g7Rqg4KhA8BbSswvIE/HHqprQLrlpUzKyNqNmCJfiXE=; b=lx+aK315XjlwwfxSQmUz7wFBzVN32LHedEVrdSkExARRjXIE7x3tL4RYsXWb51KNmdYm0S tgp9D0zGkfQUrA26aUJdTLrON+uy2n7TpDMQRNG/duN40pxV02E550+U9c5IyDxXCJlA+/ 4YZ+F7MyEUo4rg7MlVLCMsDhkI9sk2Q= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats Message-ID: References: <20260318001426.2664-3-thorsten.blum@linux.dev> <20260318203739.GO3738010@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260318203739.GO3738010@noisy.programming.kicks-ass.net> X-Migadu-Flow: FLOW_OUT On Wed, Mar 18, 2026 at 09:37:39PM +0100, Peter Zijlstra wrote: > On Wed, Mar 18, 2026 at 01:14:27AM +0100, Thorsten Blum wrote: > > Replace snprintf("%s", ...) with the faster and more direct strscpy(). > > > > Reviewed-by: Waiman Long > > Signed-off-by: Thorsten Blum > > --- > > kernel/locking/lockdep_proc.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c > > index 1916db9aa46b..e458fa258d05 100644 > > --- a/kernel/locking/lockdep_proc.c > > +++ b/kernel/locking/lockdep_proc.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) > > const char *key_name; > > > > key_name = __get_key_name(ckey, str); > > - snprintf(name, namelen, "%s", key_name); > > + strscpy(name, key_name, namelen); > > } else { > > - snprintf(name, namelen, "%s", cname); > > + strscpy(name, cname, namelen); > > } > > rcu_read_unlock_sched(); > > Why though? I suppose it doesn't matter, but this hardly seems worth the > electrons is was sent with :/ Is "faster and more direct" not a reason? There's nothing to format so the format specifier is unnecessary and can be removed.