Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1389732lqp; Mon, 15 Apr 2024 05:22:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUU5UB1uago4F61ypDGAOIyTKdELS59XhtkLv3W80pKfF4chga46qgqxbaN5MmynJ8pxnQt+u5Xd9YsRpY1r7hbfTa5XCevLn2vDzOClw== X-Google-Smtp-Source: AGHT+IE2DHGejps0m/e8fxr9e38ECu+xpwA6EQOdslThq2c1Z4cvGyU25yTyB8udFBDsMRydjkMD X-Received: by 2002:a9d:68d8:0:b0:6eb:7d1a:1b87 with SMTP id i24-20020a9d68d8000000b006eb7d1a1b87mr3967748oto.20.1713183744401; Mon, 15 Apr 2024 05:22:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713183744; cv=pass; d=google.com; s=arc-20160816; b=bDOmRYifGXSJG5U2aN18h7QkNIy0kwr+w7fvJLe2iOqUPhNdr6sRCyCA1BDFcnCxa2 YrJIBNQPg/izwRWS6EWirtX1kwmBEtC4uwq8TGTYw0vTKFMEZUQHFV4RiJHqBOTVOych R9zwhq8jyGX6bPohobfGuUwFkVSGwgHd8gHxXzQ1iFoUK3r1aWJkfhgXDGiWLn1cOiJL MUwf2Lp0q2vtqqa+NaIQ9UViyL7vDGCryKSeWqyxjIm0Zr0IVvEOujOHa0eEiT14MX9U wKipqK5CVt5o6h4vkGv09haRpVntV1BoNf/M68ciK12HcVRwEE1+huRdtJT+iyQhYQrO TgoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=v98Cv78tYFIBnrKr/5wOGoFGclRvVI/9L01oEqjuzME=; fh=8mZP3M6PAgp/PjjZstGz5vfdgfC3/JFy0A6tayPaJ0U=; b=jpi4+m6HRyA/e9PbnBklpm9jfwpC7zysBfGfAhI/lriM+hS7TTgp+DZkgyzLBAniY8 fJZ9uhpVxUUiAMUDj8gVtBBw85DAxPhD7xYfhZquZsznQQw4siAJUABcHoajpB6mMJcE T7xb4QYmlrxZtpsex932p3LaroZ3WDFzCDV74toVvviHUJiuHPV/+tCBqrPXhua0yKxj 9LFPPIbsEIh0QBfcYf/rfa4h/08jm9FoJfUOH2SLM9Dd5ZE5OauJLMb7WTnGTb3UPgEu W4Gg+VLsUZFxzbQ94XzG/Q8rbXvhgFwgw+tK7JDJH8/Cx9uyxTML4qvyg0CqSnAzy7Zi zm2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qnlL7jUD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dt6-20020a05620a478600b0078edcb8ce38si4349506qkb.732.2024.04.15.05.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 05:22:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qnlL7jUD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 229471C20FAE for ; Mon, 15 Apr 2024 12:22:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3036D6EB65; Mon, 15 Apr 2024 12:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qnlL7jUD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EB296F515; Mon, 15 Apr 2024 12:20:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183655; cv=none; b=gPmTnVfqxWD5T0gDsYhHaYxlvnzfBtJ1pBV0rSSTAq1USwu4WLF9yu8focsFCHmTSDCcm3xUIn9uIb5UleEGjleVvCT7/guZSnhkS/n/UN2lplFcGlen9WE7HL4rJ5jdmY6VN31iicBE6JHbqIz3JaOeGk2+20nXkt7ga7ZIp9E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183655; c=relaxed/simple; bh=8JKhrJT3q63/BXO9ILtj2EX2ia1+UIIUhuNAvPawccM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ATsOLcE6uOUUdluzRk/lDUHjyxkFSQM0bY3Tq2Xc0a6crqrEvjcc8dWMSzyVFZZKXiKzPjjW0K2gC4rmrxbdvemMbbltvceOHaDANIlXMZT08lOl9Ri4K37wA9A4YagQWn4MQhp8gLzIpzMitc3r7I74nGM9w5Xfdtsef/WH0v4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qnlL7jUD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2C02C32783; Mon, 15 Apr 2024 12:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183654; bh=8JKhrJT3q63/BXO9ILtj2EX2ia1+UIIUhuNAvPawccM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnlL7jUDv7TTP2v4bEWYvzv+ygQxlEQxsAxojfWkiCbLzw0rr+JALMsJJ6C2XHw81 ku2Snmkl4o/iEbG+KibhPGJSLDQJaJmr1h5UusKYVoAPrBzup0Z54IVC40VBFgyiRg 8YcwiZaG5Yh9ya6CloB9jKCNZxuNL3oyzBMzBQDCk1dPi7REMFtgr7eOWtvqRZRC73 L9whn9FXY+oazENeODSNeyYMGgeYSK/oOCEPnxxmkTZmcD4KHMRT5DzO+naXkpCy53 c/wzLjuSSV+f8aga5cXQhtsOeQOEQRGngzChWdHc/J6HepFlhET/6OTph2+BugApGs gMyH+QcwWWx4A== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] [v3] kbuild: enable -Wformat-truncation on clang Date: Mon, 15 Apr 2024 14:20:35 +0200 Message-Id: <20240415122037.1983124-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann This warning option still produces output on gcc but is now clean when building with clang, so enable it conditionally on the compiler for now. As far as I can tell, the remaining warnings with gcc are the result of analysing the code more deeply across inlining, while clang only does this within a function. Link: https://lore.kernel.org/lkml/20240326230511.GA2796782@dev-arch.thelio-3990X/ Link: https://lore.kernel.org/linux-patches/20231002-disable-wformat-truncation-overflow-non-kprintf-v1-1-35179205c8d9@kernel.org/ Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 95466a04d51b..202e26e6f29f 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -100,7 +100,14 @@ KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +else +# Clang checks for overflow/truncation with '%p', while GCC does not: +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219 +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf) +endif KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang -- 2.39.2