From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 615A0C83030 for ; Mon, 7 Jul 2025 22:18:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB30B6B03D5; Mon, 7 Jul 2025 18:18:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92BB76B03D6; Mon, 7 Jul 2025 18:18:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E2316B03D7; Mon, 7 Jul 2025 18:18:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 495D66B03D5 for ; Mon, 7 Jul 2025 18:18:13 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C56231A03CE for ; Mon, 7 Jul 2025 22:18:12 +0000 (UTC) X-FDA: 83638882824.12.1B3B498 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by imf10.hostedemail.com (Postfix) with ESMTP id A3B10C0010 for ; Mon, 7 Jul 2025 22:18:10 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=D6kMjTtY; spf=pass (imf10.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.218.48 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751926690; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vUqqsbRlIl+0KIYJcUROFT1sVqNppMFyhgNr/RPU0Ys=; b=mfjoBkJy1U+E58fhXmR3hXuSyTu2lPhR1Mw+Qs4Hj0VD0fGlf1WmQxEqMGonguukJAEakb GIKp+KbSxdbgxiNLkUBDIntoWHOniqWwHCvFDCD9qmJNsnXc8cUZNzyyCbzLQCsKyYVBx4 60nJMMlIHZzH884glZtEMS3ZqMH0wJc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751926690; a=rsa-sha256; cv=none; b=b0NkYTG4aPAJbbaIvlv3gMc7vcc6KVwubM0UIEYw/u1DeB+BZ+fMF5gowyFXIS+ovD/Po6 Z2dZE5TBnWWEiOvgSEmxw4NN7qC5fRuzdmvO60VSNpu4araexkkUgO09oMvQh9600Tnkry EFm1XF85iXfRXp5dg4sa7XHrdF72ico= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=D6kMjTtY; spf=pass (imf10.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.218.48 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-ae36dc91dc7so634705066b.2 for ; Mon, 07 Jul 2025 15:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1751926689; x=1752531489; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vUqqsbRlIl+0KIYJcUROFT1sVqNppMFyhgNr/RPU0Ys=; b=D6kMjTtYsbwVi/ehY57UfVGSrm+O0n9Hj8Q42Lgf+Lq50tiF1hxvSPi4H09Sn2mWa4 7DHNwpV8vHl5TlTmK7B3T8m0dA5obsTpzTHOYjAhHHAX85i/9yGrWrKxNnRZ/21v35yB uZtbwZ/m11akSwxDSRrHqQtGvLDgV9afeWGpI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751926689; x=1752531489; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vUqqsbRlIl+0KIYJcUROFT1sVqNppMFyhgNr/RPU0Ys=; b=J4zsCoWnmp3k2ZuahVDXrE/b3pb/UGABQxYk/cNO5Lp2mKrE9ZW3CdS2AXh/cE2E9l LzvDNU5gTwuKxZHdBgWIE4IHqg0wwaa5GSZCBTDAZc0oVgbJ+9xJ6Xs41bDNKuNYnVMY sVdDK8abhv4w7bJyKP5VyXM/o4gatKAFWArQiLjpfLVlf48cBtfvaof7if49f0vqdV31 z27tStr1kXUtaLahU6OyY0PwKjayuWotBELNJUB+/zqnuvE51RbRzfL61iRZW+4pmclB z5at8eP5K/ScdQBS/eedMk82+g58IFAXAjCuTGjNowjk1qEgfQkZKFvHj14oIrDBtIWj 04Yg== X-Gm-Message-State: AOJu0Yx1n1vkzW3DsemLp+ubnjBBhfExtPVOsul1OMXBPYtOkut/SNh0 DWBcMIyu4sElKmEECeUD4aAzXFXmArvOlUmRiuW7SbYT/9FLw0LaEb6xm62qV57oMGGQOLCi7JQ zMLekxx0wmQ== X-Gm-Gg: ASbGncvN5EmCeN+GfZt4yXRDv+TECxrKKwTlb81FnUBYxZJf6EkwBqAtcGGnO5oAEYk aAPrL54zBv+nnhENTZSlnTgDtgGAXweM+c6zeL/JegFCI/EkRlAwLUoXJAiTPrKS8TkzgRgsQfR dRNZCIR10MSyeRKHoAYuOOvnXDUtQztrfpizdMGtPLecK8WDCAENaaDk8E6Kn088btrWWmVz17g Q7ifNEngFGJ0wwOhpO54Qkd9DcpdzwDWuiobUZQyelBv5m4CMFBtevnWVnzBY3hEPYRCI00aHRt AtBO+sxUFBAhgCLcZQ0Tw/6ploD65WbLzsT8BQrdHXQc6PJfmnm76Q0oUoeHFDLMQ6060C2u/eF c1v+wOWULgw0t6P18wEN8CLO5YL0owSJY5Km2 X-Google-Smtp-Source: AGHT+IGWCTzL4oKRfq2ImWA5UJTJ5w8xhIFE6i5GjNK4YO3A2oJddNeRopKYls0INfWxt3N1fqDljA== X-Received: by 2002:a17:907:9711:b0:ade:4121:8d3d with SMTP id a640c23a62f3a-ae3fe64e0e1mr1355498866b.12.1751926688725; Mon, 07 Jul 2025 15:18:08 -0700 (PDT) Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com. [209.85.208.44]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae3f6bb1d4dsm791943366b.178.2025.07.07.15.18.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Jul 2025 15:18:07 -0700 (PDT) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-6077dea37easo6037698a12.3 for ; Mon, 07 Jul 2025 15:18:06 -0700 (PDT) X-Received: by 2002:a05:6402:2356:b0:60c:461e:71c0 with SMTP id 4fb4d7f45d1cf-60fd6e04c9emr12735823a12.30.1751926686474; Mon, 07 Jul 2025 15:18:06 -0700 (PDT) MIME-Version: 1.0 References: <033bf00f1fcf808245ae150346019aa7b997ea11.1751862634.git.alx@kernel.org> In-Reply-To: From: Linus Torvalds Date: Mon, 7 Jul 2025 15:17:50 -0700 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXx7EVbwgcu_kwWLSiLwlTlYjfwq5vvQwKm9O0uZQ7guWOwdxI-MvQMXh0I Message-ID: Subject: Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs To: Alejandro Colomar Cc: linux-mm@kvack.org, linux-hardening@vger.kernel.org, Kees Cook , Christopher Bazley , shadow <~hallyn/shadow@lists.sr.ht>, linux-kernel@vger.kernel.org, Andrew Morton , kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Marco Elver , Christoph Lameter , David Rientjes , Vlastimil Babka , Roman Gushchin , Harry Yoo , Andrew Clayton , Sven Schnelle , Heiko Carstens , Tvrtko Ursulin , "Huang, Ying" , Lee Schermerhorn , Christophe JAILLET , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Chao Yu Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A3B10C0010 X-Stat-Signature: gb8oiu5pk9y5w4rxk9mj5q4eandsjmeg X-HE-Tag: 1751926690-779532 X-HE-Meta: U2FsdGVkX1/yZ9kZxAOGKWzrjoMSqWt5elOe95ypSzLDzupcZmhsfIILtNPZciGgbiLEL2xQUOvDPQ7vLq29bxu1B+TM1t0h6GZ30ut4qVrC1WHpkD1XXMoU1JzemtlmxQifJGZdYh2fM+V6/6oObZePdSAfIu/ibj9HSFeB1UHbSA3ewfHULyXVvwnuSmM9EN3UEf+KePhvk6x5Rj4810zwTOygeczSgU0UloJyXCGKLWIQOELNdvkjAAjOGStLrvGMMlwXM843m4mTBc9RROas9bPvdH6X3OXb/dWbt/uGv7W2FkEoBzsCzTIN+WnWqkdQNGrDFxQ50zaoUM+mmykxrWEy6dH+oyQSGN4nG4K0LWkWyx5dj79jMZBKtvgfIjZdYmDa3qUI+Uo9KAMWSwXEpekVqvIKmi0UD0ZCgJjOzL5hNyzLjHgC+Ky44nZt7Jm6iQBYq3fLFwSMsbOtdqlaSrIqyL5ohQzPw7L+BNm6x89gJ0yP2s8rHVm4i8ebXlsyv+MZLnCW2ttLsCRjIs0wX9VEbBmq2ElzzYDvb/2or/bfmnFsTWGrdqgilD6u6NDbSwXns/1pZnug7plBzjCOLROwpE1GfGN5zSyB4UCt9FMWt1IOw334BjejFB56Xenv+iblJ/fMjB1oIBFlVkuz0w5lyK+9KFK4fa2n3vsZs+e6gM4DZMBQIWVwcMhj8+D56os7EZTFIEFDOIc6YaAkSIa6v8+jjVTFLCG9yAsUyjnLkNQA7YYQ1c9ym+KZkpK6R/TFOc6MCr/fV/UyOStABIGdz4nOm62X3/EpW36hCJlUXaAeUoAhzKBBg7LITyKYnZYlyOpDEx7wsalGxiRs9AocJ7ER+8NiuwUB9SYDDRCrO1r011+jfoZgmOprZhNlJd1deud+KpRB7cpn31qo0wDoD2Cd6iUHmjF5P3h7EqVI0ilQGnOe0C0I/1nBemyk/3XXqSkaZWW6zV+ yv5DBUou G8mzKCgoG9gETuwqbIwWbYPqhmNj+4yhvUGbET3tTKrQjsMPdkAa2E4xNCyo/RJ51dCrfH3vJh7xuSRaYL7w6KsWmgcfppzGscN76472joAxBQsxmKt+4e00Zrk/K/QVCc1f6bRCSVE8NaCp8qBGIfUzv+YxBbfRuQKSdv07d8NrTzb/nmGO15TlbpRTiObpYR6qtIG9IRAcUvI1rMMOtAdI75jC+2nw9BKoFQETViYlhAVfLdouw6iOLXktLrg4I/We87uWIht5sfYswFNc9QFKQZD0QtE+mhDa9X8hdmQYkB7yv7mYt0mFlUTUyNl/Qel/do2PLz/5pzcgTJAvNdOV+U3CRKPef1gH4De4OfQWewvg0dptf9RTymwc1Csr2z+/yNtuNWTE3LCE3FPZaGhX5avpKDFqsY2ijeUv20h4pglIslvZacrYsAKgxWcpJvzFVwXAS2Q35YXGvtxuEe4Hcg0RUqnhFUqYYA5b+Gmr2i744u9gq9b2251rJqxfevR/T//VSMTOJrRq8kOzEr3WTg5mL/EMYXw4W0AdA9HVhAE4ourB1sInBfxelsZd5ObBEJ0bOYK8ojbZD42fLs6WnOjkIR/2IToXN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, 7 Jul 2025 at 14:27, Alejandro Colomar wrote: > > If the name is your main concern, we can discuss a more explicit name in > the kernel. So as they say: "There are only two hard problems in computer science: cache invalidation, naming and off-by-one errors". And the *worst* model for naming is the "add random characters" (ok, I still remember when people believed the insane "Hungarian Notation" BS, *that* particular braindamage seems to thankfully have faded away and was probably even worse, because it was both pointless, unreadable _and_ caused long identifiers). Now, we obviously tend to have the usual bike-shedding discussions that come from naming, but my *personal* preference is to avoid the myriad of random "does almost the same thing with different parameters" by using generics. This is actually something that the kernel has done for decades, with various odd macro games - things like "get_user()" just automatically doing the RightThing(tm) based on the size of the argument, rather than having N different versions for different types. So we actually have a fair number of "generics" in the kernel, and while admittedly the header file contortions to implement them can often be horrendous - the *use* cases tend to be fairly readable. It's not just get_user() and friends, it's things like our type-checking min/max macros etc. Lots of small helpers that And while the traditional C model for this is indeed macro games with sizeof() and other oddities, these days at least we have _Generic() to help. So my personal preference would actually be to not make up new names at all, but just have the normal names DoTheRightThing(tm) automatically. But honestly, that works best when you have good data structure abstraction - *not* when you pass just random "char *" pointers around. It tends to help those kinds of _Generic() users, but even without the use of _Generic() and friends, it helps static type checking and makes things much less ambiguous even in general. IOW, there's never any question about "is this string the source or the destination?" or "is this the start or the end of the buffer", if you just have a struct with clear naming that contains the arguments. And while C doesn't have named arguments, it *does* have named structure initializers, and we use them pretty religiously in the kernel. Exactly because it helps so much both for readability and for stability (ie it catches things when you intentionally rename members because the semantics changed). Linus