From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 279E430567B for ; Wed, 3 Jun 2026 11:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780486449; cv=none; b=Fw3feL5pzf8rpOhHbzL8xMVQD0yf6tmuhceNFFIgqtuyLqMf4MkOgxJA5ZUAL4sR9W6ZLNjCnMbcHpkhRe4WtGWgYvS1AFwFBYO45xkfWjAbD5adAuRIc4P1205Bl9ij4X2zAK8PV2DGSgJVyBNjHQa08ugZKbd3BsWP/1GtwGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780486449; c=relaxed/simple; bh=RapGnouF+GPxTpweAF63f1cUVcBqdgw5nFoBRQ+4xSQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pAwun+FbtRiHO0IgVaBAi/t5fAPHhgIrKSeAMmoVMZ0byWyJEYMhjBHq6+SJsrxy6wKC+hyHIXDYamdpKHNRlFJ1UXUAqaiap5cwxCe6IxPj3XA/R8yYTr6+9hUcV+GD08Rcn+Rje/6Vc6IxW9VvAAWQIpfsYiArJLkTOKLXhG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C7Mk1JhM; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7Mk1JhM" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49050ff7cbdso117481065e9.2 for ; Wed, 03 Jun 2026 04:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780486446; x=1781091246; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=6kxfPbGPtsYnZe1bXs6s72zMs7r5+MiXzexuNNu0kkA=; b=C7Mk1JhMyhqvJs+niRkPH/0OBGwsTLTMMFAyAL2Povfuz82HLfmvB982rpNVv7g7h0 mOT3IsYh2uwcCaTveri8OkzZ9+cpQSZlApZdmBNXu2JORQTO9OKXpDPWRX0sQM7IrZvK WlqgkXSMZwOlDWp+znUReYcAe3LUeVMQPcIUTIWAYeZdHYvWbbBW9GbJN/sXQWPsIw3f ET2Y9CKG/8DdJqwreiyGa3DfGulneDCn8Gv/10wM0xjG/uGUgv4bXIZZCYvfLaRmamzR H8MumXF+I6MpNIEp4Y0XvH7csJXOlziYbAKgXZbZnaZJU3j0V37MW+FMePqJt9+eNlg1 pxew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780486446; x=1781091246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6kxfPbGPtsYnZe1bXs6s72zMs7r5+MiXzexuNNu0kkA=; b=mFyaQX7xofMQXEsX4XtenDgLyMzqgBAnc2rMdKKI4jVD4/yo0zLTApW3Y2N/0dXvLM BF3xHCPS5XoznAIIDyafzWkwA+KWyTQtLWZAuMIxLd7xzGjRKXbELQNayx/2eFK5IMjT QfI9RvehA/pVGBgPkfbdTtyhg3rpaffBTgy7HgcM3o4iEpJRSaPwE3nEfZSB5IVPsIJD UeiPhkBHTNGR9Nil/+cAo0Ts3vuagiddhIoEUPYE9gXlmD4sJJzOVB7a80aehiq5fv0a 5TAZwsqnHlMgSpP2a9sWWQVfHCgJWblVwrAKvfl1IVkHJutu5pXoK03ZLIJJN5lLjOvO ve/g== X-Forwarded-Encrypted: i=1; AFNElJ+ZckCkBXaTb08d660Cwyp5UvwlwM2yr7oHM80RWAi9wL0o6xq6j6uJAzNJT8Tiq3/UQmSyf0S3a1gjJ5Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzpjN3AuG6L9nnXsU6PfmgKya+IUlxRfZ7sW7lD7Sje8lKLayKA VrDl4eSZD979xKWyF34l8/52DbWhmG85Tc3ldcFsKcBgbXH7e7Se+WGi X-Gm-Gg: Acq92OF6sQw8bTwleIMV882cZAuq+b3EFFqSzgiwfPkmgZ/LwbLtpRefh792boktf+G 626AFH5P7TfPoLUAkG0ftCgZn+C0jnaCeGfU0H2aF81lVGlEkst54uMXJgUkA9/RVY893t4DEri tJeFORd8avEnP6s79CMBr2Ct3Zn97BFA+WK8EMyn0ypv1SxrUm/5RfaGRkoBV//0iqFlZ/APJXN btXotzanZY/rPSscUziNRa1a8OvafTOIFKaMRlgdvgQdx3h45Tff4LY3gaiGX/pGsyoR7SmvyvC aOiyYqSLGndlp2nHgSmj2hqQv/E60yqe4PoVMMwcQ5QOyjG8kDcnkyb1UhEsP/LFp7X0yc0CtS3 QS4uOdebk4BvBbZ59L5UuLjZgy43GAC5N3+suPzLBTkqRtJBAGkPdmFWMene43pNGTpochw9ViL bHMeGjbyqqkv1j3f8ZSrHCo+C/CTGrndngaTnG14X96W8SIoryR4PFqUgVh5kv2Dw+QXfEGWY= X-Received: by 2002:a05:600c:1989:b0:490:b9fe:e64a with SMTP id 5b1f17b1804b1-490b9fee832mr27277785e9.2.1780486446358; Wed, 03 Jun 2026 04:34:06 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63e63d7sm57985335e9.12.2026.06.03.04.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:34:06 -0700 (PDT) Date: Wed, 3 Jun 2026 12:34:03 +0100 From: David Laight To: Andy Shevchenko Cc: Dmitry Antipov , Petr Mladek , linux-kernel@vger.kernel.org, Andrew Morton , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , rodrigo.alencar@analog.com, dlechner@baylibre.com, jic23@kernel.org Subject: Re: [PATCH v1 1/2] kstrtox: Make _parse_integer() take variadic arguments Message-ID: <20260603123403.75cd52ca@pumpkin> In-Reply-To: References: <20260602203706.103449-1-andriy.shevchenko@linux.intel.com> <20260602203706.103449-2-andriy.shevchenko@linux.intel.com> <20260603113750.71c93100@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit On Wed, 3 Jun 2026 13:56:24 +0300 Andy Shevchenko wrote: > On Wed, Jun 03, 2026 at 01:54:43PM +0300, Andy Shevchenko wrote: > > On Wed, Jun 03, 2026 at 11:37:50AM +0100, David Laight wrote: > > > On Tue, 2 Jun 2026 22:29:46 +0200 > > > Andy Shevchenko wrote: > > > > > Instead of having different functions that just use default parameters, > > > > combine those to use variadic arguments, so the user may call it using > > > > the same name. > > > > > > Adding a default final parameter can be done generically: > > > > Only one? > > > > > #define one(v) v > > > #define first(v, ...) v > > > #define dflt(d, ...) first(__VA_OPT__(one(__VA_ARGS__) ,) d) > > > > > > int foo(int, int); > > > #define foo(a, ...) foo(a, dflt(42, ## __VA_ARGS__)) > > > > > > See: https://godbolt.org/z/x5aao7reK > > > > I know, we support some GCC versions that do not provide it. > > > > 551d44200152 ("default_gfp(): avoid using the "newfangled" __VA_OPT__ trick") > > I stand corrected, it's all about sparse. Since this is the generic header, > I would also avoid using VA_OPT even if it allows more than one optional > argument. I'm not sure multiple optional arguments are overly useful. Starts getting difficult knowing what they are for. Really the C standard should have added named parameters ages ago. Perhaps as: int f(int a, int b, int c = 0); then: x = f(b:17, a:42); then you could have default values for any parameters. Would also be less error prone for functions with lots of flag parameters. For sparse it only has to expand to valid C. So how about something like the following for sparse builds? #define dlft(d, ...) (one(__VA_ARGS__) + 0 ?: (d)) -- David