From patchwork Sat Mar 4 04:19:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 64156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp778614wrd; Fri, 3 Mar 2023 21:13:30 -0800 (PST) X-Google-Smtp-Source: AK7set+K3N2GB0aLKCM6jAlR4DqcCcwZfQI7unztxic5BA384ew5pmcSXGIzN/K7C1N/ko36+by7 X-Received: by 2002:aa7:cf03:0:b0:4c0:8bd8:b4d2 with SMTP id a3-20020aa7cf03000000b004c08bd8b4d2mr4109186edy.42.1677906810421; Fri, 03 Mar 2023 21:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677906810; cv=none; d=google.com; s=arc-20160816; b=GtMdHTi35IlrsrIrW01tl7/GLxlwB8uK0ZQICzXP+5t6Gu9ccJDjhpDeupos45ypYL OVgXs4ii1pGZtsNLwjWGuw5aQOpWbopMdb0oDKVx7fvjyay75S2kTWWcbxznLHXoN7KX bqe4Pdvm1mIR0rirpnzD8IAobw5316CG9AZCFFCdkh728nTDAxTeH5+vAVYd1HQ3AbDn TPofFkLZ4ssJwDWqiLWb+jKtv9EJSjsY5G6bQvP1RhHIyEJWdcbfjOQYRailIhrdpihf 98Dns7MBNQrId/dYGTPtxywhIW3SuAGwsvh1YHxvP1/5ZUvYhPTt7ykWOyAWl5LW1T1G cEfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vivs7/1T3zc8MKnKuUo0J0oEoV998CT2dg0xmqwGI8U=; b=OfqBlkr+DXVL28A7xUfSaFRuXCFH2EIFHv0lUlYjk7Y8mHcuy9svZ8xBtdF2vm1z4I KJxpDxiAtp5nvuqd8AJWWjS1aZIQcOJcJZFltZ3vujTRVkktvD7uNUimWx3KMCb9w8id D5FeResnbZc+p66EOyIyyd7WyLy9D2bbnvnGXmX61LccsGYCTmcZiVorg0ZoHVDOXJma ANNpgInSiTp7POJ8fOczLmDnhXyj81eoFZYQxGIUbSmq6Qi2buS4Jd9RQY6OP/MbPqov rNKS2Nhb9JLu45vZW0ticzAEmeF6ISbtBiHcztMValQfdsPIbnj864Ex97P9JXDBAciw 2Xzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=engCTQj2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d25-20020a056402079900b004ab4c6f9996si869451edy.516.2023.03.03.21.13.06; Fri, 03 Mar 2023 21:13:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=engCTQj2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjCDETu (ORCPT + 99 others); Fri, 3 Mar 2023 23:19:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbjCDETn (ORCPT ); Fri, 3 Mar 2023 23:19:43 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 407E71259B for ; Fri, 3 Mar 2023 20:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677903582; x=1709439582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xvEmsWuughcRdW3oGFQ5VdryPdej8zL62swUuDZTanw=; b=engCTQj2R9x0Q22X8Vgse2w7zPaAFGK2vfXALHnSLwgLJRutPMfrPfkO MR4UEl0rhBpwuxtj8I19f7oLs6DE1vwcQtS1gUjBEvzhQy91xFAlUBjvu EInGUSW4ZJxF94qUfvtTEgCsVYfFx3DpqV78eJbYMy9Hlq5vcblDgwWwV SGnMeE+thTk1Ny+tBm/dPLA9/wUComKln+i5sy82h70vByMyfzD3FjfCs clNtAkA6pK4Qyq8VkSzI+FKM2raR54wG9OgKrBXxaVIx/nVqJJZ6xNa5V Gl4n9l1z+HabPR2lIgQ8IzA4lJF0g7tdCI0ZYfa8Nb+CSIOMrWVjWCVQW w==; X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="315618085" X-IronPort-AV: E=Sophos;i="5.98,232,1673942400"; d="scan'208";a="315618085" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2023 20:19:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="708062006" X-IronPort-AV: E=Sophos;i="5.98,232,1673942400"; d="scan'208";a="708062006" Received: from tdx-lm.sh.intel.com ([10.239.53.27]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2023 20:19:37 -0800 From: Wei Wang To: arnd@arndb.de, akpm@linux-foundation.org, keescook@chromium.org, herbert@gondor.apana.org.au, josh@joshtriplett.org, jani.nikula@intel.com, corbet@lwn.net, jgg@mellanox.com, dmatlack@google.com, mizhang@google.com, pbonzini@redhat.com, seanjc@google.com Cc: linux-kernel@vger.kernel.org, Wei Wang , James.Bottomley@HansenPartnership.com, jarkko@kernel.org Subject: [PATCH v1 1/3] security: keys: don't use data type as variable name Date: Sat, 4 Mar 2023 12:19:30 +0800 Message-Id: <20230304041932.847133-2-wei.w.wang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230304041932.847133-1-wei.w.wang@intel.com> References: <20230304041932.847133-1-wei.w.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759412811917287380?= X-GMAIL-MSGID: =?utf-8?q?1759412811917287380?= 'bool' is a specific name for the data type that is an alias for the C99 _Bool type. It shoudn't be used as variable names as that causes too much confusion either for the reader or the compilier. CC: James.Bottomley@HansenPartnership.com CC: jarkko@kernel.org Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs") Signed-off-by: Wei Wang Reviewed-by: Jarkko Sakkinen --- security/keys/trusted-keys/trusted_tpm2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c index 2b2c8eb258d5..390d7314f5a6 100644 --- a/security/keys/trusted-keys/trusted_tpm2.c +++ b/security/keys/trusted-keys/trusted_tpm2.c @@ -54,12 +54,13 @@ static int tpm2_key_encode(struct trusted_key_payload *payload, asn1_oid_len(tpm2key_oid)); if (options->blobauth_len == 0) { - unsigned char bool[3], *w = bool; + unsigned char bool_val[3], *w = bool_val; /* tag 0 is emptyAuth */ w = asn1_encode_boolean(w, w + sizeof(bool), true); if (WARN(IS_ERR(w), "BUG: Boolean failed to encode")) return PTR_ERR(w); - work = asn1_encode_tag(work, end_work, 0, bool, w - bool); + work = asn1_encode_tag(work, end_work, 0, + bool_val, w - bool_val); } /* From patchwork Sat Mar 4 04:19:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 64158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp794379wrd; Fri, 3 Mar 2023 22:14:07 -0800 (PST) X-Google-Smtp-Source: AK7set/Sa1wC4F9ZEGeekkF3K3Na/caa6G1poNKsG24JNR4EFup9oi/v2kIoabEuBZKYD96xCSpi X-Received: by 2002:a17:907:80e:b0:885:6a2e:f941 with SMTP id wv14-20020a170907080e00b008856a2ef941mr5308684ejb.54.1677910447643; Fri, 03 Mar 2023 22:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677910447; cv=none; d=google.com; s=arc-20160816; b=t6DT8P/pyEniat9OClmNuVmlZYoEFIv86xTgLskIBufo6QmaIwmOSZCiCKDGv0TULe NyjddVDZzhelFVWRQ18hoKm7Mq2sgRODwZBOvCSsZnePpq8VspAGIL1oSGzNuPWpqRPv hdO3hqA+yTOrU/YgO0czWxcFCDZj8E3YN5w36xvBR/LbaV5q4Uynn3mp3LmRfQs1lTYw AXLyuEhatTBmZ4nj1aHLdKZzPnE8ArzBYBRZuqD0xeSqDsR4tPoCW17H5FJ/EmF8DrNU Ec85GS83uNf5UXqKc/ZJAAgGo4AFWRO4nw9QVG3DcWI1zMqDL1JYEHEbpz1x938TpiAd 7nFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x/YTEVZX7bk5PFPO8h1bcm3j6LUAomnLb0WNrNU8+As=; b=tANPkUq4poGKlDJOZ/DsMBrq6BdGRI76dls9f1hcLVbKXNZx4gM6dz2Dedz6BHQQPZ zeGR03MMUspywW12lBvdyTYTbhzAzVd8uMuNT5f2t4xpROJvp6eapZpfG2p7xrlr9aaV wv7oRgOzvr9O3yp+HHFGCoVwB8dFoe87XTXYUkVsGZcmAxyJ7aD+gwB0ReOvJsWODgLP MrQIoh614ACtJJxLUEetj+G3+UrCDuB5exjW6Hjy/l/6CuBOXGGvxiaZuwWaBA77NXuW 5m/0Jep4pN5roj/P8maxr1kb9yWCn31TyyYNP+v9xvJG9M4hj/ss2ryw4JX+6nbwAq4S PZhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bhgfJNBu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ba10-20020a0564021aca00b004acbe7b3479si4574104edb.653.2023.03.03.22.13.40; Fri, 03 Mar 2023 22:14:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bhgfJNBu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbjCDETx (ORCPT + 99 others); Fri, 3 Mar 2023 23:19:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjCDETr (ORCPT ); Fri, 3 Mar 2023 23:19:47 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE50D126EA for ; Fri, 3 Mar 2023 20:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677903585; x=1709439585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IcgtldqkfkE6eHD67FeLCamBoKCMzTV2qNFng33ppWw=; b=bhgfJNBuZNt8h0hX5EEB9fRvMmF8zlAMFHVZ3YmP7ib4gdq2h4EyD1fY 6QwbcG3D0lAy9M47X41xjZhsrzO4Rp0ROudSMFQfIMcgUXu/JWocqffOg 9weHm+PslQMagB97GeTC2IzT+y9GQVbuDvl6E+DtN9qxgtZ7YOkWx1daW Nhg/Anu0075Oi//tGrQdiI/u5O2TMGRE0uJLFWnTLR9KHUbhq6V37BPJG MRiOEV54rhCYxy0gDOf1R1ntq0Zng0qaZ9jNgV3RPZtT29XmjR7DLOuJv Kl8pPHLXhoY8EwgHygvzqLloMoi0oinUKKf3ZdG1VIzTYeRA6HtbUHeJu A==; X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="315618100" X-IronPort-AV: E=Sophos;i="5.98,232,1673942400"; d="scan'208";a="315618100" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2023 20:19:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="708062010" X-IronPort-AV: E=Sophos;i="5.98,232,1673942400"; d="scan'208";a="708062010" Received: from tdx-lm.sh.intel.com ([10.239.53.27]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2023 20:19:42 -0800 From: Wei Wang To: arnd@arndb.de, akpm@linux-foundation.org, keescook@chromium.org, herbert@gondor.apana.org.au, josh@joshtriplett.org, jani.nikula@intel.com, corbet@lwn.net, jgg@mellanox.com, dmatlack@google.com, mizhang@google.com, pbonzini@redhat.com, seanjc@google.com Cc: linux-kernel@vger.kernel.org, Wei Wang Subject: [PATCH v1 2/3] Documentation/CodingStyle: do not use data type names as variable names Date: Sat, 4 Mar 2023 12:19:31 +0800 Message-Id: <20230304041932.847133-3-wei.w.wang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230304041932.847133-1-wei.w.wang@intel.com> References: <20230304041932.847133-1-wei.w.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759416625541540953?= X-GMAIL-MSGID: =?utf-8?q?1759416625541540953?= Observed some merged code uses "bool" as variable name. This is confusion either for the reader or compilier. Add a rule to have programmers avoid using data types as variable names. Signed-off-by: Wei Wang --- Documentation/process/coding-style.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst index 007e49ef6cec..6d7f4069d55d 100644 --- a/Documentation/process/coding-style.rst +++ b/Documentation/process/coding-style.rst @@ -356,6 +356,9 @@ specification that mandates those terms. For new specifications translate specification usage of the terminology to the kernel coding standard where possible. +"bool", "int", "long" etc. are specific names for data types, C +programmers should not use them as variable names. + 5) Typedefs ----------- From patchwork Sat Mar 4 04:19:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 64155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp775849wrd; Fri, 3 Mar 2023 21:03:23 -0800 (PST) X-Google-Smtp-Source: AK7set+Ebd+q0ocuHCZpVMLqQKlfzv5/srrHX9k9Yyvfn0xo2xixIWBujJuDl5s71VvfTE5+qMzY X-Received: by 2002:aa7:d68f:0:b0:4ae:eab6:a07b with SMTP id d15-20020aa7d68f000000b004aeeab6a07bmr3906928edr.16.1677906203704; Fri, 03 Mar 2023 21:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677906203; cv=none; d=google.com; s=arc-20160816; b=B/AP3LAQ5nPKaFUxHMXB9jSwtW7pDgzXR5O0nAyVVdFG+BK+stYAH6GNorgPdH4EOB Uc1oAeukQCRZ3oXpJbhndMkkQuXpm3rjNWkM8A+kYMT7v7Yuaawx1hmF9nuuWzVO5ORc nC3FyJuGm9VGpHljf8h9UCwIePDNTV4OmwErqzw+HyAaboHmJ6QA90oMttrRdIGC8iZ2 m022ej3Xss5yE3txfR7PgfFfQ0AF+3qAmPoaOIUmxAldQ7vuOHSaq/ScVtS/7xApftOI YYV0Io7rXp7QKWU0oM2+TD50FaP8qJYtyO/mOel88soUQ320+hTADGmTtdIIdOKb2ZHb RNMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NeaMY+lnRc3wmc0jOZuYJ7EnJVNSS5MHa4tMpd4bMLw=; b=AsbseiJC6RkXs+O2C3ayTSdNsM7AAGAivFTn4BGbQqFgd+Kj3//jgzd5P/51ZQG0Vd TnvzrGRuN01u3EcWvIn5yCFFb3FmHpz8j69XMmKg0l9RYGusasqxl5VH6IQ6/QCERpyg gfEXyiuJHXLLU6C6zNsRbr58SaQPa5mQuKqWxKvYJpvsgvCuKfV+2uqlZtL0gs8IClce SH60/wZI5ftyK0oE+Hwz0arPsY+qvs+kYoHab85xzhFqSY7R8hkQb3cJAxk1CHO0GZHt 2xWeRB6DUin/W0xiXRGDP5ZmvREsyPG8FsKB9pSzJWdUQrAc84ag73PaGqG+lRHTqhQj JkCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aOf30N78; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be15-20020a0564021a2f00b004acc137fdd5si4039459edb.48.2023.03.03.21.02.54; Fri, 03 Mar 2023 21:03:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aOf30N78; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbjCDEUA (ORCPT + 99 others); Fri, 3 Mar 2023 23:20:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbjCDETu (ORCPT ); Fri, 3 Mar 2023 23:19:50 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9341A19F35 for ; Fri, 3 Mar 2023 20:19:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677903589; x=1709439589; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pd8dhXsOYVnMcYaWLAlR4eqh0jn5NMv7qu4K0qUhvcU=; b=aOf30N78IrFHtDyfM5pc47f/xxt/8k5+pMAkRzRNTZqPGcIT2VDEAWCM Uapts8h2Y56sxaisn81A383aPNfKLGMSfNnKW/R31iVaE08J9nDPBJVWY 3m5TjOsL83ixUEZEF1zkxR+i0XKanVeNvgTYRdfD3vlT78SNEDfgqPxyF FN+JG1WuFAK7GA7nUDHXzg1Jc2aS+hDOdBrWvW4O+FvUgu/fw7o4PftsN K43r0oAHLD6fsQ3Z0hbFnVRSVFSBHGUOMwUct3EK06SkPY0DR4K6AkBGx k7Mz+L3KTys6BrumqNTKMOaHdT7YJC1tpjxvTwcZmTm1WYBlGufbeToxq A==; X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="315618117" X-IronPort-AV: E=Sophos;i="5.98,232,1673942400"; d="scan'208";a="315618117" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2023 20:19:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="708062015" X-IronPort-AV: E=Sophos;i="5.98,232,1673942400"; d="scan'208";a="708062015" Received: from tdx-lm.sh.intel.com ([10.239.53.27]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2023 20:19:45 -0800 From: Wei Wang To: arnd@arndb.de, akpm@linux-foundation.org, keescook@chromium.org, herbert@gondor.apana.org.au, josh@joshtriplett.org, jani.nikula@intel.com, corbet@lwn.net, jgg@mellanox.com, dmatlack@google.com, mizhang@google.com, pbonzini@redhat.com, seanjc@google.com Cc: linux-kernel@vger.kernel.org, Wei Wang Subject: [PATCH v1 3/3] bug: use bool for __ret_warn_on in WARN/WARN_ON Date: Sat, 4 Mar 2023 12:19:32 +0800 Message-Id: <20230304041932.847133-4-wei.w.wang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230304041932.847133-1-wei.w.wang@intel.com> References: <20230304041932.847133-1-wei.w.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759412175729118493?= X-GMAIL-MSGID: =?utf-8?q?1759412175729118493?= coding-style.rst documents below: bool function return types and stack variables are always fine to use whenever appropriate. Use of bool is encouraged to improve readability and is often a better option than 'int' for storing boolean values. __ret_warn_on is essentially used as boolean in WARN/WARN_ON, so change its definition from 'int' to 'bool'. Signed-off-by: Wei Wang --- include/asm-generic/bug.h | 12 ++++++------ tools/include/asm/bug.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 4050b191e1a9..3a316be73f0e 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -107,7 +107,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); instrumentation_end(); \ } while (0) #define WARN_ON_ONCE(condition) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ __WARN_FLAGS(BUGFLAG_ONCE | \ BUGFLAG_TAINT(TAINT_WARN)); \ @@ -119,7 +119,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #ifndef WARN_ON #define WARN_ON(condition) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ __WARN(); \ unlikely(__ret_warn_on); \ @@ -128,7 +128,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #ifndef WARN #define WARN(condition, format...) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ __WARN_printf(TAINT_WARN, format); \ unlikely(__ret_warn_on); \ @@ -136,7 +136,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #endif #define WARN_TAINT(condition, taint, format...) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ __WARN_printf(taint, format); \ unlikely(__ret_warn_on); \ @@ -164,14 +164,14 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #ifndef HAVE_ARCH_WARN_ON #define WARN_ON(condition) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ unlikely(__ret_warn_on); \ }) #endif #ifndef WARN #define WARN(condition, format...) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ no_printk(format); \ unlikely(__ret_warn_on); \ }) diff --git a/tools/include/asm/bug.h b/tools/include/asm/bug.h index 550223f0a6e6..c1f72071303b 100644 --- a/tools/include/asm/bug.h +++ b/tools/include/asm/bug.h @@ -8,14 +8,14 @@ #define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0) #define WARN(condition, format...) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ __WARN_printf(format); \ unlikely(__ret_warn_on); \ }) #define WARN_ON(condition) ({ \ - int __ret_warn_on = !!(condition); \ + bool __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ __WARN_printf("assertion failed at %s:%d\n", \ __FILE__, __LINE__); \ @@ -23,8 +23,8 @@ }) #define WARN_ON_ONCE(condition) ({ \ - static int __warned; \ - int __ret_warn_once = !!(condition); \ + static bool __warned; \ + bool __ret_warn_once = !!(condition); \ \ if (unlikely(__ret_warn_once && !__warned)) { \ __warned = true; \ @@ -35,7 +35,7 @@ #define WARN_ONCE(condition, format...) ({ \ static int __warned; \ - int __ret_warn_once = !!(condition); \ + bool __ret_warn_once = !!(condition); \ \ if (unlikely(__ret_warn_once)) \ if (WARN(!__warned, format)) \