From patchwork Thu Feb 25 14:49:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 8423831 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3BCFC9FC33 for ; Thu, 25 Feb 2016 14:51:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7258E2020F for ; Thu, 25 Feb 2016 14:51:54 +0000 (UTC) Received: from lists.xen.org (unknown [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 868A52035E for ; Thu, 25 Feb 2016 14:51:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aYxEH-00087l-WA; Thu, 25 Feb 2016 14:49:21 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aYxEF-00084o-Sk for xen-devel@lists.xen.org; Thu, 25 Feb 2016 14:49:19 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 6C/5E-03293-F641FC65; Thu, 25 Feb 2016 14:49:19 +0000 X-Env-Sender: prvs=856900a8f=George.Dunlap@citrix.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1456411754!25026848!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31517 invoked from network); 25 Feb 2016 14:49:18 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-10.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2016 14:49:18 -0000 X-IronPort-AV: E=Sophos;i="5.22,498,1449532800"; d="scan'208";a="341078886" From: George Dunlap To: Date: Thu, 25 Feb 2016 14:49:02 +0000 Message-ID: <1456411743-17741-8-git-send-email-george.dunlap@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456411743-17741-1-git-send-email-george.dunlap@eu.citrix.com> References: <1456411743-17741-1-git-send-email-george.dunlap@eu.citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: George Dunlap , Ian Jackson , Wei Liu , George Dunlap Subject: [Xen-devel] [PATCH 7/8] tools/xenalyze: Fix multiple instances of *HYPERCALL_MAX X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We HYPERCALL_MAX defined as the maximum enumerated hypercall, and we have PV_HYPERCALL_MAX defined as some other number (presumably based on experience with actual hypercalls). Both are used to size arrays (hypercall_name[] and pv_data.hypercall_count[], respectively). Rename PV_HYPERCALL_MAX to HYPERCALL_MAX, and use HYPERCALL_MAX to size (and iterate over) all arrays. While we're at it, print "(unknown)" for values not present in the hypercall_name[] array. CID 1306868 Signed-off-by: George Dunlap Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/xentrace/xenalyze.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 3e26a4c..4ae50b8 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -1068,9 +1068,10 @@ enum { HYPERCALL_sysctl, HYPERCALL_domctl, HYPERCALL_kexec_op, - HYPERCALL_MAX }; +#define HYPERCALL_MAX 38 + char *hypercall_name[HYPERCALL_MAX] = { [HYPERCALL_set_trap_table]="set_trap_table", [HYPERCALL_mmu_update]="mmu_update", @@ -1509,13 +1510,12 @@ char *pv_name[PV_MAX] = { [PV_HYPERCALL_SUBCALL]="hypercall (subcall)", }; -#define PV_HYPERCALL_MAX 56 #define PV_TRAP_MAX 20 struct pv_data { unsigned summary_info:1; int count[PV_MAX]; - int hypercall_count[PV_HYPERCALL_MAX]; + int hypercall_count[HYPERCALL_MAX]; int trap_count[PV_TRAP_MAX]; }; @@ -6405,7 +6405,7 @@ void pv_hypercall_process(struct record_info *ri, struct pv_data *pv) { } if(opt.summary_info) { - if(eax < PV_HYPERCALL_MAX) + if(eax < HYPERCALL_MAX) pv->hypercall_count[eax]++; } @@ -6566,10 +6566,10 @@ void pv_summary(struct pv_data *pv) { switch(i) { case PV_HYPERCALL: case PV_HYPERCALL_V2: - for(j=0; jhypercall_count[j]) printf(" %-29s[%2d]: %6d\n", - hypercall_name[j], + hypercall_name[j]?:"(unknown)", j, pv->hypercall_count[j]); } @@ -6677,7 +6677,7 @@ void pv_hypercall_v2_process(struct record_info *ri, struct pv_data *pv, int op = pv_hypercall_op(ri); if(opt.summary_info) { - if(op < PV_HYPERCALL_MAX) + if(op < HYPERCALL_MAX) pv->hypercall_count[op]++; }