cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [cocci] [PATCH] perf/x86/intel/pt: Return an error code only as a constant in pt_pmu_hw_init()
@ 2023-12-23 20:30 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2023-12-23 20:30 UTC (permalink / raw)
  To: linux-perf-users, kernel-janitors, Adrian Hunter,
	Alexander Shishkin, Arnaldo Carvalho de Melo, Borislav Petkov,
	Dave Hansen, H. Peter Anvin, Ian Rogers, Ingo Molnar, Jiri Olsa,
	Mark Rutland, Namhyung Kim, Peter Zijlstra, Thomas Gleixner, x86
  Cc: LKML, cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Dec 2023 21:06:27 +0100

Return an error code without storing it in an intermediate variable.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/events/intel/pt.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 8e2a12235e62..24fd18e2da34 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -190,7 +190,6 @@ static int __init pt_pmu_hw_init(void)
 	struct attribute **attrs;
 	size_t size;
 	u64 reg;
-	int ret;
 	long i;

 	rdmsrl(MSR_PLATFORM_INFO, reg);
@@ -242,11 +241,10 @@ static int __init pt_pmu_hw_init(void)
 			    &pt_pmu.caps[CPUID_EDX + i*PT_CPUID_REGS_NUM]);
 	}

-	ret = -ENOMEM;
 	size = sizeof(struct attribute *) * (ARRAY_SIZE(pt_caps)+1);
 	attrs = kzalloc(size, GFP_KERNEL);
 	if (!attrs)
-		goto fail;
+		return -ENOMEM;

 	size = sizeof(struct dev_ext_attribute) * (ARRAY_SIZE(pt_caps)+1);
 	de_attrs = kzalloc(size, GFP_KERNEL);
@@ -273,8 +271,7 @@ static int __init pt_pmu_hw_init(void)

 fail:
 	kfree(attrs);
-
-	return ret;
+	return -ENOMEM;
 }

 #define RTIT_CTL_CYC_PSB (RTIT_CTL_CYCLEACC	| \
--
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-23 20:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-23 20:30 [cocci] [PATCH] perf/x86/intel/pt: Return an error code only as a constant in pt_pmu_hw_init() Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).