From patchwork Mon Jun 3 09:41:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13683496 Received: from wfout4-smtp.messagingengine.com (wfout4-smtp.messagingengine.com [64.147.123.147]) (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 E5B6585656 for ; Mon, 3 Jun 2024 09:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407674; cv=none; b=pXcgLvlxEv7ZQLT7kAyh7s9E7PCid5vSQIZ6YgXMQufE9e2CS+nskoKMGWhrxh4l/G13nuMmrtseqOH3pinfjcOss1Fu5lTEg2z7nTbuhp+jB1CxXOu4JSnZy3Eawj1g+PWEgSCNiP+QfMWhH3NmWR9qCbV+b2TsLllFTwqlm/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407674; c=relaxed/simple; bh=oM8UMIGhh70nbcMJkwU/VQ2LlmQ9LJicyVF7ByQ7Z4A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S05Pnl0hJHIuuwXSOC0otEqTH0Kog7csbLr/nS3vw1IIeK1SZ92I8UCws/4+u6aPn9Xa0VIDfFFlM6X2DrpKh4eMIQnhD2zGGwgVcDnKu6AHdxQ0BmdXBjOYlYfAIzuU/li0JEXOedqYv27UPNFJFar5R68FRaLtvoFzF9Mn1qE= 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=ecg4oKY/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=LNkIBHrU; arc=none smtp.client-ip=64.147.123.147 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="ecg4oKY/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LNkIBHrU" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.west.internal (Postfix) with ESMTP id 330291C0009D; Mon, 3 Jun 2024 05:41:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 03 Jun 2024 05:41:12 -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=1717407671; x=1717494071; bh=oM8UMIGhh7 0nbcMJkwU/VQ2LlmQ9LJicyVF7ByQ7Z4A=; b=ecg4oKY/6S+2TfP9++QDx3B0LN 20Pu8ZaxmajyEOM8HHiMiG3AOwgzfDqGfkL9IHTGZnvgq7H2QIMAdXcMep1NLYzO G4W69Q+yie2ISrNFJLN4Fgq/BTqvs2rZDuiWK4DZ2iAHmUnR21Zg5e+gl8SjoWBT tRjoe7xcMJiWtjr1DLgBUc0lFiexP2GGGMS8ujvd1aqRQWNQ/7qXtgqawm+efxZ1 YzbJum8kcf0V1OahqLvZU/TQ/Yhy1xoXw0tNh+VX1Y058GeOkfDzucwuuL/otIYI JWW+eNg/kecLsLxbkG6BRNsVyyLPJPEacGNo1wigP1YbZPkt/ukH5/lTyjGw== 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=1717407671; x=1717494071; bh=oM8UMIGhh70nbcMJkwU/VQ2LlmQ9 LJicyVF7ByQ7Z4A=; b=LNkIBHrUKW5+yZWhsXtG1/UgLuzVhpQzNb0XGp2E4kmS loCzMgHgKMQ7K2NxTvqfNNZD8VhEZUA7xWkuua8yEPfWBpqhPfP78Snka/SNcWSY 4dLlDRakSkgrfGQycKUuItRWo/7nRgmPXDubBkqGekZI4+Z/eKnJPT9fHlcUpxIO IXwqvSeNOC2gISnruMi3+G2RQFDt9fvQqA3c5ISGw3CNN7lmqTwYshuxD4NagXPD UoaRWRdN3LovI/3u14gtaM28ttEnRNSUB9arBbOfgJEUSKr0t7bu+vCDQ2TmZ17A rwAuPqzs3F3Mx293+e1mggC8OfpPcKhjFOK398q+pQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpedtkeefgeeiiedugfdvgeeffffgtdehge efieetffekleetgeffvdfhveejudejtdenucffohhmrghinhepmhgrkhdruggvvhenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jun 2024 05:41:10 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id efb4d162 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Jun 2024 09:40:46 +0000 (UTC) Date: Mon, 3 Jun 2024 11:41:08 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v3 27/27] config.mak.dev: enable `-Wwrite-strings` warning Message-ID: <342754713476cd680b31420681fb1da624c91675.1717402403.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)),)