From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A486BC54FCB for ; Thu, 23 Apr 2020 22:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C0182077D for ; Thu, 23 Apr 2020 22:16:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="J9DU0iJi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbgDWWQf (ORCPT ); Thu, 23 Apr 2020 18:16:35 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:53966 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726056AbgDWWQf (ORCPT ); Thu, 23 Apr 2020 18:16:35 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 48134664ED; Thu, 23 Apr 2020 18:16:33 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=9ndP8TGT8DGZ/Qkv9hEy3x1+ays=; b=J9DU0i Ji1tGyIxQReg8wKnqLYrm+/Ct1ZpFZwqLrADBOUPBiMA8sxiSC2/UTrNckDviNCK +Ixy5S/Tq8Tiy8xbe0rGERiTCBpK07a2EfPGjAmGTWot2opF4gpHoY8y9FsYWqkt 7nvJvopVXMQ/6072tokpyBS2i6oBh5+gTPpbE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=ov01/LuS6JmtodwIIMgmIqi5c/lXJOTK 1pCsudd67Bl3xdSjBNZBhVa9+OVNt+x9lV+2xnDXMMkV7XlVlXm9lbLwx7LtdZXz cPAG5M3G6aMGuXNrSDQvd+B2j6okFrHrsyWi2SIfksEsDuhmqVuI6eJOe+kXYNTc hnn+syemCQ8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 3E4EA664EC; Thu, 23 Apr 2020 18:16:33 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.74.119.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 9E4A2664EB; Thu, 23 Apr 2020 18:16:31 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Johannes Schindelin Cc: Carlo Marcelo Arenas =?utf-8?Q?Bel=C3=B3n?= , Jonathan Nieder , Johannes Schindelin via GitGitGadget , git@vger.kernel.org, Jeff King , "brian m. carlson" , Ilya Tretyakov Subject: Re: [PATCH 2/3] credential: teach `credential_from_url()` a non-strict mode References: <1081841b16de31693473e72ff817bed5f0064dda.1587588665.git.gitgitgadget@gmail.com> <20200422233854.GE140314@google.com> <20200423212212.GA20669@Carlos-MBP> Date: Thu, 23 Apr 2020 15:16:30 -0700 In-Reply-To: (Junio C. Hamano's message of "Thu, 23 Apr 2020 15:11:25 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 15EB48B2-85B0-11EA-9036-D1361DBA3BAF-77302942!pb-smtp2.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Junio C Hamano writes: > Johannes Schindelin writes: > >> Yes (modulo doing "greater than" comparison on pointers which is IIRC not >> permitted in C in general). > > Of course, people write a loop like this > > char *cp, *ep = strchr(string, '\n'); > > for (cp = string; cp < ep; cp++) > ... > > all the time, and forbidding pointer comparison would make the > language impossible to use ;-) > > I think you are confused with a different rule---what is not kosher > is to compare two pointers that do not point into elements of the > same array. Whether the comparison is done in (ptr1 < ptr2) way, or > (ptr2 - ptr1 < 0) way, does not change the equation. Having said that, between 1. if (strict || slash - url > 0) 2. if (strict || slash > url) c->host = url_decode_mem(host, slash - host); I think the former is moderately easier to read. It still has the same "Huh?" factor that a comparison between slash and URL guards the size of the region being decoded, which is slash - host, and makes the reader wonder how these two variables, URL and host, relate to each other at this point in the code, though, either way the comparison is spelled. Thanks.