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)) \