From patchwork Tue Jun 20 20:09:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 106015 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1580750qgd; Tue, 20 Jun 2017 13:10:58 -0700 (PDT) X-Received: by 10.99.140.79 with SMTP id q15mr30313724pgn.140.1497989458415; Tue, 20 Jun 2017 13:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497989458; cv=none; d=google.com; s=arc-20160816; b=xgQ+pPH0c3rew8MwQ5EgXf+ms4hKM/upQs4q/2ArFohx14K/D/XS6cq6P0Qx11c0Fd r/fOAF1O3e7w05Wmb3nPvKwmwcfaiIYrFAciEdFzK2xs3y5O4wA0Yw6phiPPBtTSQFsh 44dus8E7WW3njvyvyw76Dm3dEPCsogSSB5GXHF3wMrYCRuUoObxiELps0RpUvcVttqFq wHrwmUFOC70Gw2a0js22gY/vMWfjs2NhZ8RFTUiwE7g0D1Uc9CjGRb+sbjUvMNqDpV6Q vZWjyVOHSupkZDN2DEQwJMVXpUX2Io9S5OTi7yGNs2dg3oJZHBnsj3zN8tYSFEnKnuQc 4c8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1NO1VPNyT5zQFiKG1CxMjuA7aatwAGwgYiD/OPxKafY=; b=umxev9VtwQqUFjcFpxWl/UZJ1WQqvV4CWIkR9RFvhzzDSJA7o+M+ZrUQqNgjckE4B6 z6lDitXTe2kakXTr8UVsATT2C9flJcsgziKHAbCwlxqcKjhAhDR7RzoGF2hcyswm4D1i QpsOoWX6TKKHgIz31jdR90M22pK+hHvsYELHSkoiHjU0ywO45Sg1LkemwNfbEvs6NWlS YrS2xJJ8b0Cm1ywErCZdnFKArLT0ZARQWTxyxobkPIdctfi2jkDYd6OsCT3dstbJzdW8 CBpntgqUFl4YoOl5ZKRB4X3A+9IhMPFmXkmczNjWrXVVeH97KBTzBmNpOmbeFOzPa6qz VHRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t189si11137535pfd.421.2017.06.20.13.10.57; Tue, 20 Jun 2017 13:10:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752097AbdFTUKu (ORCPT + 25 others); Tue, 20 Jun 2017 16:10:50 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:64311 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751135AbdFTUKt (ORCPT ); Tue, 20 Jun 2017 16:10:49 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0M5tFN-1dgtG410OH-00xsAM; Tue, 20 Jun 2017 22:10:01 +0200 From: Arnd Bergmann To: Andrew Morton Cc: Ian Abbott , Michal Nazarewicz , Kees Cook , Borislav Petkov , Johannes Berg , Peter Zijlstra , Alexander Potapenko , Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH] kernel.h: fix new warnings for container_of() Date: Tue, 20 Jun 2017 22:09:20 +0200 Message-Id: <20170620200940.90557-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:0F0U6gEj1tZP2HiB4uBT59mY2ZJ2wiNBeOLeTeoygarZAFTnFRi C0QwsJ6ylLDk4lCSDPswT1UNuuNbiGK41KdMqq1ZqCM8RHgME+mv5rsDiW5NXrs/vYdFopI wkMWiWX9/rKJJTY4XfOUL+i6JGLxa2/owxDzDMSU5aSpnioX7golkgqUWeealiDbVeE6hEI R70gvRbIfaTfJ7mq+BclA== X-UI-Out-Filterresults: notjunk:1; V01:K0:arSB2plncDk=:HEQ4kuOmHmZSznLuU6uDOE Z+dm02JplTgWEEEyYrcW6rlrS9EedKr3CnVqjY+r0eyKNhGH61W/zWlTdv4pWbhVmH1Ml5A51 e58SjfbPhgoU0O/X+zBur+GyUqAeOnEfXMnlPxMfkz0LaqPHMRedyjREla+o1AlkuasZl6LpM TOv+TGe/eKyOWA6SSG7nwCFQqDktZvFmnfYFlTIn/YE17omfW2lYA/nxiAsBsz4BImQKyOVPA 25J3S+frWlBddt5Kg8QKTdA8EuOQcgJ0jjrZ0ApAQ/EBf5m5Ip6O9wobKfyoDsYC5CwP7kPB/ fCfpIjITZH912mgmCc2t5GSQqd+rXcczs38WPF3eBzef1C6K1tUBESXTArtnWO/M/mn9D7jgI WWfZlhXaUiDFjJg24TxK0TEOzBZt6VDmBoAYQkW663dViSevWt/z1OlzTa/AVzq9Ijb/Dgfnb g3iXKn2wqSVBKKAHS6I2UZjHQe2vDg7qZoejnez0M44DobAqv9IhE0zrrsI1WWdXeGSHH3/0U F+Lm0FV+h7NnqfLLqeQHLyl0gTNMad27Ofs9SG4pibJ1UgjLjqNTgHKXQudnegsfOv0GBzPXA rUsbLrFth9ORwxszukfXFWrD7CuTSWkvd5P1RSpW8XE7dUj1qafSki7+LbMvdDl6KfCWKwhbH 9v4/langdGY7UUxZZXcU298eFKnkuMDOhy9ETa4TCmN0e8dVMgOJwxZBbOLh6vrle+7M= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I see new warnings with gcc-7.0.1 with the modified container_of(): fs/f2fs/dir.c: In function 'F2FS_I': fs/f2fs/f2fs.h:1122:385: note: found mismatched ssa struct pointer types: 'struct f2fs_inode_info' and 'struct inode' This seems to happen for all structures that have a zero offset between the member and the container structure, i.e. idential pointers. Reverting to an intermediate pointer avoids the warning, and using a void pointer instead of the target type should also avoid regressing on the previous patch again. Fixes: mmotm ("kernel.h: handle pointers to arrays better in container_of()") Signed-off-by: Arnd Bergmann --- include/linux/kernel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.9.0 Acked-by: Ian Abbott diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d043adadcf33..bd6d96cf80b1 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -856,10 +856,11 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } * */ #define container_of(ptr, type, member) ({ \ + void *__mptr = (void *)(ptr); \ BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ !__same_type(*(ptr), void), \ "pointer type mismatch in container_of()"); \ - ((type *)((char *)(ptr) - offsetof(type, member))); }) + ((type *)(__mptr - offsetof(type, member))); }) /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD