From patchwork Wed May 29 12:44: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: 13678794 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 AF208142E68 for ; Wed, 29 May 2024 12:44:39 +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=1716986681; cv=none; b=UNfl23KKdqIqBRdGPtBItJYKlrVcldk3xJ34CNQvgTgZWnA4kQ5IyqHqzvTwba95gb8IcD2VPwg4X0PAvoldheN02PgensuDgBP9xbFkGmMWXUVsgqKMt6kvuneJTqMTsbny/HsJJZp5BD3v0phWc3jAi6d0Yr/mD2G0JzCL2bE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986681; c=relaxed/simple; bh=wk9CV1AL5ubqpuhU6yIHqAK/CcLGDjIqHfYXRN6e7js=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SZjjd0zX51h08wqQdmGHOmUG7x7KRmvRVyUqg1mPvrbsnN/Iqvdm5wbR/8di4+gQaLFQ2hFztv6KaTvlhXloDhC6aJpHt2ZFZYKGb9G1SjFCnTaAPn44wUAoLVM94ZCWJf7UpeX4NVJbfa1YjgZsXFBQK44FO0imuSIt7PTuQrI= 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=c6HY8PRn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nm8z9f+K; 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="c6HY8PRn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nm8z9f+K" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id DD94A1C00122; Wed, 29 May 2024 08:44:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 29 May 2024 08:44: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=1716986678; x=1717073078; bh=hd/KBKn6AZ sB4vi2dTE0ZrSeMfGutRFzAZsjfvDfM78=; b=c6HY8PRn1m26fcxYqu2JJdHgn8 QPAASod8r0tmXQV3KMt4ivCe/NNNSze+F2t48o0xr6yH7jwRTBzWUV86zRUE1sA7 I5kzYUJEH3MOmYSAtv8sS0pGDepO1sL8EmRp6Mx23LZ0UQBnzyATRR5J1Le7Xp6F DRPHGAXadjvrTy9JnPAoTTtRTbr2fzzfuV19qnBsG7+MHr6XfJQEi5FIUh2Nin// RAYYP377W8/pxT5AyYkvezw18OJAyG9ot1nuShSs/lfB2EfyOLt0Az1HbwLzVTYo fihd1otG7Qk7sqp8Zlhei6+EeSUwYShxgID4c1nXfKDEv77P6fJGck/E5VXQ== 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=1716986678; x=1717073078; bh=hd/KBKn6AZsB4vi2dTE0ZrSeMfGu tRFzAZsjfvDfM78=; b=nm8z9f+KE8MehYEqrXy/uE7zZFtsrTISEqrPLqvvLWUU uxZMXHTs7ac0/H4uydn6mqFzEoKN5BbL5uCTxihniKMXxJ9SqAXEUPiCUbE7dTDi iL7WKpyZOgNaW3CArMtT/+GUvk5yYidT0luzl79cnhf58E0fO6bI08mMdhqZg4Pu YHSiHPU7JJ6j5OoHUr5uiaT7iRqxX8WwiB9OtQ4VVduzzeysCNPJfWuWn8xpMBhl fl4ptdByMgrdalGj1tAqvreA5EXRK/ffx+xGmYfW9SoRCXFKwLuycD6Ulofbhq8z RjOesWybBE6ADy0rw9XGvsl6ykUPLhtvqh7QTl0/hA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekuddgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedunecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 May 2024 08:44:37 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id c4089cc4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 29 May 2024 12:44:23 +0000 (UTC) Date: Wed, 29 May 2024 14:44:35 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King Subject: [PATCH 07/19] http: do not assign string constant to non-const field Message-ID: <03b13c449b52ecfc845e8ffb0dd69fe67d50651c.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: In `write_accept_language()`, we put all acceptable languages into an array. While all entries in that array are allocated strings, the final entry in that array is a string constant. This is fine because we explicitly skip over the last entry when freeing the array, but will cause warnings once we enable `-Wwrite-strings`. Adapt the code to also allocate the final entry. Signed-off-by: Patrick Steinhardt --- http.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/http.c b/http.c index 67cc47d28f..2dea2d03da 100644 --- a/http.c +++ b/http.c @@ -1974,7 +1974,7 @@ static void write_accept_language(struct strbuf *buf) /* add '*' */ REALLOC_ARRAY(language_tags, num_langs + 1); - language_tags[num_langs++] = "*"; /* it's OK; this won't be freed */ + language_tags[num_langs++] = xstrdup("*"); /* compute decimal_places */ for (max_q = 1, decimal_places = 0; @@ -2004,8 +2004,7 @@ static void write_accept_language(struct strbuf *buf) } } - /* free language tags -- last one is a static '*' */ - for (i = 0; i < num_langs - 1; i++) + for (i = 0; i < num_langs; i++) free(language_tags[i]); free(language_tags); }