From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965084AbcHaPwM convert rfc822-to-8bit (ORCPT ); Wed, 31 Aug 2016 11:52:12 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:55134 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933887AbcHaPwK (ORCPT ); Wed, 31 Aug 2016 11:52:10 -0400 From: Arnd Bergmann To: Trond Myklebust Cc: Schumaker Anna , List Linux Network Devel Mailing , List Linux NFS Mailing , List Linux Kernel Mailing Subject: Re: [PATCH 1/2] NFSv4.1: work around -Wmaybe-uninitialized warning Date: Wed, 31 Aug 2016 17:52:08 +0200 Message-ID: <4865077.USSZu2CAsg@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <20160831123911.3467676-1-arnd@arndb.de> <5024842.0SZmq2hZxe@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K0:QzOkIehaLoTWH4ucNKkcu7oaVYPrH8QV5w8rwgVe7/71pkg4smL ht9bS1K0k560as5PLPCucYfBW/LwJ5EioMbveMzdkMyiPqfMSSNPxtfjxOOv8APoN7QSoyA jsruHr3EKUFrBx+MMRr9sblRnYn4M07i5d4es1PO/Fq9Co14lZ7NTWUui2jqmC7WdtHvQ93 7YKgJ1/jJBPsU5jiLDaiA== X-UI-Out-Filterresults: notjunk:1;V01:K0:Iyuok098fkA=:0wH/zjv8Fg1q9v64TTxQ+r gFUpULdM4a/jkFTW4rnkQIeE4kFpnyiuv0c7ZrXFSIFsKWgDXro4SY9/9+JCgjNaFCURFG60s pF1II4zNNpjDnYDV/9d8oLA52m5DqPzeSATWeNd4qqb3g9b/+XxBxvjlXrZTzgLggAYQFOFK/ XwHOarabFltzFmAPN33d2BKRZfiyMGLPJGdgQcSGEnAzNoYMSbGyn7YW8ISfY7pUUvyZQT7JD qBxMyizSMJCBOVPC7Tm3bqL4FFZMeFJg5XclWVv9eQQY5+cWDApKKYW8x89axijOAbjaPqGjy TpacBVHlC1C7EVejl718t9pip0Uv47GtDJ+tTsaOdbA9WZJAExY7RT17uYsAJVjGzPUTjy3IE GMfa9TQxQMDjRD6AMYnYOUjAe0IZ8e+PEKeGcVp0kAug0OWCAcQKEJtzMIwKz6xfzk/DBMW7z vXwT74kCs02PY6RGAmGiN+SO83xleOD6Xlsr9usDPj6loqIUA+xnOjGQKxwHLd9eH8ZWyc8Ew GLEQaoIumWxhvwpEhnooNK+Ux692xFUu9yPsBAQo66FT+RT8sbXkAsm11GDQsBJzk9pNw5CQO qYVnum6G4OelhWfTISRORW4kOwq/7luYM+ZYX0BUd7MC1vSiuHup2G6opU8EnIvH/qng6T6gN l8hhh0GITm/p8Ry96H4/olnxZ9oQic7wYwRv+G/WVt1Jf9T8dnf2Wrfz0mi7V4MT8YaT54zeY hl6/ptwNdAGlAXyA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, August 31, 2016 3:02:42 PM CEST Trond Myklebust wrote: > > On Aug 31, 2016, at 09:37, Arnd Bergmann wrote: > > > > On Wednesday, August 31, 2016 1:17:48 PM CEST Trond Myklebust wrote: > >> What version of gcc are you using? I’m unable to reproduce with gcc 6.1.1.. > > > > This is also on 6.1.1 for ARM. Note that 6e8d666e9253 ("Disable > > "maybe-uninitialized" warning globally") turned off those warnings, so > > unless you explicitly pass -Wmaybe-uninitialized (e.g. by building with > > "make W=1"), you won't get it. > > > > I’m not getting that error on gcc 6.1.1 for x86_64 with either “make W=1” or “make W=2”. > “make W=3” does gives rise to one warning in nfs4_slot_get_seqid: Ok, I had not realized that the patch that Linus did disabled the warning for all levels, I'll try to come up a patch to bring it back at W=1 level. On my system, I had simply reverted the patch that turned off the warning, but I have now verified that I get it with "make EXTRA_CFLAGS=-Wmaybe-uninitialized" on an x86 defconfig with gcc-5 and gcc-6. > /home/trondmy/devel/kernel/linux/fs/nfs/nfs4session.c: In function ‘nfs4_slot_get_seqid’: > /home/trondmy/devel/kernel/linux/fs/nfs/nfs4session.c:184:10: warning: conversion to ‘int’ from ‘long int’ may alter its value [-Wconversion] > return PTR_ERR(slot); > ^~~~~~~~~~~~~ > > (which is another false positive) but that’s all... sure, W=3 is useless. > > The reason I'm still sending the patches for this warning is that > > we do get a number of valid ones (this was the only false positive > > out of the seven such warnings since last week). > > There is a Zen-like quality to IS_ERR() when it casts a const pointer to an unsigned long, back to a non-const pointer, and then back to an unsigned long before comparing it to another unsigned long cast constant negative integer. However, I’m not sure the C99 standard would agree that a positive test result implies we can assume that a simple cast of the same pointer to a signed long will result in a negative, non-zero valued errno. > > I suspect that if we really want to fix these false negatives, we should probably address that issue. I've looked into this before, as we've had a couple of these cases (I think less than 10 in the whole kernel, but they keep coming up every few releases), and I couldn't find a way to make IS_ERR more transparent. Using IS_ERR_OR_ZERO() seems like a good enough solution, and will probably result in slightly better code (I have not checked this specific case though), as we can also skip the second runtime check. Arnd