From patchwork Tue Jun 4 12:37:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13685177 Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (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 EE69D146580 for ; Tue, 4 Jun 2024 12:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717504668; cv=none; b=TvDXWtmeQeGrv8DjbhBEowP5FJPW5D6hkSFg8+bfQMFD97o2N+MbTW0n6GDuqukQqZTkCv3GCMHofuHEc6RdcvDct8cY1HUa8xI8kX7rgjHLaUvNbQXp8k4lkQ0bNn+eFV4c5CllFNMM55uFNOedJn9fWT2IjUp6Y5H+72yFNzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717504668; c=relaxed/simple; bh=F9MdeYxHJSbuHVws3CJbA9Op6bTfHt5gij+QvqK6mxU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=txB2Q0pLjngaofJB3bAM27LiuFJbGWzNLBC2ifhoBSJvk8lPntDOk5O3DdzkTuasfmIQGTTxmQ4dcF19tFImVLhVAH9XLt6miJCIWA9OT5IYvaWhj9wGwIA1GkQAnz1msD8DO2PASuCxD+oCELjM4EBwThxRhcctF1Ie5fwWFwk= 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=XUYz1e0n; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FtWw2v+0; arc=none smtp.client-ip=103.168.172.158 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="XUYz1e0n"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FtWw2v+0" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 4971111400DB; Tue, 4 Jun 2024 08:37:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 04 Jun 2024 08:37:46 -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=1717504666; x=1717591066; bh=U4AnBVFym7 0QabwAv69jqBNsnQur21/Cpg0OVRqs4Mk=; b=XUYz1e0nkLTkqkLTtHJ+i5xEBW Fuj247gtQ/C8msFkNsglQLc3lgjPBJZyZzvazALZLWXn4rmSkuIhBBx9R1WYQCjg XJ6bDcKeACTsR9p8vt9DgDMQmg+Ppiv7Qw5epM3cE5qhcT3VGb0I+/jQdFgndg1l rhECgR7ussp7c2f9Tvjw21C4c2SkgKVsPIu+lzwtrjsdrWTH5ruvZGpuF079JvsH My17H1JtxGc2X8K6/4cH+8ndD3N/1dTlw9ckvHMo97U9/5lVfXkpQ/t8rZWoQBNI pP9LW9ffapNrCegkgM1gmUdD8Vo6DWXbMHjEZXhkCoddC/lwRe8z8z4laJow== 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=1717504666; x=1717591066; bh=U4AnBVFym70QabwAv69jqBNsnQur 21/Cpg0OVRqs4Mk=; b=FtWw2v+0O4kG8Pg7edgVBUSgyPC90JT/3Rbt2goYmIxu iKyxFBQQWk5zdpDYMCcEaMn8wzGuY9nSSnM9O1Gnbxp6FB3Rmw0al0dbYF2yx0vS 3wbec2HEMVy9XPS4pgIv4BKtHP1rGEJu4ZvQ93Q/+x04jH+REPX1dtp5dL5gGvNW xQK7eBY2u5vm5TgH4Cn7AzqKrwe1O0RgUMGKbHiUkOxtvvEUWwts0WtPQHb4AaWs 4JSbtTYhfeOoUFpMAV/XGge0Mg6b3cSONLPz0tkutJw2P9m6FiTn2YbDAyiPSwHJ b6sp4dQKGMvd5jiBDlwiHOl5Zb4+QQMr/0lEKImiug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelgedghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jun 2024 08:37:45 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 24007acf (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 4 Jun 2024 12:37:18 +0000 (UTC) Date: Tue, 4 Jun 2024 14:37:42 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Eric Sunshine Subject: [PATCH v4 11/27] ident: add casts for fallback name and GECOS Message-ID: <030dbd0288170eb1cc8fa0186f3b5e022ff67c40.1717504517.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 `xgetpwuid_self()`, we return a fallback identity when it was not possible to look up the current identity. This fallback identity needs to be internal and must never be written to by the calles as specified by getpwuid(3P). As both the `pw_name` and `pw_gecos` fields are marked as non-constant though, it will cause a warning to assign constant strings to them once compiling with `-Wwrite-strings`. Add explicit casts to avoid the warning. Signed-off-by: Patrick Steinhardt --- ident.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ident.c b/ident.c index cc7afdbf81..caf41fb2a9 100644 --- a/ident.c +++ b/ident.c @@ -46,9 +46,9 @@ static struct passwd *xgetpwuid_self(int *is_bogus) pw = getpwuid(getuid()); if (!pw) { static struct passwd fallback; - fallback.pw_name = "unknown"; + fallback.pw_name = (char *) "unknown"; #ifndef NO_GECOS_IN_PWENT - fallback.pw_gecos = "Unknown"; + fallback.pw_gecos = (char *) "Unknown"; #endif pw = &fallback; if (is_bogus)