From patchwork Thu Jun 6 10:29:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13688251 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (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 0E9F3194C61 for ; Thu, 6 Jun 2024 10:29:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669746; cv=none; b=N15WsSwFovtJAWJtm02fTT8emsLRaOkZx7QqPJJnBtpMSGpeoK2i081Qcqz7EheZBMKJLBRW2zFE5hA6Rfe4ExYtdI7t+jAzoW937rHQ7hqQ1CP8yRuQ9pkNFn3iyUD5EJXxihMAB18fIfeArOJXg3EUfJszN+n8VIDxBUJ0HTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669746; c=relaxed/simple; bh=L4btAryBejP0zLSEGgr6813/ApF6OPr4Y6NkJFtCDuw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s0K2+rh55qQARkm9YWSgpaw8F2ZugGie2iyEnIUcUQEboxaXElyZufM5uG4IXrpOnE5QlytnpddxvCllhDNO8dROFrADI96QmTPoD1eKp3b7pXOFRVs4bU78SaFr8363g34l4mTKSOoaekMadF9R5HEEhcIhEXs3ll1+/VrA7pA= 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=H8rAHPtV; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NNIIudUi; arc=none smtp.client-ip=103.168.172.148 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="H8rAHPtV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NNIIudUi" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 5FA8A138014F; Thu, 6 Jun 2024 06:29:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 06 Jun 2024 06:29:04 -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=1717669744; x=1717756144; bh=8vAiFMGiLU RpqVLjMTEwDChCmXuSTjAnObdrhLgPFYk=; b=H8rAHPtVulHSeTYDsrbwvEb4wY fucoDzvW4QB0wv0jNU6gEuCRl4JWZNB24GQivngyc7GT3HAk3a+kHcS+v7PiZQyg pp/R+xp6js7b1IFYACVXtx90uvw9iMEdJ568AQ2g/Fo49HmHFiuxLFYenFqWjYfe DZYc8TlGTr/R9DTW9rEZ8KmluVwBfejckgdjyPMiXQL008QOLt8XZesiQyAeYDNq uFxAwWXo4fCf7iLxZB5JdWOatplFxIHCHQscJQEs73AhxCzx2tWHZ2Lz5PzI6MHh jpNjCZbKadd2jp0idSqmDRTvZGBPctuG9hkdZwqQpxwd7ikV/IEn2Ktg1E4g== 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=1717669744; x=1717756144; bh=8vAiFMGiLURpqVLjMTEwDChCmXuS TjAnObdrhLgPFYk=; b=NNIIudUiaUVBdXbUo1HRJoWoW+eHmIuGPt1m1c1/2+il Mc9zcdDLyWPxFm5dyNDxYf+T+xKWOzvMOQQyxKzV05vewMpv0NhvcMKRRbKzE3Qr j1AZdo+o7aIyJJQT82vRsyX0iyDrKOEgmjE2qKjCN05OptUwUCiNiz0WH5VITA4b xjmtEH0YHL1zALLWdPrXux/PkAuGU2rBiF7PZNF6ObkFbf2go/e2/y7ZiFnqXirg gAC36RWdtkzpykhzOLiSVPe2aHh4lEgZMkqoQESI0oyrjKAw4UlxUsqkr9h4/Rg7 l8mrG2pmzvFhjPFh2RNGqjSg1CrMEqz0dqaOA1pP5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelkedgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Jun 2024 06:29:03 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 269d0c13 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 6 Jun 2024 10:28:32 +0000 (UTC) Date: Thu, 6 Jun 2024 12:29:00 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Eric Sunshine Subject: [PATCH v5 16/27] http: do not assign string constant to non-const field Message-ID: 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); }