From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753636AbcJDItQ (ORCPT ); Tue, 4 Oct 2016 04:49:16 -0400 Received: from s3.sipsolutions.net ([5.9.151.49]:40592 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752029AbcJDItP (ORCPT ); Tue, 4 Oct 2016 04:49:15 -0400 Message-ID: <1475570946.5324.37.camel@sipsolutions.net> Subject: Re: [PATCH] x86: suppress sparse warning in copy_to_user() From: Johannes Berg To: Jan Beulich Cc: Ingo Molnar , x86@kernel.org, Thomas Gleixner , linux-kernel@vger.kernel.org, "H. Peter Anvin" Date: Tue, 04 Oct 2016 10:49:06 +0200 In-Reply-To: <57F385DC0200007800114C92@prv-mh.provo.novell.com> References: <1475566428-22484-1-git-send-email-johannes@sipsolutions.net> <57F37B8A0200007800114C45@prv-mh.provo.novell.com> <1475568162.5324.10.camel@sipsolutions.net> <57F385DC0200007800114C92@prv-mh.provo.novell.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > If that was the case, everyone should have seen such warnings > > > from the day the original patch got introduced.  > > > > Only if they run sparse. Clearly people don't, or we wouldn't have > > a history of a ton of such problems, e.g. > > No - you say "which gcc declares with (void *, int type) prototype". > If that was the case, there would need to be a warning. There would need to be a warning when? > > > And the compiler warnings > > > I get when testing with all four combinations of const and > > > volatile > > > also supports this by saying "expected 'const void *' but ..."  > > > > It's not a compiler warning though that I'm getting. > > > > What tool are you using to get such a warning? > > I'm talking about gcc and the warning surfacing when I additonally > add volatile. Oh, sorry. If you get the warning, it prints "expected 'const void *'" ... yeah, I see. > > https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html  > > Perhaps it's just the documentation which is imprecise here? Hmm, yeah, that could be right, or maybe it changed at some point? If it were defined the way the documentation says, you should have gotten a compiler warning ("passing argument 1 ... discards ‘const’ qualifier from pointer target type") with the code as it is (without my patch), since you can't pass a const pointer to a function that expects a non-const pointer. Clearly that didn't happen. That does indicate that the prototype is indeed with the const, I guess I'll go fix sparse instead. Sorry I misread your earlier explanation entirely! johannes