From patchwork Fri Apr 15 12:00:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8850581 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 10F0DC0553 for ; Fri, 15 Apr 2016 12:00:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06EF9202E9 for ; Fri, 15 Apr 2016 12:00:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EE360202DD for ; Fri, 15 Apr 2016 12:00:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65CDD6EC25; Fri, 15 Apr 2016 12:00:27 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9985E6EC25 for ; Fri, 15 Apr 2016 12:00:26 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id l6so5599631wml.3 for ; Fri, 15 Apr 2016 05:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y9dEkikdC6Yg+ajmJmVf95HGJd5wvUyeB48QO8g3lJE=; b=g2nXpxTv85S9hI9/B3WCMN3y6FE81MELEf5uSM3dmYg0VwXBfBlELm1fs0AEhGmXnL bZxaMHddEavRlKVwVgwzwsH7OP9Sp6Eh1yOP+BpVOF5f0ezaFwQySh2nCwxKVy1BKOVc qD82BaHeGzrAL1oKulIOnoFACmD1HeipOZ0cEdEeptZmbhE2g4VLKBE5/VjXtUE9SoK6 tGS60UsUYeu1qylZIRKP82g8j7dQMFRXbo7hkM63UZGTnTdcEQYTJ038lMfV+P7NTQnB icnnaYYlWjfOg+y/4GQQ6ne/J+m3V8yB9plhOYM8P2RYgX+GUo0+KPTyXqdj1Ei5gMT4 M2pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=Y9dEkikdC6Yg+ajmJmVf95HGJd5wvUyeB48QO8g3lJE=; b=aWSnVxEjqulRxTAixplI7RoJirY+9+iZsqg1BSAC8Z2ijzRKDbPvPsI9sKsEOJjRuZ F61S8B9DzVHSDRFQ9JDljfV1j6Hy1qK4Sm4Godv6/dF+Hnt4tiDYBCwe8VrFrNWjFAjz vsB8mDyjgm/NfC0K1GIAIWmTD/n/2Sigr2tm8HPkfz7oOO+GV0sALBU6MDeYEA+AYJG4 qzxJNcM9Am8LCD7D2OIe2IVEAMBiw1z7Vw2qO9zzZSk2LifeZYtQT4M1/jKOmb3J1B92 eV6D/wCfUx2FM6/ZUSGOf2DaNjEYeFJUdMzxclA+rkMU0KW2OqxwfgDuo38n/FUgHrsx XWIA== X-Gm-Message-State: AOPr4FVKr8vU9yqg9I7kZ5RpXmvdrNg475ZF3Krb0JkEfQCCsCErqWN8P/YAKaWqM9pMqQ== X-Received: by 10.28.165.142 with SMTP id o136mr3832677wme.31.1460721625240; Fri, 15 Apr 2016 05:00:25 -0700 (PDT) Received: from cizrna.lan ([109.72.12.224]) by smtp.gmail.com with ESMTPSA id d131sm11294324wmd.12.2016.04.15.05.00.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Apr 2016 05:00:23 -0700 (PDT) From: Tomeu Vizoso To: Intel GFX discussion Date: Fri, 15 Apr 2016 14:00:04 +0200 Message-Id: <1460721604-19685-1-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 Cc: Tomeu Vizoso Subject: [Intel-gfx] [PATCH] lib: Declare loop variable as volatile before setjmp 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 The variable used as loop counter in the igt_fixture macro had unspecified value from the setjmp(3) man page quoted below. Because of that, in certain circumstances and with -O2 and -Os, the initialization of that variable would be eliminated and the compiler would complain of uninitialized usage. Below can be found a snippet that reproduces the problem with GCC 5.3.1 and 4.9.3 and the errors as printed by 5.3.1. "The compiler may optimize variables into registers, and longjmp() may restore the values of other registers in addition to the stack pointer and program counter. Consequently, the values of automatic variables are unspecified after a call to longjmp() if they meet all the following criteria: · they are local to the function that made the corresponding setjmp(3) call; · their values are changed between the calls to setjmp(3) and longjmp(); and · they are not declared as volatile." static void test(void) { igt_subtest_group { igt_fixture { } igt_subtest("foo") { } igt_fixture { } } } In file included from lib/intel_batchbuffer.h:8:0, from lib/drmtest.h:39, from lib/igt.h:27, from tests/kms_addfb_basic.c:28: tests/kms_addfb_basic.c: In function 'tiling_tests.isra.0': lib/igt_core.h:110:43: warning: '__tmpint245' is used uninitialized in this function [-Wuninitialized] #define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \ ^ lib/igt_core.h:110:43: note: '__tmpint245' was declared here #define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \ ^ lib/igt_core.h:148:31: note: in definition of macro '__igt_tokencat2' #define __igt_tokencat2(x, y) x ## y ^ lib/igt_core.h:110:30: note: in expansion of macro 'igt_tokencat' #define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \ ^ tests/kms_addfb_basic.c:245:3: note: in expansion of macro 'igt_fixture' igt_fixture { Signed-off-by: Tomeu Vizoso --- lib/igt_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/igt_core.h b/lib/igt_core.h index b3fa7356e473..1b62371a7138 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -107,7 +107,7 @@ void __igt_fixture_end(void) __attribute__((noreturn)); * enumeration (e.g. when enumerating on systems without an intel gpu) such * blocks should be annotated with igt_fixture. */ -#define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \ +#define igt_fixture for (volatile int igt_tokencat(__tmpint,__LINE__) = 0; \ igt_tokencat(__tmpint,__LINE__) < 1 && \ __igt_fixture() && \ (sigsetjmp(igt_subtest_jmpbuf, 1) == 0); \