From patchwork Thu Sep 15 22:28:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 9334823 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 E833E601C2 for ; Thu, 15 Sep 2016 22:28:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E106D29BAF for ; Thu, 15 Sep 2016 22:28:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D43BF29C57; Thu, 15 Sep 2016 22:28:44 +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=1.6 required=2.0 tests=BAYES_50, RCVD_IN_DNSWL_NONE, RDNS_NONE autolearn=no version=3.3.1 Received: from ml01.01.org (unknown [198.145.21.10]) (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 80BBF29BAF for ; Thu, 15 Sep 2016 22:28:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8EB491A1F08; Thu, 15 Sep 2016 15:28:23 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B16F71A1F08 for ; Thu, 15 Sep 2016 15:28:21 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP; 15 Sep 2016 15:28:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,341,1470726000"; d="scan'208";a="9584929" Received: from djiang5-desk3.ch.intel.com ([143.182.137.38]) by orsmga004.jf.intel.com with ESMTP; 15 Sep 2016 15:28:16 -0700 Subject: [PATCH] ndctl: move test/dax-errors buffer to global to avoid gcc optimization From: Dave Jiang To: vishal.l.verma@intel.com Date: Thu, 15 Sep 2016 15:28:16 -0700 Message-ID: <147397849629.229288.3348330822830988783.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Some gcc toolchain are optimizing out the memcpy and this causes dax-errors to not trigger the SIG_BUS when doing memcpy on an mmap'd buffer. By moving the buffer to a global variable this bypasses the optimization and allow the test to work as intended. Signed-off-by: Dave Jiang Reviewed-by: Vishal Verma --- test/dax-errors.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/dax-errors.c b/test/dax-errors.c index 11d0031..9ea5c91 100644 --- a/test/dax-errors.c +++ b/test/dax-errors.c @@ -17,6 +17,8 @@ static sigjmp_buf sj_env; static int sig_count; +/* buf is global in order to avoid gcc memcpy optimization */ +static void *buf; static void sigbus_hdl(int sig, siginfo_t *siginfo, void *ptr) { @@ -27,7 +29,7 @@ static void sigbus_hdl(int sig, siginfo_t *siginfo, void *ptr) static int test_dax_read_err(int fd) { - void *base, *buf; + void *base; int rc = 0; if (fd < 0) {