From patchwork Thu May 30 12:52:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13680376 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (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 66AB6132129 for ; Thu, 30 May 2024 12:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073528; cv=none; b=DKPa2/rekRnf2x2fnPbRuzEM6xkZetG6kIjV6K+q+vxSD15T0QPQ3SHo/jXLFzJMQYWvjji7j0+3nrhgiw+ARaz7kLojiutgoFRdaUVmCuvfgKlBGwp7phc5xkEY5VQ03rwK+I9knLbZLBf06dl2iD5SSC3CkHh9CKAhTfbW/F4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073528; c=relaxed/simple; bh=qYCJYV+8zxZwI+GnMsqoX2sXB8KbhRcrhoxS3gBDPpw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Dv0IGOb/oppS+7SW4daerD70THJPelht42eiXAtryNHH2u1yxbKGylJC+W4Kz3Xwuuv2WdvoHNVXSiP0h/PZYOsAQIVk2KyOgpOwXD6jUhhoXM2KOo/Jc98nSOskIB7VJjPNIFlU22kq++y92PG2uRGvtBDgTT/ZqO6bJkyvsnI= 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=AyPg69f3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YnMEleBs; arc=none smtp.client-ip=103.168.172.149 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="AyPg69f3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YnMEleBs" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 8972B13800DE; Thu, 30 May 2024 08:52:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 30 May 2024 08:52:06 -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=1717073526; x=1717159926; bh=qYCJYV+8zx ZwI+GnMsqoX2sXB8KbhRcrhoxS3gBDPpw=; b=AyPg69f3oKiDaD/Ida/vCT4juU T72EeDVI4CaEj1GtVupsbtTTwszuB4L8sXV5RH2vTobZLe377dkktaxKpzjCLnrO bbpqEVVVo3nGKzC0ucY2dVvo0IWHFsmSekbQomcX3Tt9Fk1AxRJu9LFa0BHxSFQT 1rTAmBUBvVwNCHPACyeAGZxtVSqnsL8QIo9p8MqtsqV9y4qbLkLvth+7u8b4Yhai D+gHist9YtjrnsmNVJiqTIasFXZZEm+V9R8hrBo208/rL7uk7xZUUF4WfOgw7W9F FPZqEooFtAetZY9du7NxsWCuGcNQrm9WhmSe7YktMr2A8x7n6+okkJechERA== 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=1717073526; x=1717159926; bh=qYCJYV+8zxZwI+GnMsqoX2sXB8Kb hRcrhoxS3gBDPpw=; b=YnMEleBsj8OWFGdjx+J2RZMjTsrPJhErqRK8VIfjGmuc A2+xQE2Fqygl+3xnp2btai1zylRW9e7wVM4h0SMK5Y0OVs0fe5GP+fIXUi894r2m owUeZs6qWkNyn+L6Uqrwki+HxK9mBoEatRQDFqwr3zW4CFobbz9iXEIW4k0pBT3z Gx8/Wv7FEvS3u5aU3ICXQjvnW2is9Nc59apVyo9l7hSSLfMt9mSX7nW9Qf9FPs6Z fDr+dqE+gIg34ll8uuVnjMvHTNiVfTHfsJpqHGcZocFvw5VBNpjGKx5kv/KJsgtT wZE6lLhrU5v/U6bhSaCNvVLf58CaZMPINuRk+QbGpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekgedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpedtkeefgeeiiedugfdvgeeffffgtdehge efieetffekleetgeffvdfhveejudejtdenucffohhmrghinhepmhgrkhdruggvvhenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 May 2024 08:52:05 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id df18a44c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 30 May 2024 12:51:49 +0000 (UTC) Date: Thu, 30 May 2024 14:52:03 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v2 19/19] config.mak.dev: enable `-Wwrite-strings` warning Message-ID: <9b9d57ae8432bc0f638bc784b23526d5a26627a5.1717073347.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)),)