From patchwork Sat Feb 24 21:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13570664 Received: from mout.web.de (mout.web.de [212.227.17.11]) (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 23DAE46B5 for ; Sat, 24 Feb 2024 21:47:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708811231; cv=none; b=K9Vzb5LKfIRxYKd7dbc5YdGDqI3Gb8Ke83VajzVjI4RlwDXVQQ4qGYWMlvH4hpmREF7O5SdD6KYHPyHi7AwGJqYfplBRBvBBtEtcHOuoNh/PROZxwgszBN4ma7QWx9Mm36YkaUtnSNN82oPJvtyKu5NCrC/rD9ENpZaMlHvd2gU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708811231; c=relaxed/simple; bh=ot1vCTZ2jXvM7H8NeJQZi33HQ3VhA4309Aop4bZrnAk=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=Re8unOYXygH6O7kiAesOlkQmDV8mPKN2DrNjr/Tzu+FNDJt+Zgm7CeQptgZnZpBekOhmW1b981p6Fv/nabt1a+6nFwpk8bHkld1g9I5IO0AdtcFgSblNSkj9PbHwOSbp51QCDM4zU+uvi8jXCeih9eshU5f7hHogEhagYw4wWGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=l.s.r@web.de header.b=FT+pgDMF; arc=none smtp.client-ip=212.227.17.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=l.s.r@web.de header.b="FT+pgDMF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1708811227; x=1709416027; i=l.s.r@web.de; bh=ot1vCTZ2jXvM7H8NeJQZi33HQ3VhA4309Aop4bZrnAk=; h=X-UI-Sender-Class:Date:To:From:Subject; b=FT+pgDMFInLvQp4/PeSGusVxY9IR5rLZIHmmt66XLtS03ccF/XQz/FWhNLsCwSkj CKQ3lccZHssMKWFs58YKnKM4XE7e/zVFEJBbkBBbY6/N4FhZeKgowvHqfU5oFFqUo 4C/4HM/ZNDoVpEC7aTyB5CSA65H4dqPiABhdvYW7BA300vK2cnz0BM9UhZ2QyGS2S D8H6rfea7un0/jZvBDD7rhK7CSrOBz1XqwQXpu9uBrV5zI3kLAkjddr4nctkTAGwp dIpRiBWwFXnju3lelUh1JbUhySF3j7iVMwa/0CMx5ttoTKWDDAqgHR6rz61EIfmxn HdM48/rZMydxMPlZGA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.19.211]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MsJSy-1qkWaf092g-00tqk2 for ; Sat, 24 Feb 2024 22:47:07 +0100 Message-ID: Date: Sat, 24 Feb 2024 22:47:06 +0100 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Git List From: =?utf-8?q?Ren=C3=A9_Scharfe?= Subject: [PATCH] fetch: convert strncmp() with strlen() to starts_with() X-Provags-ID: V03:K1:PZk1tCzQeOeMr65K0zOVHhiDfcfqeW2WB10UuSmPCPLmV2s4kZT Them8EB8FM/4I0hVcoLakJ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s= Using strncmp() and strlen() to check whether a string starts with another one requires repeating the prefix candidate. Use starts_with() instead, which reduces repetition and is more readable. Signed-off-by: René Scharfe --- builtin/fetch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.44.0 diff --git a/builtin/fetch.c b/builtin/fetch.c index 3aedfd1bb6..0a7a1a3476 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -448,9 +448,8 @@ static void filter_prefetch_refspec(struct refspec *rs) continue; if (!rs->items[i].dst || (rs->items[i].src && - !strncmp(rs->items[i].src, - ref_namespace[NAMESPACE_TAGS].ref, - strlen(ref_namespace[NAMESPACE_TAGS].ref)))) { + starts_with(rs->items[i].src, + ref_namespace[NAMESPACE_TAGS].ref))) { int j; free(rs->items[i].src);