From patchwork Thu Dec 1 01:24:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lyude Paul X-Patchwork-Id: 9455267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0A4460585 for ; Thu, 1 Dec 2016 01:25:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3820283E4 for ; Thu, 1 Dec 2016 01:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A84AD2849F; Thu, 1 Dec 2016 01:25:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01A2C283E4 for ; Thu, 1 Dec 2016 01:25:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63D286E664; Thu, 1 Dec 2016 01:24:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 844D06E320 for ; Thu, 1 Dec 2016 01:24:55 +0000 (UTC) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22C963D961; Thu, 1 Dec 2016 01:24:55 +0000 (UTC) Received: from whitewolf.lyude.net.com (vpn-57-119.rdu2.redhat.com [10.10.57.119]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB11OpIT020682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Nov 2016 20:24:54 -0500 From: Lyude To: intel-gfx@lists.freedesktop.org Date: Wed, 30 Nov 2016 20:24:47 -0500 Message-Id: <20161201012448.16334-5-lyude@redhat.com> In-Reply-To: <20161201012448.16334-1-lyude@redhat.com> References: <20161201012448.16334-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Dec 2016 01:24:55 +0000 (UTC) Cc: Lyude Subject: [Intel-gfx] [RFC i-g-t v3 4/5] igt_debugfs: Make igt_crc_to_string() work with other CRC types X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Intel GPUs have CRC values with 5 n_words, but the Chamelium's definitely doesn't. So make igt_crc_to_string() a little smarter so it can handle this. Signed-off-by: Lyude --- lib/igt_debugfs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 9142e3f..4809b73 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -290,11 +290,18 @@ void igt_assert_crc_equal(igt_crc_t *a, igt_crc_t *b) char *igt_crc_to_string(igt_crc_t *crc) { char buf[128]; + char *p; + int i, len; + + for (i = 0, p = buf; + i < crc->n_words; + i++, p += len) { + snprintf(p, sizeof(buf) - (p - buf), "%08x %n", + crc->crc[i], &len); + } - igt_assert_eq(crc->n_words, 5); - - sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0], - crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]); + /* Strip the trailing space */ + *strrchr(buf, ' ') = '\0'; return strdup(buf); }