From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 C0743A95E for ; Tue, 25 Nov 2025 15:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764084749; cv=none; b=bPlN4B5w6MxeKPBRrbTf0mm04DRHsyaN10Poeyw5Bbco2qOGxATi7smigIqxM+OEeV+cEpWLBua6kbE7tVqD9S0t2sTXXpLg61f41OFfE2q1DKMFw7BEyAudIzAKev5B2sfMOdtxbGCX7hZsxX2aCVszSvhAcYcBVi2me33iu/w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764084749; c=relaxed/simple; bh=MoTnXX/JDMIlor/GGBh7GqAbbA2mFgxeg5HWI/Krl7Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i8WWOBRyM+dFEhH/cF9d3IjIEULn0s678lRHCGfCzg34Zmjfi2/YE9yThq33ZaMyXrP2592ykQdfT8Rl3twCeSHKAqOqeUMc5htZbU/Wt8sg/IrSBkKzGhAtm46F+rkExao4IxIyd75bFfQ/fCY71GVkKYkb6UA73x4hPtlqSeY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=FIpdOze/; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="FIpdOze/" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso6584987b3a.3 for ; Tue, 25 Nov 2025 07:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1764084747; x=1764689547; 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=bNI+MRfplprIGgM8wV4MohxouRr1kUJAd5B82/krB3U=; b=FIpdOze/HrANroy2CQSRlKh7QsFO6FCadqhcdJAZlGJrFVoASSIFDiO53vITyhgvOy yBmrIbPZWbK8cHE53tDNak9bHtyKb2jPazIDzyv3cPp+CMhSASMs0B+wwgKgfVbnDUA6 2zIF3AKa4D85vfevDO0OIMSPzAXnOvWz/guEpP2ikAL6K7enz5Q/e9zHlxKmZw/JFl3J dbPrIOZwew+hztI8AVl2APccl6w2d9xCtnJ4BO0/CYieINVOSL0+2QcUhhrF60GLiyX+ bUbz9koU4D3vD03k8Q7y/MNumzKPK5qRYIneHYd92026Fsrt71LZ3XCamgeT48qmxvlr pkYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764084747; x=1764689547; 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=bNI+MRfplprIGgM8wV4MohxouRr1kUJAd5B82/krB3U=; b=SUPePfw0fi329OowTbW8jdMYCMfJ+Fb7Hx59KHBFoyb/yb1uSTB32U9Wh/fqAZmBKm Aye2BAaMwqcY7poEYIN3yrmhaYbMNiNbSCipjzbPQlfrG1SKgqqnmSPk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== X-Received: by 2002:a05:6a20:2589:b0:341:d5f3:f1ac with SMTP id adf61e73a8af0-3614edd7ee7mr18164019637.41.1764084747054; Tue, 25 Nov 2025 07:32:27 -0800 (PST) Received: from phoenix.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f024b4aesm18276206b3a.33.2025.11.25.07.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 07:32:26 -0800 (PST) Date: Tue, 25 Nov 2025 07:32:24 -0800 From: Stephen Hemminger To: Alexey Dobriyan Cc: James Bottomley , 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: <20251125073224.30e24755@phoenix.local> In-Reply-To: <7b37e1cb-271e-49fe-a3ee-5443006284e1@p183> References: <58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com> <7b37e1cb-271e-49fe-a3ee-5443006284e1@p183> 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 Tue, 25 Nov 2025 17:25:19 +0300 Alexey Dobriyan wrote: > 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). > Agree with everything you said. But I don't want to see patches that are just to rearrange existing code to move declarations around. So yes, but no more churn please.