From patchwork Sun Jul 29 12:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10548187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED013112E for ; Sun, 29 Jul 2018 12:41:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC30E2A521 for ; Sun, 29 Jul 2018 12:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF9392A571; Sun, 29 Jul 2018 12:41:50 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 92F2C2A521 for ; Sun, 29 Jul 2018 12:41:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4D578811C; Sun, 29 Jul 2018 12:41:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CCA58811C; Sun, 29 Jul 2018 12:41:49 +0000 (UTC) Received: by mail-pl0-x241.google.com with SMTP id 6-v6so4260079plb.0; Sun, 29 Jul 2018 05:41:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=odcstujfMGuP6ltaJ9W5jp9asWIUM4/E58fGNbx31gE=; b=fVdFmMmfN581ipOg6OQu/+Uwh1hcf5Ae/8v0RNZd05CS4FNriWoE6NrlvrXJCQ+BlA Ef3jOANJj0rge8J6aNbkJ3iQyQJ9gdiFoLp4nsroDUY0Xzd78OLeR+FHNUD0e7ex3NOT OUY/Po7NCnXXSBt4gaQiF2kgqJ/WyH6o9NSwxyDjOKvhwc7wW+hq51fsmz/1eRhShURr XxLhXWvzOtBWuhDLSF+22tpg51/f2diu06T5k6ejZqTh1Q5vCcsZ2SVDUAyeTEXB4aKg EyzC1kL0OuyGGaFyjmeC0oLyvCIHDFhrFVBCcomzaM+3p1thdhcfyN0JCVhmlT6fOWUs 1EGQ== X-Gm-Message-State: AOUpUlG6tH0FfMRPIwhYnmjTl5F2tfXeain5FcX0rLpNrMAzAXfbplxC nMbJGi0sJjPuT4IAwdbxLL8= X-Google-Smtp-Source: AAOMgpfZ7l5mbJgySZSy4vP29/aZR57f0vzGWMMG+Zl7tWNSFcfTINt42ocorjH5SVTg34ww+DP/JQ== X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr12633865pla.277.1532868108826; Sun, 29 Jul 2018 05:41:48 -0700 (PDT) Received: from smtp.gmail.com ([140.113.61.252]) by smtp.gmail.com with ESMTPSA id r16-v6sm13551960pfe.173.2018.07.29.05.41.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Jul 2018 05:41:48 -0700 (PDT) Date: Sun, 29 Jul 2018 09:41:45 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180323 Subject: [Intel-gfx] [PATCH v2 i-g-t 2/2] Fix truncate string in the snprintf X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This patch fix the following GCC warning: ../tools/intel_reg.c: In function ‘dump_decode’: ../tools/intel_reg.c:203:41: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(decode, sizeof(decode), "\n%s", bin); [..] ../tools/intel_reg.c:200:40: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 1022 [-Wformat-truncation=] snprintf(decode, sizeof(decode), " (%s)\n%s", tmp, bin); [..] ../tools/intel_reg.c:200:4: note: ‘snprintf’ output between 5 and 2051 bytes into a destination of size 1024 snprintf(decode, sizeof(decode), " (%s)\n%s", tmp, bin); [..] Notice that snprintf writes in the decode variable the values from tmp and bin. These two variables together have 2048 bytes and some extra characters added by snprintf, this commit changed the size of decode to support the combination. Changes since V1: - Improve commit message Signed-off-by: Rodrigo Siqueira --- tools/intel_reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/intel_reg.c b/tools/intel_reg.c index ddff2794..15ebb86a 100644 --- a/tools/intel_reg.c +++ b/tools/intel_reg.c @@ -180,7 +180,7 @@ static void to_binary(char *buf, size_t buflen, uint32_t val) static void dump_decode(struct config *config, struct reg *reg, uint32_t val) { - char decode[1024]; + char decode[2060]; char tmp[1024]; char bin[1024];