lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240217105904.1912368-1-fabio.maria.de.francesco@linux.intel.com>
Date: Sat, 17 Feb 2024 11:59:01 +0100
From: "Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com>
To: Peter Zijlstra <peterz@...radead.org>,
	Dan Williams <dan.j.williams@...el.com>,
	linux-kernel@...r.kernel.org
Cc: linux-cxl@...r.kernel.org,
	Ingo Molnar <mingo@...nel.org>,
	Dave Jiang <dave.jiang@...el.com>,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>,
	Ira Weiny <ira.weiny@...el.com>,
	"Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com>
Subject: [PATCH 0/3 v5] Add cond_guard() to conditional guards

Add cond_guard() macro to conditional guards. Show how to use it by 
converting two functions in drivers/cxl to replace open-coded up_read()
in show_targetN() and in cxl_inject_poison() and avoid to 'goto' to a
cleanup block marked by an 'out' label. The second conversion is added
with v5 to show that the most recent implementation of cond_guard() can
also be used more than once in the same scope.

Cc: Dave Jiang <dave.jiang@...el.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Suggested-by: Dan Williams <dan.j.williams@...el.com>
Suggested-by: Ira Weiny <ira.weiny@...el.com>
Suggested-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@...ux.intel.com>
---

Changes from RFC v5:
        Changed the interface of cond_guard() to take a statement or 
        statement-expression as its second argument to conform to Dan's 
        suggestion (thanks).
Changes from v1:
        Fixed a grammar error in the commit message of 1/2; replaced the
        name of the second argument of cond_guard() with '_fail'
        according to Jonathan's comments (thanks). 
Changes from v2:
        Changed macro's implementation to add an 'else' to protect
        against it being used incorrectly within another if() block.
        Suggested by Dan (thanks). The Reviewed-by tags on 1/2 are not
        forwarded because the implementation of cond_guard() has changed.
        Removed a redundant 'else' from show_targetN() in 2/2.
Changes from v3:
	Added braces around empty body in an 'else' statement in
	cond_guard(). Added Reviewed-by tags (Dave, Ira - thanks).
Changes from v4:
	Made it possible to call cond_guard() more than once in the same
	scope. Jonathan suggested a more elegant implementation than the
	one I had thought. It uses an exhisting helper instead of creating
	an ad hoc one (thanks). Added a second conversion to show that
	cond_guard() can be used twice in the same scope. Deleted the
	Reviewed-by tags from 1/3 since the implementation of cond_guard()
	has significantly been reworked to allow multiple calls.

Fabio M. De Francesco (3):
  cleanup: Add cond_guard() to conditional guards
  cxl/region: Use cond_guard() in show_targetN()
  cxl/memdev: Use cond_guard() in cxl_inject_poison()

 drivers/cxl/core/memdev.c | 19 +++++--------------
 drivers/cxl/core/region.c | 16 ++++------------
 include/linux/cleanup.h   | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 26 deletions(-)

-- 
2.43.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ