From patchwork Tue Aug 4 04:19:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 51891 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 68DEF228F2 for ; Tue, 4 Aug 2015 04:31:46 +0000 (UTC) Received: by lady2 with SMTP id y2sf1018715lad.1 for ; Mon, 03 Aug 2015 21:31:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=rhbpAhvDIp/Z+aWoiffR/lVCtcs92dvnrMy8i0j2l+o=; b=F7qQNaeaUMoKQ0ShgAeBKfUNTdljY5rz4h92mAEw8GokkhK9Kuhu9KsuE24LdWXJ7S 4IFb+696dwBbfZTdWSQwl4VrnqIXXU9O/pKMy0nOUcHmbCuswM1GM/VTGr/P+v0+szYu Yy6B2yTVQ/UaoRDKvwJEyHFknawRiGQSXqbONHKBWOVOvOdPhAq0hKmiqD8f4bevu6NR UCMlFJBBKNteZ4YiRsACzSB/UsZulYd18zfmmvxgNfzqJjG4lto0Z+AL3X4/bgttzP6L t2PUQTUQOZKyOnOZEl3BxF4GPcXkE2qJV+RhVtGpUMpsuvyN4S4f6BPWVTGUCmHYdnw/ nM1Q== X-Gm-Message-State: ALoCoQkUgbGYXVb0hRXy8kuu5fGSaXGQUo8+Euw4pBJLXNn1L/aaOsptbKzRERL06jeARtqMubsc X-Received: by 10.112.142.97 with SMTP id rv1mr471733lbb.12.1438662704221; Mon, 03 Aug 2015 21:31:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.65 with SMTP id yg1ls603083lab.26.gmail; Mon, 03 Aug 2015 21:31:43 -0700 (PDT) X-Received: by 10.152.36.7 with SMTP id m7mr1226131laj.87.1438662703827; Mon, 03 Aug 2015 21:31:43 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id f10si13752137lam.75.2015.08.03.21.31.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 21:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbyj8 with SMTP id yj8so88206133lbb.0 for ; Mon, 03 Aug 2015 21:31:43 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr1295371lal.35.1438662703279; Mon, 03 Aug 2015 21:31:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp2203241lba; Mon, 3 Aug 2015 21:31:42 -0700 (PDT) X-Received: by 10.180.189.17 with SMTP id ge17mr38979644wic.90.1438662702375; Mon, 03 Aug 2015 21:31:42 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id k4si262715wif.101.2015.08.03.21.31.41 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Aug 2015 21:31:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZMTrQ-0003Yc-Du; Tue, 04 Aug 2015 04:29:56 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZMTrP-0003YX-2E for xen-devel@lists.xen.org; Tue, 04 Aug 2015 04:29:55 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 46/0F-28791-2CF30C55; Tue, 04 Aug 2015 04:29:54 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1438662584!31584371!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 6.13.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8238 invoked from network); 4 Aug 2015 04:29:53 -0000 Received: from unknown (HELO szxga02-in.huawei.com) (119.145.14.65) by server-11.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 4 Aug 2015 04:29:53 -0000 Received: from 172.24.1.51 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.51]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CPV01967; Tue, 04 Aug 2015 12:19:58 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.158.1; Tue, 4 Aug 2015 12:19:50 +0800 From: Shannon Zhao To: , Date: Tue, 4 Aug 2015 12:19:31 +0800 Message-ID: <1438661972-10140-2-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1438661972-10140-1-git-send-email-zhaoshenglong@huawei.com> References: <1438661972-10140-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected Cc: shannon.zhao@linaro.org, zhaoshenglong@huawei.com Subject: [Xen-devel] [PATCH 1/2] ACPI/table: Always count matched and successfully parsed entries X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Shannon Zhao acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0, but since its count variable is only incremented if max_entries is not 0, the function always returns 0 for max_entries equal to 0. It would be more useful if it returned the number of entries matched instead, so make it increment count in that case too. Signed-off-by: Tomasz Nowicki Signed-off-by: Shannon Zhao --- xen/drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c index 1beca79..822689e 100644 --- a/xen/drivers/acpi/tables.c +++ b/xen/drivers/acpi/tables.c @@ -240,10 +240,13 @@ acpi_table_parse_entries(char *id, } if (entry->type == entry_id - && (!max_entries || count++ < max_entries)) + && (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL; + count++; + } + entry = (struct acpi_subtable_header *) ((unsigned long)entry + entry->length); }