From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id C892C3858C31 for ; Thu, 14 Nov 2024 16:24:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C892C3858C31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C892C3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731601480; cv=none; b=hKDU7owi39JwJN8eqRYNwPsiEleRAqF1mFjA4+O9FFDbScdDO54t9Oj2oKBmTDTCEfwwJQ7B0EFy/XRZizlx9pH3rKBDjO6VM7q1XalTLWQf7UpzNA34iNxxYgOZMdY7zyEnAycddL+e6y2/RllCfxQJNMzTF6//tYR51gdjqAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731601480; c=relaxed/simple; bh=LMLTDDBeanZO+g3esx1zGri1uBkcN4LLiaK3ZRUwpvA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=fAYvyPn+Wa4/RFluhL93aIDWTW8vL6xFMFfePmsmfAuLBrWdFzHUeMSj16F04Z0nbjQKUnAnxJHcFvlr4u4TNh/KPBKkrv6cC3WjiQ9G/WUv3i39Ozhj6ubS66s8EcnlZhIaT5DPh3EyYQDJswGh4lil2eASEta/DaB9nVje7Q0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C892C3858C31 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=U2ik68KG Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-53da353eb2eso1519977e87.3 for ; Thu, 14 Nov 2024 08:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731601478; x=1732206278; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ttBTyUM/O4bqPlqBUfmL70W9C/xta6I8RNJcjRK+qmA=; b=U2ik68KGNpt+ISDiHrbNXbTuEtpd1VuR7+GKyhZfThDddqp8tmjXRFeWdJWEyHE2R2 QG17gK/YZ/e5Ej3qbBlz4MwMfeFg6yOr0l+JGQZ1KJ/40OKejlbba5pA6W6EwTXb5T2c jA3AF4u+fyAvNi5SZbh/cJaRsdF1zgv80FB3Y7IEW3G2QJ0HWwj7bmvbJwfr4k3uRxRr drUFxJBJAFoIfSPnxjl2Aeb2p/EJyeeGGbGRBWW9ymL1X6TH/q48koUthljlzR95AU3H I9+zH2sdbLx9LG9KxrsiNZCkmUMrhHJMn2C7pioXttnrWQOL8kvG/5YTfPzhjgviO20X wYZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731601478; x=1732206278; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ttBTyUM/O4bqPlqBUfmL70W9C/xta6I8RNJcjRK+qmA=; b=YlzpHUluNdxHN5mAC0yQ5vWMrlUjwHBoxmEMgXOM2FWP9Gmzjjb2OQVFd5McnxSyRC i7yhXFMWDeSq7p1FvC/Q2Z/mT0a3BkekRrP11p/smEnbGId/OlnsErpPp3cMKnvlD7Nx jH4G04jSn6AxSnnsBnC+mtmV7ge9LPTdDlq51smgcnQdAKVRBuPI20DELLjIN0ZGjz9D 0pStNoMsiNaTOAi0x8ia9XGrABAIgc4VYlb+QwbQjSzVfepRqBb0Yn9FtFr7WqOvo4q+ patcfGkdcJH3MW5e0vnaznUELKkq9TfnEodHr4DtQLg0sB+aiN7QtrPJKIOpKDtlc9cP V6mQ== X-Forwarded-Encrypted: i=1; AJvYcCUwCYTJZPEEx+A9GpmhXjLhc/sOSQDkkgkI2sMv+bIQAQAwC6QLbMhNmLt/tc8Q2ChyRB8BcXKe0tZf@sourceware.org X-Gm-Message-State: AOJu0Yzitajc3WyK+oyouRfFNZVSqlhXw2VhLs7gIaTlb7EXoRFxZ+0f 0R/6A5yeVuroDOD2MMf23iQBlNkI/5PRTe/yRtwSS4MM88q62kDy X-Google-Smtp-Source: AGHT+IF/MMDebLrCxZ7SQmXQmOCaNKqINEzednzM9hpj8hRJ+fSW+CRwe2zhPRr4GxPGmXwCin0p4w== X-Received: by 2002:a05:6512:281d:b0:530:ab68:25c5 with SMTP id 2adb3069b0e04-53da5c27958mr2316843e87.2.1731601477933; Thu, 14 Nov 2024 08:24:37 -0800 (PST) Received: from ?IPV6:2a07:b944::2:2? ([2a02:6ea0:1703:5033::24]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20df56962sm79206866b.78.2024.11.14.08.24.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2024 08:24:37 -0800 (PST) Message-ID: <7e0401be-0435-4c76-a987-0ef833483cbe@gmail.com> Date: Thu, 14 Nov 2024 17:24:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: lfind(3) $3 type should be const To: Alejandro Colomar , libc-alpha@sourceware.org Cc: linux-man@vger.kernel.org References: Content-Language: en-US From: Gabriel Ravier In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/14/24 3:38 PM, Alejandro Colomar wrote: > Hi! > > lfind(3) does not modify its third argument, *nmemb. > > It's already suspicious that it takes a pointer, but I guess it's due to > historic reasons, and that's already set in stone. > > However, I don't see why we should not make it 'const'. The function > doesn't use it as an output pointer. Should I sent a patch for > constifying it? I believe the reason is that it aims to mirror lsearch, and to be able to be used with it interchangeably as a function with the same type - doesn't `const` make the pointer types distinct and incompatible ? I'd imagine it's not even used much at all elsewhere given how simple it is and how cumbersome it is to use compared to an directly inlined implementation. That is, I think making it non-const might just happen to break a majority of uses of it. The only way to plausibly rectify this, I think, would be to make the compatibility implicit in the standard for any similar function (in the same way one might like to make it standard to e.g. pass a pointer to a pointer to const char to strtol). > > Have a lovely day! > Alex >