From patchwork Mon Jun 5 13:28:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 9766263 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 6B0A260353 for ; Mon, 5 Jun 2017 13:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 621C026E56 for ; Mon, 5 Jun 2017 13:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 561ED27F86; Mon, 5 Jun 2017 13:48:08 +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 22C0C26E56 for ; Mon, 5 Jun 2017 13:48:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 037EB89C52; Mon, 5 Jun 2017 13:48:06 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3D42189C21 for ; Mon, 5 Jun 2017 13:48:04 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.9]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v55DSe8V023558; Mon, 5 Jun 2017 14:28:40 +0100 From: Liviu Dudau To: Petri Latvala Date: Mon, 5 Jun 2017 14:28:40 +0100 Message-Id: <20170605132840.9125-5-liviu.dudau@arm.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170605132840.9125-1-liviu.dudau@arm.com> References: <20170605132840.9125-1-liviu.dudau@arm.com> Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 4/4] lib/igt_debugfs: Only use valid values in igt_crc_to_str() 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 From: Brian Starkey Not all elements in the crc array may be valid, so only use the valid ones to generate the string. Signed-off-by: Brian Starkey Reviewed-by: Arkadiusz Hiler --- lib/igt_debugfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index f5ed3daf..80f25c61 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -312,10 +312,11 @@ void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b) */ char *igt_crc_to_string(igt_crc_t *crc) { - char buf[128]; + int i; + char buf[128] = { 0 }; - sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0], - crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]); + for (i = 0; i < crc->n_words; i++) + sprintf(buf + strlen(buf), "%08x ", crc->crc[i]); return strdup(buf); }