From patchwork Fri Aug 14 03:36:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 52414 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id E52642031F for ; Fri, 14 Aug 2015 03:42:17 +0000 (UTC) Received: by wicul11 with SMTP id ul11sf2323238wic.1 for ; Thu, 13 Aug 2015 20:42:17 -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=uzxMDLbZc6frfuNNZlt4dppDpEge2vbTwPUsbuorAdk=; b=ShKsErvu1tJ+lBEUxtBEnOQTx++GDfEJ2ax8fgc8zuviDNRG8J9FFsJ+X2lAW2BT1G bXjJsNc+zOjSpGZHdMw3KZaNZEaiFW9jCkHbo43CUKpCJvv1CJqWp/gsxtMsx5633EOk vTdfN7yhMzf94SUeYlGhzuaQoV61aWzLLUFEjS/bFweq2/39vaOebiIyYznX0ihjmoFO XhkeS7UNRctUxi4+nW6CGV3pvCQQnddr6OdD7NeIInrvidJskDUcCpNiAu2PqUoagOXv sFod7OZiCVGIbI8v1VuV4CxxckZbJ8bReeGAGy2FKt9cmIqJEhDCRVyYaHu+1Ly5hqTW iZKw== X-Gm-Message-State: ALoCoQmEXUPIb8bXLA9q9lMLBUePAY9MW6w6fsXMPVlsWwL1F9S/RRm1pXeECruMt1569ep1iYtt X-Received: by 10.112.78.101 with SMTP id a5mr9236854lbx.9.1439523737217; Thu, 13 Aug 2015 20:42:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.1 with SMTP id o1ls294142lao.12.gmail; Thu, 13 Aug 2015 20:42:17 -0700 (PDT) X-Received: by 10.112.12.233 with SMTP id b9mr39583524lbc.91.1439523736988; Thu, 13 Aug 2015 20:42:16 -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 x8si5109152laj.25.2015.08.13.20.42.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2015 20:42:16 -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 sx3so38249741lbb.0 for ; Thu, 13 Aug 2015 20:42:16 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr40818125lbb.35.1439523736842; Thu, 13 Aug 2015 20:42:16 -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 l6csp1328197lba; Thu, 13 Aug 2015 20:42:15 -0700 (PDT) X-Received: by 10.140.235.129 with SMTP id g123mr41843853qhc.11.1439523735381; Thu, 13 Aug 2015 20:42:15 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i132si7356752qhc.129.2015.08.13.20.42.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Aug 2015 20:42:15 -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 1ZQ5rA-0003FB-95; Fri, 14 Aug 2015 03:40:36 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZQ5r8-0003F1-GQ for xen-devel@lists.xen.org; Fri, 14 Aug 2015 03:40:34 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 93/7B-10678-1336DC55; Fri, 14 Aug 2015 03:40:33 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1439523625!33662499!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 6.13.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1722 invoked from network); 14 Aug 2015 03:40:32 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-4.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 14 Aug 2015 03:40:32 -0000 Received: from 172.24.1.49 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.49]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BKZ68370; Fri, 14 Aug 2015 11:37:09 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Fri, 14 Aug 2015 11:36:58 +0800 From: Shannon Zhao To: , Date: Fri, 14 Aug 2015 11:36:07 +0800 Message-ID: <1439523368-22256-2-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1439523368-22256-1-git-send-email-zhaoshenglong@huawei.com> References: <1439523368-22256-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.55CD6266.0042, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: fc7389b43d019f49e26491233d0b7fbf Cc: Hanjun Guo , "Rafael J. Wysocki" , shannon.zhao@linaro.org, Tomasz Nowicki , zhaoshenglong@huawei.com Subject: [Xen-devel] [PATCH v2 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.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 Ported from Linux commit 4ceacd02f5a1795c5c697e0345ee10beef675290. 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 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); }