From patchwork Wed May 30 00:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10437445 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 5A5F6601E9 for ; Wed, 30 May 2018 00:47:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A94F2811E for ; Wed, 30 May 2018 00:47:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F6E3286F9; Wed, 30 May 2018 00:47:02 +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 C8DA728709 for ; Wed, 30 May 2018 00:47:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BA566F577; Wed, 30 May 2018 00:47:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-x241.google.com (mail-qk0-x241.google.com [IPv6:2607:f8b0:400d:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B2D06F576; Wed, 30 May 2018 00:46:59 +0000 (UTC) Received: by mail-qk0-x241.google.com with SMTP id a195-v6so10505240qkg.3; Tue, 29 May 2018 17:46:59 -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=gp0peli7VbhgRNx2kjoAC8M4E1OJEe6N1XuzO39NiRM=; b=SEcBLvZ2NVxcqJQW4RJ77iszUcvRLumwPkek78uXANfOBw/Q5M7UHem7bkd+0EwBXe t3yjZWH1yC0OBKvYqh4qLzdgqlnsgOmUMXvtsAuhmk/jeSVaj9ypEW2vVYFuOhVEBPCZ eutVFuWQs1/7nY2lLZ6HiXTACcH9ZWRQLOD008+SlR7WxbJS+a6rUJQxQtXiAFtDmEQr Dr2QSFn0lIBbHWgCyG5H54Jhty+skprYwATIi68h9bD7QEeWrXalN1aR88Dsb8eL+xTk iT44DcFsyCMqViSgdReQ/6BHP7miwc+gSNZh7pyYm2uiadr/D46vg7W20rVb7szJXRXB P33w== X-Gm-Message-State: APt69E1rirp61Oph9hE2mV4AICOWE2Nvgvi4VYcyTmrPSBENoLuAvTt7 oKSjcNx0TUVxlymOOpt8cf4anA== X-Google-Smtp-Source: ADUXVKLqlJKlS3DmAu7HecS8+SgA+SvY1TI6ummnCYK0NhldP7rZKbmfgW61x/iWqFVJwQ7gNd1byw== X-Received: by 2002:a37:aa4d:: with SMTP id t74-v6mr543987qke.141.1527641218474; Tue, 29 May 2018 17:46:58 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id j13-v6sm9567188qke.87.2018.05.29.17.46.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 17:46:58 -0700 (PDT) Date: Tue, 29 May 2018 21:46:55 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: <0d8325c242cc19f74149bfe721e395bf4de951df.1527639529.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180512 Subject: [Intel-gfx] [PATCH i-g-t 2/3] Remove extra '\0' in strncpy in igt_save_module_param 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: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(data->name, name, PARAM_NAME_MAX_SZ); This error happens due to the '\0' character appended by strncpy. Notice that reduces by one in the total of bytes to be copied, in this case, is harmless because the strings received in the parameter already have '\0'. Signed-off-by: Rodrigo Siqueira --- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 5dd2761e..06f586d6 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1240,7 +1240,7 @@ static void igt_save_module_param(const char *name, const char *file_path) data = calloc(1, sizeof (*data)); igt_assert(data); - strncpy(data->name, name, PARAM_NAME_MAX_SZ); + strncpy(data->name, name, PARAM_NAME_MAX_SZ - 1); // -1 because of '\0' fd = open(file_path, O_RDONLY); igt_assert(fd >= 0);