From patchwork Sun Sep 9 23:53:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10593527 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 50D9614E2 for ; Mon, 10 Sep 2018 02:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DCB528CC3 for ; Mon, 10 Sep 2018 02:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E5A428D0C; Mon, 10 Sep 2018 02:55:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A8A928CC3 for ; Mon, 10 Sep 2018 02:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726132AbeIJHqt (ORCPT ); Mon, 10 Sep 2018 03:46:49 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53964 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbeIJHqt (ORCPT ); Mon, 10 Sep 2018 03:46:49 -0400 Received: by mail-wm0-f66.google.com with SMTP id b19-v6so19909190wme.3 for ; Sun, 09 Sep 2018 19:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SgqGoS7BHC02IjfsogezWuKtBF1aAfcQcEzl64td274=; b=AYNLSkr8LVp2Ka9iiDMOrgRXWQcL7IgyZ+6993d1L/zPzkQj6Q2sRQUM0dko3tQ8uq ESwUaRfRNaPAB2Ddc/BzysRYNUmk9S13HLWh3SdxiUhtNkEuBSswTMk/S/8/5UoI2se4 b2jMzThM9SMCE8omYv9lZDv3eQ901STw9pvTED6gwlocOF56kU/MuW4y9CLdkmIgTjYt +tEDPxjMl4+c7U14usElDO4iHNht8TTlh9HQu+URi9PqkyI8/SnbMzQ4DNxG43E9lMTL oWupFj4LKLiuRAxE+cr3mUtaEk3p1gdElhOo+j+jQZyTQ54zA0Ic6gvEwJzNrZW94/td KW8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SgqGoS7BHC02IjfsogezWuKtBF1aAfcQcEzl64td274=; b=bgWilIrGFSdu1V1cBQF1N/z/sD34wsuoqf2lM1ZXGMhe5VanzSF5wSPzLxijK3p2H1 pldWB8xKG00WY8s1Yy/dAr7AuX5mURdezhzTAv3nwG4jgzyVGVhYlVEvmUioBcNiYBvI qfNEaRwZdR/GvnzJ32NuUbz6h16G9CWLEpRHMeAePZihHR7axAGqbHkUKCYgmEI4njqe DXgUauDK3JlvPjjoj3Z9kIp3/BA/p5KRBZEnBlCljxXm7Ng9J7ypanMnwy7RgoiYSZjf sN+QFI9BIkkpJof45LJ4ibZDstKf+RJiYUSyfik5KWZYUbLWTTQ1W6w8dI3X1IvLTzKq 3JqQ== X-Gm-Message-State: APzg51BvR52F629gpqXJyJ7vSuoofnVDRx76Lxjy8MwQGBfo2Jls9kNY PhxMJHUtDF/Ligh5CI1kxQcoR6sr X-Google-Smtp-Source: ANB0VdZHRoRn97T4IxiWCYLLyJYsiSuEL4z0xW4wp0GnJiwynXugveRzFwOeTNUYsFTz8TENynthcA== X-Received: by 2002:a1c:b9cf:: with SMTP id j198-v6mr11521772wmf.93.1536537330858; Sun, 09 Sep 2018 16:55:30 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4006:df00:5977:db62:b6c9:6a45]) by smtp.gmail.com with ESMTPSA id n11-v6sm15121516wra.26.2018.09.09.16.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:55:30 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH 1/4] test: make test Waddress-space-strict succeed on 32-bit Date: Mon, 10 Sep 2018 01:53:24 +0200 Message-Id: <20180909235327.26252-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180909235327.26252-1-luc.vanoostenryck@gmail.com> References: <20180909235327.26252-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test Waddress-space-strict made assumptions about the relative size of integers & pointers. Since this test was crafted on a 64-bit machine, the test was running fine for LP64 but failed on a 32-bit machine (or anything using IP32, like using the -m32 option). However, since the test is about conversion of address-spaces, using integers of different size adds no value, and indeed brings problems. Fix this by limiting the conversions to a single integer type, the one with the same size as pointers on ILP32 & LP64: long. Reported-by: Ramsay Jones Signed-off-by: Luc Van Oostenryck --- validation/Waddress-space-strict.c | 33 +++++++----------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/validation/Waddress-space-strict.c b/validation/Waddress-space-strict.c index 5071aab26..871da282a 100644 --- a/validation/Waddress-space-strict.c +++ b/validation/Waddress-space-strict.c @@ -1,33 +1,22 @@ #define __user __attribute__((address_space(1))) typedef unsigned long ulong; -typedef long long llong; typedef struct s obj_t; -static void expl(int i, ulong u, llong l, void *v, obj_t *o, obj_t __user *p) +static void expl(ulong u, void *v, obj_t *o, obj_t __user *p) { - (obj_t*)(i); - (obj_t __user*)(i); - (obj_t*)(u); (obj_t __user*)(u); - (obj_t*)(l); - (obj_t __user*)(l); - (obj_t*)(v); (obj_t __user*)(v); - (int)(o); (ulong)(o); - (llong)(o); (void *)(o); (obj_t*)(o); (obj_t __user*)(o); - (int)(p); // w (ulong)(p); // w! - (llong)(p); // w (void *)(p); // w (obj_t*)(p); // w (obj_t __user*)(p); // ok @@ -38,19 +27,11 @@ static void expl(int i, ulong u, llong l, void *v, obj_t *o, obj_t __user *p) * check-command: sparse -Wcast-from-as -Wcast-to-as $file * * check-error-start -Waddress-space-strict.c:10:10: warning: cast adds address space to expression () -Waddress-space-strict.c:13:10: warning: cast adds address space to expression () -Waddress-space-strict.c:16:10: warning: cast adds address space to expression () -Waddress-space-strict.c:19:10: warning: cast adds address space to expression () -Waddress-space-strict.c:26:10: warning: cast adds address space to expression () -Waddress-space-strict.c:28:10: warning: cast removes address space of expression -Waddress-space-strict.c:29:10: warning: cast removes address space of expression -Waddress-space-strict.c:30:10: warning: cast removes address space of expression -Waddress-space-strict.c:31:10: warning: cast removes address space of expression -Waddress-space-strict.c:32:10: warning: cast removes address space of expression -Waddress-space-strict.c:9:18: warning: non size-preserving integer to pointer cast -Waddress-space-strict.c:10:25: warning: non size-preserving integer to pointer cast -Waddress-space-strict.c:21:15: warning: non size-preserving pointer to integer cast -Waddress-space-strict.c:28:15: warning: non size-preserving pointer to integer cast +Waddress-space-strict.c:9:10: warning: cast adds address space to expression () +Waddress-space-strict.c:12:10: warning: cast adds address space to expression () +Waddress-space-strict.c:17:10: warning: cast adds address space to expression () +Waddress-space-strict.c:19:10: warning: cast removes address space of expression +Waddress-space-strict.c:20:10: warning: cast removes address space of expression +Waddress-space-strict.c:21:10: warning: cast removes address space of expression * check-error-end */