From patchwork Thu Jan 10 17:21:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1023072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43bCWv2dd4z9sMM; Fri, 11 Jan 2019 04:23:39 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ghe3L-0003nt-Iy; Thu, 10 Jan 2019 17:23:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1ghe1L-0003dn-RE for fwts-devel@lists.ubuntu.com; Thu, 10 Jan 2019 17:21:31 +0000 Received: from 2.general.alexhung.us.vpn ([10.172.65.255] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ghe1L-0000Dh-7L; Thu, 10 Jan 2019 17:21:31 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2][V2] lib: fwts_ac_adapter: fix readdir(ac_power_dir) failing Date: Thu, 10 Jan 2019 09:21:27 -0800 Message-Id: <20190110172128.12484-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" As readdir() returns next directory, the position of the directory stream dirp needs to be reset by rewinddir(). Signed-off-by: Alex Hung Acked-by: Colin Ian King Acked-by: Ivan Hu --- src/lib/src/fwts_ac_adapter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c index 9dd828f7..853cf222 100644 --- a/src/lib/src/fwts_ac_adapter.c +++ b/src/lib/src/fwts_ac_adapter.c @@ -89,6 +89,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching) (void)closedir(ac_power_dir); return FWTS_ERROR; } + rewinddir(ac_power_dir); ac_interface = &fwts_ac_interfaces[SYS_INTERFACE]; /* then try older /proc interface */