powertop - power analysis tool
 help / color / mirror / Atom feed
From: Michael Vetter <mvetter at suse.com>
To: powertop@lists.01.org
Subject: [Powertop] closedir patch
Date: Tue, 21 Apr 2020 08:18:49 +0200	[thread overview]
Message-ID: <20200421081849.73090b0e@maitreya> (raw)

[-- Attachment #1: Type: text/plain, Size: 184 bytes --]

In case `dir` is NULL we should not call `closedir()` since it's
behaviour is implementation specific.

Patch attached. Please apply with `git am <
powertop-only-closedir.patch`.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: powertop-only-closedir.patch --]
[-- Type: text/x-patch, Size: 916 bytes --]

From 553294813635c074230a9d8ba0d7736c23f15ddd Mon Sep 17 00:00:00 2001
From: Michael Vetter <jubalh@iodoru.org>
Date: Tue, 3 Sep 2019 12:56:04 +0200
Subject: [PATCH] intel_cpus.cpp: Only call closedir() if opened

In case `dir` is NULL we should not call `closedir()` since it's
behaviour is implementation specific.
---
 src/cpu/intel_cpus.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 4dffadc..af473ee 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -142,11 +142,12 @@ intel_util::intel_util()
 void intel_util::byt_has_ahci()
 {
 	dir = opendir("/sys/bus/pci/devices/0000:00:13.0");
-        if (!dir)
-                byt_ahci_support=0;
-	else
+	if (!dir)
+		byt_ahci_support=0;
+	else {
 		byt_ahci_support=1;
-        closedir(dir);
+		closedir(dir);
+	}
 }
 
 int intel_util::get_byt_ahci_support()

                 reply	other threads:[~2020-04-21  6:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200421081849.73090b0e@maitreya \
    --to=powertop@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox