From patchwork Wed May 29 12:45:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13678806 Received: from wfhigh6-smtp.messagingengine.com (wfhigh6-smtp.messagingengine.com [64.147.123.157]) (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 A77ED12E5B for ; Wed, 29 May 2024 12:45:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986741; cv=none; b=AcP+EhcS9RUmaID7bp9cyDrcCS1xFa4hT33IASWvu02PGZeP4fmkBUMpc+LiouOCqD/9nvU5d/VP7LoeLHGvMoXdnSucV4Savyx+XCfz1ceyB1CHmT61DbubtFxMUniD0fasPRPL2qFFerXUGhi+hiuH0sCPvt96XLOyJ/7gbdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986741; c=relaxed/simple; bh=gXbJs77wQdZ5la+RCoUDgSdpfGztRSu4HTdgw5H0Ops=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=awtRiO53ZCiX36cLqLvi85dZ0m67gnFpJoPEoX1Dde9WCFnhDSKs2sYrCd70Gh84VSo5/N9zko6Gux7xgbuvgh4wDpA464fLE4DNAp7v9MZIBLcykTTRkpCEPKGeaXhQ6C+7N6iGE0q1qewG8MDx69Tl5an1G7eVjD2TYhkAxYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=RetuSXQf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=a+kcBbze; arc=none smtp.client-ip=64.147.123.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="RetuSXQf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="a+kcBbze" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 007AC180011B; Wed, 29 May 2024 08:45:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 29 May 2024 08:45:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1716986738; x=1717073138; bh=gXbJs77wQd Z5la+RCoUDgSdpfGztRSu4HTdgw5H0Ops=; b=RetuSXQfwwIGsOhtZOD9107Gba N03Z0jMfG1ZPK/UyCrmuTH74GKZ9o5H/5l+pA5inwVfla1ydRHBR7oMxsjYvYx6Z 9NBx0/Kmoz3bZ4A1G87hGYN+Kpxzu1nKD6QR74cK6YETpyUOH7VLo3IZP3lJ4keV e4jb73uvbvat8/VqMIk9YHq18N7dDtD9bADSAmYfqOLl0BAxnejQVwJmKJuShCoe WCF67z8jr9gKtmg1jxh0ZFDdi3VzfR4lvkyniFCDHTRFHQnekHBBnMVsY8HJLc26 TsvzUdI599gPb6ot6rT82E/yI3+ZGLBI9r11oZV1lrdYY+wcXC1nTbmfVZ+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1716986738; x=1717073138; bh=gXbJs77wQdZ5la+RCoUDgSdpfGzt RSu4HTdgw5H0Ops=; b=a+kcBbzeuUyQRalln68lu+hkPdJpv21pCODSuc6dbhKS 0jvGTCY7PBOGoDphPhG4GnLg8cN003xgs2d1nOP5VGKlv1BbT8NI2Rzh6SzHejv7 avb+J7uc1rzeEO4uYe66tL1iFscVSaSVvvbSQ/B+ONoqktDOOQTLV+LGtdK2y5e0 8r/AoU/97XqCBO9LgRDqmysZx3vOY260N6bsIAZX0nSNobO8Zbrvgk88tcWNabdo u0e6bZ8sC6RPIBavhKaDX6sypO0uT9czigOvrpe2f+4oHXt/WfjWNX8+j1EKv/k2 LtnSf/h49LVcEVALBeHLhoMwegDp4ej+XyYldo/+Uw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekuddgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpedtkeefgeeiiedugfdvgeeffffgtdehge efieetffekleetgeffvdfhveejudejtdenucffohhmrghinhepmhgrkhdruggvvhenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 May 2024 08:45:37 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id fff5cd66 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 29 May 2024 12:45:23 +0000 (UTC) Date: Wed, 29 May 2024 14:45:35 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King Subject: [PATCH 19/19] config.mak.dev: enable `-Wwrite-strings` warning Message-ID: <37e7aaed97df0b902631e76ba82ee7c6473293ad.1716983704.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Writing to string constants is undefined behaviour and must be avoided in C. Even so, the compiler does not help us with this by default because those constants are not in fact marked as `const`. This makes it rather easy to accidentally assign a constant to a non-const variable or field and then later on try to either free it or write to it. Enable `-Wwrite-strings` to catch such mistakes. With this warning enabled, the type of string constants is changed to `const char[]` and will thus cause compiler warnings when being assigned to non-const fields and variables. Signed-off-by: Patrick Steinhardt --- config.mak.dev | 1 + 1 file changed, 1 insertion(+) diff --git a/config.mak.dev b/config.mak.dev index 981304727c..1ce4c70613 100644 --- a/config.mak.dev +++ b/config.mak.dev @@ -37,6 +37,7 @@ DEVELOPER_CFLAGS += -Wpointer-arith DEVELOPER_CFLAGS += -Wstrict-prototypes DEVELOPER_CFLAGS += -Wunused DEVELOPER_CFLAGS += -Wvla +DEVELOPER_CFLAGS += -Wwrite-strings DEVELOPER_CFLAGS += -fno-common ifneq ($(filter clang4,$(COMPILER_FEATURES)),)