Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp441903lqj; Sun, 2 Jun 2024 05:54:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfqyWisORFIdyecYi5CIKPwlNTl24nI6B5ZUczXpOecy3TDN9ChSk6D66c/Gs70LHdTqPllQa6j49cBASjyI7H6Q3hXKPuKZcO+Vu+Jg== X-Google-Smtp-Source: AGHT+IEWEfKhvXm33P/S1Hh2IW4MxKqSlYjFohbJgehVfz/bzRebEceEEkUzX/26g+7mPPunp1og X-Received: by 2002:a17:903:11c8:b0:1f4:8fcb:ab2a with SMTP id d9443c01a7336-1f637048205mr81636135ad.35.1717332883062; Sun, 02 Jun 2024 05:54:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717332883; cv=pass; d=google.com; s=arc-20160816; b=BKwYvlZ2UAZSm48uZ7cto/X7P8jTJGkWEePLJL4h+IQpARewyING710G0JN4bjwBrH WHclpaN6WSEjgIt3QLcqXLbHKQNC39zRlhwM2BEl44J1tR3GXFHbBaRqoH6jlxw+oIVu XlGEieJVfCLkqFponvM9KNCzkAPK0aHOJYKYRZIsF81xxPjC9HL0el5/ko9fuPGjKka6 gtKEYywcF+kfpKiwJomJSdThy2/pfI7rlU2xM7idDajrh89fGJDJ1AgDzU44rrbiwA6t 0r4rWCVcCGbDvmnqvbCjXpJYR250T0cGlJC1wm3HpquILOY7E2TpAU7N5o9wSFHzKFwM e38A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NXCioVikRZdFYnqPI34ZaSOfe8pQRv9Y2+e+myCG1kY=; fh=oQbvuNnOUeIuBT5siQdg+euUHNNdn+CeEwAg69/1RSo=; b=NCJa4EVFVaMOoFaCUloxpyz3tRDGr5wWe2pgQ8ZseWEDTCvZqtySE5KUZG/L8ZehXU 7rRbkY1F7Tf/8gfzaUdwe2PFT2UdSY5NtvFinUsfgqq13tBM7fEtVa8QmT0MVvrSFE5r phMYf1idBVKhFivNh2oWQod2BnkrERfNPjxzNrysY5RcrIFEkyQf1HUerp8JgWhaUrDA aFl8pRsZxWDk2geEh/XVVx1Uo2y8asl3G8vmqfmmTMvc6uwRF0g/gbSeaarXJ0xgfhIp zxKs0LyrHJtnm3RKZK+lByWLkrqALHkxIEZCLxlVm///1xFv5wfZdUd00EyQ6vRq6+6i vDTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M+dqZw2h; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6677beb6asi13140605ad.357.2024.06.02.05.54.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 05:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M+dqZw2h; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AC26C2827CF for ; Sun, 2 Jun 2024 12:54:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 565623D38E; Sun, 2 Jun 2024 12:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M+dqZw2h" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 801493BBFB; Sun, 2 Jun 2024 12:54:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717332866; cv=none; b=hDqnzCsAARMgwVWD/v4kMdYtNnER35PfpFzXR6UcY3rFxZRwP4RO5vOv1tinEDQP7sO+9tgOeR+SLD2G3yTiuwkiL2GqqlTsnzx5G3w0xl32sCd7H0hFv0c1OCWPbeZYUjhum7HhrWjAWUOAS88gPj8ioit/0/HW98iWmKMwPgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717332866; c=relaxed/simple; bh=jhtE2dYSDGcTkB1IPIYvXqLDX0YEkcCTRydIkDHQ7Ko=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=izHbmMQKPeEUOu63P5fGiGQc2kDEAaULRtjG5e4cWKHrhvbiyMmizvBVGOK6e4y8aLGu64pNN5kKGZQvErR803Mm1GcrpLvbTYb5Uri/GQLxXtDd+qZMVLmdBfHwAlqJK/CVtJEeMiPZ84RaLN1ebhBYWOD2O7ydcLaDiThnBAg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M+dqZw2h; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BEF9C4AF08; Sun, 2 Jun 2024 12:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717332866; bh=jhtE2dYSDGcTkB1IPIYvXqLDX0YEkcCTRydIkDHQ7Ko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+dqZw2hcg+sZ0bs2YbOGjgzhrMhWxueFdqTAmJsiAh0Z7mza4u2ekmsvtaY5ivcG 5pVjClZ3cYlhe83KpyAzwNMWdiz8WQAzmb4/Ak7LQjR+4k842ylnxhllxyT2Sjwk6P hLUH8ZsiRyiub6uOvEio5OAOn79Db0OA1X6Ce3v+tu1RCKJUIYNuUVGcFyK9wGA0Kk PmBJkPbPwSgRDK5df9k36yRhdYFsLYdsrJVUII+LlM0bSVMYlibfpZb/kf6m9b3szs WVOwZXIXPPjWcJmdi/cCTRh3ENpcXwYG/dCvinN5hY5BrFrI6VM5tnbq94nK4jJok5 C05xcAE4NJEZA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 2/3] kconfig: refactor conf_set_all_new_symbols() to reduce indentation level Date: Sun, 2 Jun 2024 21:54:15 +0900 Message-Id: <20240602125416.976336-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240602125416.976336-1-masahiroy@kernel.org> References: <20240602125416.976336-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The outer switch statement can be avoided by continue'ing earlier the loop when the symbol type is neither S_BOOLEAN nor S_TRISTATE. Remove it to reduce the indentation level by one. In addition, avoid the repetition of sym->def[S_DEF_USER].tri. No functional change intended. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 61 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9a20e9e9bdad..cf8193fc00fc 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -218,43 +218,42 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) } for_all_symbols(sym) { - if (sym_has_value(sym) || sym->flags & SYMBOL_VALID) + tristate val; + + if (sym_has_value(sym) || sym->flags & SYMBOL_VALID || + (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)) continue; - switch (sym_get_type(sym)) { - case S_BOOLEAN: - case S_TRISTATE: - has_changed = true; - switch (mode) { - case def_yes: - sym->def[S_DEF_USER].tri = yes; - break; - case def_mod: - sym->def[S_DEF_USER].tri = mod; - break; - case def_no: - sym->def[S_DEF_USER].tri = no; - break; - case def_random: - sym->def[S_DEF_USER].tri = no; - cnt = rand() % 100; - if (sym->type == S_TRISTATE) { - if (cnt < pty) - sym->def[S_DEF_USER].tri = yes; - else if (cnt < pty + ptm) - sym->def[S_DEF_USER].tri = mod; - } else if (cnt < pby) - sym->def[S_DEF_USER].tri = yes; - break; - default: - continue; + + has_changed = true; + switch (mode) { + case def_yes: + val = yes; + break; + case def_mod: + val = mod; + break; + case def_no: + val = no; + break; + case def_random: + val = no; + cnt = rand() % 100; + if (sym->type == S_TRISTATE) { + if (cnt < pty) + val = yes; + else if (cnt < pty + ptm) + val = mod; + } else if (cnt < pby) { + val = yes; } - if (!(sym_is_choice(sym) && mode == def_random)) - sym->flags |= SYMBOL_DEF_USER; break; default: - break; + continue; } + sym->def[S_DEF_USER].tri = val; + if (!(sym_is_choice(sym) && mode == def_random)) + sym->flags |= SYMBOL_DEF_USER; } sym_clear_all_valid(); -- 2.40.1