From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by sourceware.org (Postfix) with ESMTPS id 275C13858D37 for ; Tue, 19 Mar 2024 08:29:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 275C13858D37 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fastly.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 275C13858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710836996; cv=none; b=AjmTOr8eesBhyC4M4+HogvcmMg2Ut0BSSk2c8zxTKxb6u3bpIIfXM6PROdmHcFdSg+NhqmAKA8wjNKBMsxCD1CWBmUkBsLr1IB6BVOzT/bvRDD2h0u7SKicHWFvtdSf+/VUmQZiTSblZdOTCQ8wQHE+7hBZJbvy7mWainuKqkVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710836996; c=relaxed/simple; bh=9ikX2eH/HqjJTFTrEdjVmBRoxG0XtUbYQNy8TIfzekE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=T9T+bfCc76kKkBl6p2zJm/WzWb+Xxe3/LkFbzbYIpQ4S7sf+0LOaPEcYVNz+S3+NbknkpPG2OHMf9lwhyOrN4ywhyyFPCZQhWT/tK6O+dy8IhjcxtopOsYEJwu8ctpPR5SRGVTuCl/S3E5h01+ntudcl5PfqQUxUsGVmdMnSpwE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5a14d7f0e66so1808835eaf.1 for ; Tue, 19 Mar 2024 01:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1710836994; x=1711441794; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GuAOuncZN4QFUQf/HrOxKqebC6WLK7SCgMLr9tn9e6c=; b=rV0vkn3UpU6bYtZ4Oak7QI82NN1AgtC92I6M4Xpk3nuwUVHWPSlpVXoyEmGaAnXFsO uWTJQtaELpsig2Am5CzgNendrWMdQbzYa0Sm06vs8+Sacp2HhWNs9+yAbLoGJDtd7+bK w0d33Dbdsx711c0DyXkHD9aQIaBzO0EvpvT98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710836994; x=1711441794; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GuAOuncZN4QFUQf/HrOxKqebC6WLK7SCgMLr9tn9e6c=; b=hOdVudMtf9C1PSpp2pqOYs8sLo6pvKuJK9k5ywPYWVInGfLFhFF+iPNYWPvvqK01R4 IFZgJejiNDyEwm0lIvLXzi9TG3b5jxytia10Ym0wbAIlMCzCbsSt7e5cfWYbIeXlJC6c nn6y2Q7MsnAliiEAuYK0TSk1TrrZJ+xLYNw7lEQfHFsTvGtnYr4ES1q05jOgkFjelVJJ rTo9eeysK6rHOxahrvtzTCGPyv3ydDMj4vjAA+ll6rIzxsWIF0vYd7YkHCy+02Ad7Y7x hUDOzDjxQCkqBc5RTp4h6Znn6AFrR4XuEs154VLcB2J4ZS/VS3mPRvgwsJBjKGZ1LwSi 9iOw== X-Forwarded-Encrypted: i=1; AJvYcCUyfQwX3iqCWE84s1aQXAhxQqDqRTagb6ucyvd8Ue0EehQRFkwv5qSudh9+1lb9YYtdjbuL6i8tE/bvfQDT66/hO2mc3MRTLg55 X-Gm-Message-State: AOJu0YxXEAxWeewLpB2Yp/yR+w5XdoIHKjI6ho4ihTADYcOdBdLX2mGY zJPKDfCdgDLeCSiE+2r2EK515uDUJ2YFkyYSgeKk9zQy6bl8JE57eYWlIXGvLQHnMaNONxbfPiI aRFF5w31DqIfICGrx0eZpdiaHqyMdI6TgSNISIA== X-Google-Smtp-Source: AGHT+IFiJxXv1ssbL4D86Y6kP34gjegXwIqXaUN/htEu/8q9Et2qV++a7xCNBlev9cN6NVP/g69uhnnZS6btOkp80v4= X-Received: by 2002:a05:6820:134f:b0:5a4:b8f2:5820 with SMTP id b15-20020a056820134f00b005a4b8f25820mr2566283oow.6.1710836994490; Tue, 19 Mar 2024 01:29:54 -0700 (PDT) MIME-Version: 1.0 References: <87zfuxcdjd.fsf@oldenburg.str.redhat.com> In-Reply-To: From: Job Snijders Date: Tue, 19 Mar 2024 18:29:43 +1000 Message-ID: Subject: Re: [PATCH] resolv: add IPv6 support to inet_net_pton() To: Andreas Schwab Cc: Florian Weimer , libc-alpha@sourceware.org Content-Type: multipart/alternative; boundary="000000000000535b400613ff47a3" X-Spam-Status: No, score=4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPAM_FROM,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: **** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000535b400613ff47a3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 19 Mar 2024 at 18:21, Andreas Schwab wrote: > On M=C3=A4r 18 2024, Job Snijders wrote: > > > On Mon, Mar 18, 2024 at 10:23:27AM +0100, Andreas Schwab wrote: > >> On M=C3=A4r 18 2024, Job Snijders wrote: > >> > + __set_errno (0); > >> > + lbits =3D strtol(sep, &ep, 10); > >> > + if (sep[0] =3D=3D '\0' || *ep !=3D '\0') { > >> > + __set_errno (ENOENT); > >> > + return (-1); > >> > + } > >> > + if ((errno =3D=3D ERANGE && (lbits =3D=3D LONG_MAX || lbits =3D= =3D LONG_MIN)) > >> > + || (lbits > 128 || lbits < 0)) { > >> > + __set_errno (EMSGSIZE); > >> > + return (-1); > >> > >> I think the first half of the error check is redundant since we only > >> accept values in the range [0,128] anyway. > > > > This is an idiomatic error check. The compiler can optimize parts of > > it, if the compiler feels they are not not neccessary. > > But it unnecessarily modifies errno (which the compiler cannot optimize > out), and sets it to zero when no error occurs, which no library routine > must ever do. The proposal at hand does save errno at the start and restores it at the end to avoid unnecessary stomping on errno (if nothing bad happened). I=E2= =80=99m not entirely sure how removing the idiomatic check helps in that regard? I might be missing something. Kind regards, Job > --000000000000535b400613ff47a3--