From patchwork Fri Aug 21 08:17:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 52608 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id AB9C822B05 for ; Fri, 21 Aug 2015 08:21:10 +0000 (UTC) Received: by labd1 with SMTP id d1sf19310411lab.0 for ; Fri, 21 Aug 2015 01:21:09 -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=i+1gUClfEH5N0nS5FjYBwowY+gh6ov3J7dNc1AMRnns=; b=l4wPSXIm4ZydsPTRsP7fND9id+BOOX0lsl+hnWZB8HSAczrc7ME/OiEEPaBNt8E+b3 NHehu2ow+DsGKw3G3E47FDHCjvTiy0OBJPp8iWVHOJpPFvTpoKs7UwnCzT8+GOqcn0qB H+hcnImzpPBcBhLrjgwJrDTcHrR9WjuNkEzDn2nDMBpYFqTV5BtNRFH/IoUvMI5Ppa8T IyarYKYMoPEYjICEv+IWxArvoNGnaoU4FjWNvhPEOu75UIJ4/f5OOsKkFQfMCEPTApPU s8y5ktVnDnyJ4R7JZp0BgZyW629vMSkQVspZZjzng89nDigb8jltdgD6QFiiREP0kJqa jCYQ== X-Gm-Message-State: ALoCoQnPiHkiMv4sCfRbRAlMFf1wcf7ye1qMWqgUqEeFFI8xHUqt2coP1I7mLmmJovfAZ5IDIP1p X-Received: by 10.112.139.137 with SMTP id qy9mr1995766lbb.17.1440145269435; Fri, 21 Aug 2015 01:21:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.169 with SMTP id c9ls138946laa.58.gmail; Fri, 21 Aug 2015 01:21:09 -0700 (PDT) X-Received: by 10.112.118.19 with SMTP id ki19mr6815261lbb.108.1440145269323; Fri, 21 Aug 2015 01:21:09 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id x8si5711209lby.143.2015.08.21.01.21.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2015 01:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbsx3 with SMTP id sx3so39056908lbb.0 for ; Fri, 21 Aug 2015 01:21:09 -0700 (PDT) X-Received: by 10.112.141.136 with SMTP id ro8mr6784166lbb.88.1440145269206; Fri, 21 Aug 2015 01:21:09 -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.162.200 with SMTP id yc8csp503719lbb; Fri, 21 Aug 2015 01:21:07 -0700 (PDT) X-Received: by 10.140.147.69 with SMTP id 66mr15971285qht.57.1440145266776; Fri, 21 Aug 2015 01:21:06 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l81si11601732qkh.104.2015.08.21.01.21.05 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Aug 2015 01:21:06 -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 1ZShXo-0005GB-3j; Fri, 21 Aug 2015 08:19:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZShXm-0005G6-S5 for xen-devel@lists.xen.org; Fri, 21 Aug 2015 08:19:22 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 7A/2A-24494-A0FD6D55; Fri, 21 Aug 2015 08:19:22 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1440145144!29585658!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 21712 invoked from network); 21 Aug 2015 08:19:20 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 21 Aug 2015 08:19:20 -0000 Received: from 172.24.1.50 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.50]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CQZ81179; Fri, 21 Aug 2015 16:17:41 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Fri, 21 Aug 2015 16:17:32 +0800 From: Shannon Zhao To: , Date: Fri, 21 Aug 2015 16:17:02 +0800 Message-ID: <1440145024-10516-2-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1440145024-10516-1-git-send-email-zhaoshenglong@huawei.com> References: <1440145024-10516-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected Cc: Hanjun Guo , "Rafael J. Wysocki" , shannon.zhao@linaro.org, Tomasz Nowicki , zhaoshenglong@huawei.com Subject: [Xen-devel] [PATCH v3 1/3] 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.175 as permitted sender) smtp.mailfrom=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: Tomasz Nowicki 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. Acked-by: Grant Likely Signed-off-by: Tomasz Nowicki Signed-off-by: Hanjun Guo Signed-off-by: Rafael J. Wysocki [Linux commit 4ceacd02f5a1795c5c697e0345ee10beef675290] 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 e57cf2a..1da2127 100644 --- a/xen/drivers/acpi/tables.c +++ b/xen/drivers/acpi/tables.c @@ -239,10 +239,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); }