From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 3570B222578 for ; Tue, 25 Nov 2025 14:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764080716; cv=none; b=SyIkh9yswL1mSheLTGFht1i6JueIRTgH7taxi6MFz/0dxc5IUzfkillNaf6+vCAsc8BX6ORzd7Jo6pOSWEzWc3Cofg7dH3siPVCL3nOka7+XIc1ZSYvTpQxJA/X4GUp5U0A0RPJwTk54ebh6YKc/KUltoFJDuHF+zgmmKTrkj8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764080716; c=relaxed/simple; bh=VidrQjP8cQNVecrbUgAZAPFFcr4TkXgMPISPirxbN0c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aVJcl/qXHU7DVxtxF+X2r1GfiGOEw9yLN3Wn32qrjH7EAO5xXvARHe0O3CWgTeGTZr/PsFqZQb9zQM4JTvnykgHEa0xk5XfBpUs6jRSWsAKTNURjdTpwQ7Yrr9GvTe3pvf2dJG1RhN5DGdI/kbMjVHOCnDs2vwrEdO/SUCxgUVc= 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=a3DfngdK; arc=none smtp.client-ip=209.85.167.53 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="a3DfngdK" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-59584301f0cso6080311e87.0 for ; Tue, 25 Nov 2025 06:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764080713; x=1764685513; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VidrQjP8cQNVecrbUgAZAPFFcr4TkXgMPISPirxbN0c=; b=a3DfngdKnrWdVoDWuMrK9Q1DS/1Np/Q31nKYTsxIF+nFwgopL3g8SQWEL+saN4poke TEkddGXTcJfeJyLls/s4qtE1EFrcscUO0sFHfutOGRqlC/+ZG0mvCzUQE/EBfdJ26lu4 sv4KqcV/XK0NgC0cmq/F+vHnqackBM6tU4SM3b5Wvko1vq9HhKxja65s4rh4Hzk4vSdx oiNwiD1m9iZqeB0z3bo3Z8Evgag1mWgQaSG57PuVHHr1kb0OBT4C8kKk2F6/jBrZtPve dn6JNBZ2waTT4vDc5NysefZWsH4xs3x0kjLvYiormAIdVIZiO5maUzdlFSiGEiOPbFhL LBVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764080713; x=1764685513; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VidrQjP8cQNVecrbUgAZAPFFcr4TkXgMPISPirxbN0c=; b=OzggKA1ZHYdqmfvQKyBZlm1syWu2etJMO0bU80S5KKr1V1XJ9MfwGy8pM8yKSeG6et AiLM7iHNKcoPmyXwekjRMTOEEz0mvQKOtKmEIbVUuVi5YjTlA4Th37K4+9pf2cbHlD3P TU2JcrukvVeK23tssuiVWbUqhLWJJO6R9pVWomr6t4BBpCHiaxelOzYmIDp+4hOtjvuL 5laRVOthK9gmRxTJLPwEY42uFlMgzVGCBob1QxliVZ0FXZ2JWA9FMq8VZxwWMZweYThh ZnMorYMwuv2pV3TjatfEAnTGxwEP5EMxo5lPldOtbuyJKWs2R1/oEiUf5nYdMPaZIt/e 6rog== X-Forwarded-Encrypted: i=1; AJvYcCVfxWVqCdnR+FRilrvJ2AnnxXGlpe+iaJ4IzoHWJ157IM/6ft2ue9C5cQigdyOFLqB9uvW+0beMiHfi6VM=@vger.kernel.org X-Gm-Message-State: AOJu0YwxFuKRrkBYqyjxE0e6jC7eAzysVGJprcLFTQdfKMDpBF777J48 WGy5CZ1RWxEyo2fz/cu6sGeD/zImgKTfU1XtlM4HM0RcbJJdgeKzLjY= X-Gm-Gg: ASbGncuKDYLBmiPLo0XCvvn7PbiNKQIADeBMT6UJyWowMjqy3Lycr2WpmLgNRqx+QKy rMjPeI3yAQfGq+nTVue7lqZ06zxW1aVAUxCDz1Q4tW5iGF34A8lLMeBOeiGSnfGSF/G5w2V3+zo KBJQq0kUQ8EspjosJu5ETmixYnZCYMP1L9PQkfhn0Rq+0Pr9wDF8wHknKYAHcW72Ax5nqbmED8j zrT4UBQVXqB15O/HB7P9j9lGUdVqIfwadO7s/zP13IFP9Jd8irm9Mhw3x69t0ePse+MW4Dbvc+p 1MEe665LvR058QymZ/FyQEHv5N3vawb6jjdONqX0TETieGhb5Ot5goQUPUyYTcG5/SsepqSX0Uv NYy+C1FzGcGUndkl55AYUQH9KT6LgomSxwK2K+inqGpt2SJKtHii5iuTv/v93/I5rn3ogvjrk X-Google-Smtp-Source: AGHT+IGxUh40YvI7RHhj6BGgFqnWbHjR95ygR8U26ZGznWuhnn4R5jSRdozHdB2YbcanGF7xt8wiFA== X-Received: by 2002:a05:6512:239e:b0:595:7fa2:acd with SMTP id 2adb3069b0e04-596b5046a9cmr1389512e87.21.1764080713051; Tue, 25 Nov 2025 06:25:13 -0800 (PST) Received: from p183 ([46.53.248.91]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5969dbc5e07sm5164295e87.83.2025.11.25.06.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 06:25:12 -0800 (PST) Date: Tue, 25 Nov 2025 17:25:19 +0300 From: Alexey Dobriyan To: James Bottomley Cc: ksummit@lists.linux.dev, Dan Williams , linux-kernel , Dan Carpenter Subject: Re: Clarifying confusion of our variable placement rules caused by cleanup.h Message-ID: <7b37e1cb-271e-49fe-a3ee-5443006284e1@p183> References: <58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com> 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=utf-8 Content-Disposition: inline In-Reply-To: <58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com> On Tue, Nov 18, 2025 at 11:39:26AM -0500, James Bottomley wrote: > So which should we do? The best way to understand that C89 style of declaring in the beginning of the function is pointless rule is to write some code in a language which doesn't enforce it. You should see that nothing bad happens. It increases bug rate due to increased variable scope allowing typos. It bloats LOC -- in many cases declaration and initializer can fit into a single line. It prevents adding "const" qualifier if necessary. Pressing PageUp and PageDown when adding new variable is pointless busywork and distracts, breaks the tempo(flow?) so to speak. C89 style provokes substyles(!) which makes adding new variables even more obnoxious: some subsystems have(had?) a rule saying that declarations (with initializers) must be sorted by length, so not only programmer has to PageUp to the beginning of the block, but then aim carefully and insert new declaration. None of this is necessary (or possible) if the rule says "declare as low as possible". There was variation of this type of nonsense with headers (not only it has to be sorted alphabetically but by length too!) There is no practical difference between code and declarations: declarations can have initializers which can be arbitrary complex, just like "real" code. So the only difference is superficial. C89 declaration style is pointless and dumb, no wonder other programming languages dumped it (or never had), it should be simply discarded. It will also make Linux slightly less white crow to newcomers (C++ doesn't have this rule after all).