linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
To: linux-raid@vger.kernel.org
Cc: jes.sorensen@redhat.com, artur.paszkiewicz@intel.com,
	Pawel Baldysiak <pawel.baldysiak@intel.com>
Subject: [PATCH 2/2] super-intel: Simplify for() loop in ahci_enumerate_ports
Date: Fri, 11 Mar 2016 16:47:16 +0100	[thread overview]
Message-ID: <1457711236-16990-2-git-send-email-pawel.baldysiak@intel.com> (raw)
In-Reply-To: <1457711236-16990-1-git-send-email-pawel.baldysiak@intel.com>

This patch simplifies for() loop used in
ahci_enumerate_ports(). It makes it more readable.
Similar thing was done in b913501
({platform,super}-intel: Fix two resource leaks).

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
---
 super-intel.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/super-intel.c b/super-intel.c
index 8a80c5b..1bc3688 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1624,7 +1624,10 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b
 	 * this hba
 	 */
 	dir = opendir("/sys/dev/block");
-	for (ent = dir ? readdir(dir) : NULL; ent; ent = readdir(dir)) {
+	if (!dir)
+		return 1;
+
+	for (ent = readdir(dir); ent; ent = readdir(dir)) {
 		int fd;
 		char model[64];
 		char vendor[64];
-- 
2.5.0


  reply	other threads:[~2016-03-11 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 15:47 [PATCH 1/2] super-intel: Make print_vmd_attached_devs() return int again Pawel Baldysiak
2016-03-11 15:47 ` Pawel Baldysiak [this message]
2016-03-11 17:36   ` [PATCH 2/2] super-intel: Simplify for() loop in ahci_enumerate_ports Jes Sorensen
2016-03-11 17:36 ` [PATCH 1/2] super-intel: Make print_vmd_attached_devs() return int again Jes Sorensen

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=1457711236-16990-2-git-send-email-pawel.baldysiak@intel.com \
    --to=pawel.baldysiak@intel.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=jes.sorensen@redhat.com \
    --cc=linux-raid@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).