From: Colin King <colin.king@canonical.com>
To: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Len Brown <len.brown@intel.com>,
Robert Moore <robert.moore@intel.com>,
Lv Zheng <lv.zheng@intel.com>,
linux-acpi@vger.kernel.org, devel@acpica.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] tools/power/acpi: close file only if it is open
Date: Fri, 18 Mar 2016 14:28:32 +0000 [thread overview]
Message-ID: <1458311312-23330-1-git-send-email-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
the logic on the test for a valid fd to close is incorrect and
the current code will close -ve fd's which is not was intended.
Since the only path to the exit label is on a failed open, we
may as well just close fd if it has been opened successfully
before the exit label and also remove the valid fd check.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
tools/power/acpi/tools/acpidbg/acpidbg.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c
index d070fcc..38ccac9 100644
--- a/tools/power/acpi/tools/acpidbg/acpidbg.c
+++ b/tools/power/acpi/tools/acpidbg/acpidbg.c
@@ -429,9 +429,8 @@ int main(int argc, char **argv)
acpi_aml_flush(fd);
acpi_aml_loop(fd);
+ close(fd);
exit:
- if (fd < 0)
- close(fd);
if (acpi_aml_batch_cmd)
free(acpi_aml_batch_cmd);
return ret;
--
2.7.3
next reply other threads:[~2016-03-18 14:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-18 14:28 Colin King [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-03-24 5:01 [PATCH] tools/power/acpi: close file only if it is open Lv Zheng
2016-04-21 0:19 ` Rafael J. Wysocki
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=1458311312-23330-1-git-send-email-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=devel@acpica.org \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=rafael.j.wysocki@intel.com \
--cc=robert.moore@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).