Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp1571384pjr; Mon, 18 May 2020 16:43:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZly9ASSODYlP3l/Mjo3epWl4t18amYOKTtI2nmlPgUFaSrN7VQf6R5lWNUACM5Vvoq4Uv X-Received: by 2002:a17:906:f75b:: with SMTP id jp27mr17306166ejb.141.1589845397145; Mon, 18 May 2020 16:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589845397; cv=none; d=google.com; s=arc-20160816; b=A701wx5GDpbF67KaKw1kM4Xa+3VFa68rFqOevxSVXylmUeeiTPU0JKEWUV6xSQRyVe jeCKPZxxULM7E0hr20JrJrafc1SV5Fic7zjhNBoiuegfUW58fJSvWAEgkxwpzOL1tbfH /8VCCcdS+ZN04fA+IN6jKGm5GjK9EcVil+um3mwnEd6lS6SU8rVFF27bwq2KgRoSYTrp +5OROJdyhs0traAHCRFXEwiev4TjE9NO3ClimA4AOUKmtXBK0DeebDCDN8ey6x847DfP yvBdOXCxcsxdPs4HQvxLyG2F03WdqBoH6FvBGKWoV8iB7NpDUHSDz2w4pP8tcUzZrVPj jGTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nu0Js8JOCYLKsvmu9K6yo8Ru9gIRCJi4mBS/843Zu1Q=; b=tjimOHUhwNewkkQriJ5rLeXVRdMmwCJvcM9SRSd3dmC6MHP6lAU7wiqXRM9virMosY tz9ocCO/PFLVT4hLiJ8bJjCy1JO/1A3C9wDzsq16mSmTyc+W5Q0bTfxaDZS6B9Qf1hDm kEu73d0U4UOWMzTWXk+L68PM8vJfaaGU521FJb3URv41MThpfda/Bew+dRaj5whspn0M 8LsVOTewLS6JHmkLZ6My9Ci4aCQpg6JUfyTsQHFB0iD4ozZwBEDXRdK5mOLFGKJriROj CKcuWeY/j46QT8iPzrV26uCsrl4VTBau2kSQ+x38/+JoxQNT6BClxzLsVFHjVOzBpHH1 KzBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uWFwuKQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si7435499ejh.346.2020.05.18.16.42.54; Mon, 18 May 2020 16:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uWFwuKQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729968AbgERRpf (ORCPT + 99 others); Mon, 18 May 2020 13:45:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:44284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729926AbgERRp2 (ORCPT ); Mon, 18 May 2020 13:45:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2D8EC20674; Mon, 18 May 2020 17:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823927; bh=fSRau1pAiWHNJbmlUH/uhaszxFG174FpSD9tnHCsz6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWFwuKQTfTGhSuTDM4cJLNl4DkviQDsovAnMBu7gA/WMYVTmT67FaXyFmz9GeFh1W Po0/mgCs7H509nJ/ruVL+TfS2h+iJvuKYhhxGI1SDDnao0Sly04CxeMzmuo63FYCYy 8B6lYQ9pS1vKVed19N0D56NEtMs83VU1kokpMYo0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds Subject: [PATCH 4.9 67/90] gcc-10: disable restrict warning for now Date: Mon, 18 May 2020 19:36:45 +0200 Message-Id: <20200518173504.854092505@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.930655662@linuxfoundation.org> References: <20200518173450.930655662@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Torvalds commit adc71920969870dfa54e8f40dac8616284832d02 upstream. gcc-10 now warns about passing aliasing pointers to functions that take restricted pointers. That's actually a great warning, and if we ever start using 'restrict' in the kernel, it might be quite useful. But right now we don't, and it turns out that the only thing this warns about is an idiom where we have declared a few functions to be "printf-like" (which seems to make gcc pick up the restricted pointer thing), and then we print to the same buffer that we also use as an input. And people do that as an odd concatenation pattern, with code like this: #define sysfs_show_gen_prop(buffer, fmt, ...) \ snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__) where we have 'buffer' as both the destination of the final result, and as the initial argument. Yes, it's a bit questionable. And outside of the kernel, people do have standard declarations like int snprintf( char *restrict buffer, size_t bufsz, const char *restrict format, ... ); where that output buffer is marked as a restrict pointer that cannot alias with any other arguments. But in the context of the kernel, that 'use snprintf() to concatenate to the end result' does work, and the pattern shows up in multiple places. And we have not marked our own version of snprintf() as taking restrict pointers, so the warning is incorrect for now, and gcc picks it up on its own. If we do start using 'restrict' in the kernel (and it might be a good idea if people find places where it matters), we'll need to figure out how to avoid this issue for snprintf and friends. But in the meantime, this warning is not useful. Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- Makefile | 3 +++ 1 file changed, 3 insertions(+) --- a/Makefile +++ b/Makefile @@ -802,6 +802,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) +# Another good warning that we'll want to enable eventually +KBUILD_CFLAGS += $(call cc-disable-warning, restrict) + # Enabled with W=2, disabled by default as noisy KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)