From patchwork Tue Jan 13 13:39:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5620481 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B9436C058D for ; Tue, 13 Jan 2015 13:39:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4598205F9 for ; Tue, 13 Jan 2015 13:39:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 041722034C for ; Tue, 13 Jan 2015 13:39:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C50E6E471; Tue, 13 Jan 2015 05:39:53 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 40CF06E471 for ; Tue, 13 Jan 2015 05:39:52 -0800 (PST) Received: by mail-wi0-f173.google.com with SMTP id em10so5526731wid.0 for ; Tue, 13 Jan 2015 05:39:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dqnu07izw3jrn7ymHprWVU5Bb0JasbA/cS62psuAVs8=; b=OuAGx5RPZB/JZOzXaCTVu6lx81sEHt5t/e3T9w+bId5dqbWsx8HNY+MQAlSkJB4z3O vQBC7g/2Pefav1it9FtDRH/D6J1QuMkxYggZe51KI5jf57av8dgZOoPeBRzAH9lA+14U YrU5u8VrlhU3zAAF9ZkxlIX6etzFVfHLh53rb2yHYVeRSKkE1mpVSVJWPUgoMHtqthzS 4aKOPPV+mag9VjVrimtdzLcbvqN/4sDoJvpW9mEcsE1HOtJ4REWEInUqNEOJpv7qLrOZ oYvUyUAMJIpXxlHtgNDbNEAwREm7ihvoiQ6rRlXMfxblSeb3RhjuUdhTZHYWHRE5B6AR F2Iw== X-Gm-Message-State: ALoCoQkKL6OuO3MS3rdpYz1ApYhRmqUEKJ10cOaVlypBjQfSjDd1QgI4+4n1pJAEfZ0NE6pUIqzG X-Received: by 10.194.190.10 with SMTP id gm10mr12000729wjc.91.1421156391353; Tue, 13 Jan 2015 05:39:51 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id i15sm25768000wjq.22.2015.01.13.05.39.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2015 05:39:50 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Tue, 13 Jan 2015 13:39:48 +0000 Message-Id: <1421156389-6987-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH i-g-t 1/2] intel_gpu_frequency: fix array bounds warning 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 Add a parameter for the size of the act_upon array in the parse function since its size cannot be calculated with ARRAY_SIZE from just the pointer. Cc: Ben Widawsky Signed-off-by: Thomas Wood --- tools/intel_gpu_frequency.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c index d9e7d22..aedceb4 100644 --- a/tools/intel_gpu_frequency.c +++ b/tools/intel_gpu_frequency.c @@ -179,7 +179,7 @@ version(const char *prog) /* Returns read or write operation */ static bool -parse(int argc, char *argv[], bool *act_upon, int *new_freq) +parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq) { int c, tmp; bool write = false; @@ -193,7 +193,7 @@ parse(int argc, char *argv[], bool *act_upon, int *new_freq) /* No args means -g" */ if (argc == 1) { - for (c = 0; c < ARRAY_SIZE(act_upon); c++) + for (c = 0; c < act_upon_n; c++) act_upon[c] = true; goto done; } @@ -233,7 +233,7 @@ parse(int argc, char *argv[], bool *act_upon, int *new_freq) } } else { int i; - for (i = 0; i < ARRAY_SIZE(act_upon); i++) + for (i = 0; i < act_upon_n; i++) act_upon[i] = true; } break; @@ -333,7 +333,7 @@ int main(int argc, char *argv[]) devid = intel_get_drm_devid(drm_open_any()); device = drm_get_card(); - write = parse(argc, argv, targets, set_freq); + write = parse(argc, argv, targets, ARRAY_SIZE(targets), set_freq); fail = write; /* If we've previously locked the frequency, we need to make sure to set things