lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4597944e-a8f5-44df-adf3-558940e88598@redhat.com>
Date: Mon, 1 Sep 2025 17:31:01 +0200
From: David Hildenbrand <david@...hat.com>
To: Max Kellermann <max.kellermann@...os.com>
Cc: akpm@...ux-foundation.org, axelrasmussen@...gle.com, yuanchu@...gle.com,
 willy@...radead.org, hughd@...gle.com, mhocko@...e.com,
 linux-kernel@...r.kernel.org, linux-mm@...ck.org,
 lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com, vbabka@...e.cz,
 rppt@...nel.org, surenb@...gle.com, vishal.moola@...il.com,
 linux@...linux.org.uk, James.Bottomley@...senpartnership.com, deller@....de,
 agordeev@...ux.ibm.com, gerald.schaefer@...ux.ibm.com, hca@...ux.ibm.com,
 gor@...ux.ibm.com, borntraeger@...ux.ibm.com, svens@...ux.ibm.com,
 davem@...emloft.net, andreas@...sler.com, dave.hansen@...ux.intel.com,
 luto@...nel.org, peterz@...radead.org, tglx@...utronix.de, mingo@...hat.com,
 bp@...en8.de, x86@...nel.org, hpa@...or.com, chris@...kel.net,
 jcmvbkbc@...il.com, viro@...iv.linux.org.uk, brauner@...nel.org,
 jack@...e.cz, weixugc@...gle.com, baolin.wang@...ux.alibaba.com,
 rientjes@...gle.com, shakeel.butt@...ux.dev, thuth@...hat.com,
 broonie@...nel.org, osalvador@...e.de, jfalempe@...hat.com,
 mpe@...erman.id.au, nysal@...ux.ibm.com,
 linux-arm-kernel@...ts.infradead.org, linux-parisc@...r.kernel.org,
 linux-s390@...r.kernel.org, sparclinux@...r.kernel.org,
 linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v5 06/12] mm, s390: constify mapping related test
 functions for improved const-correctness

On 01.09.25 17:22, Max Kellermann wrote:
> On Mon, Sep 1, 2025 at 5:11 PM David Hildenbrand <david@...hat.com> wrote:
>>>> Should this also be *const ?
>>>
>>> No. These are function protoypes. A "const" on a parameter value
>>> (pointer address, not pointed-to memory) makes no sense on a
>>> prototype.
>>
>> But couldn't you argue the same about variable names? In most (not all
>> :) ) we keep declaration + definition in sync. So thus my confusion.
> 
> Variable names in the prototypes have no effect either, but they serve
> as useful documentation.
> 
> Whereas the "const" on a parameter value documents nothing - it's an
> implementation detail whether the function would like to modify
> parameter values. That implementation detail has no effect for the
> caller.
> 
> Of course, we could have "const" in the prototype as well. This boils
> down to personal taste. It's not my taste (has no use, has no effect,
> documents nothing, only adds noise for no gain), so I didn't add it.
> If you prefer to have that, I'll leave my taste and home and add it,
> but only after you guys make up your minds about whether you want to
> have const parameters at all.

Valid points. The problem is that it could very soon become inconsistent.

For example, when I write a new function I usually just copy what I have
from the definition into the declaration.

For example, checkpatch complains about missing variable names and I 
think it complains when "extern" is used for functions.

If we were to decide to go that route (not keep them in perfect sync), I 
guess it would be reasonable to extend checkpatch to warn if "*const" is 
used in a declaration. (perl magic, no idea how hard that would be)

I'm sure there are false positives in the following:

$ git grep "\*const" *.h | grep -v inline | wc -l
403

-- 
Cheers

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ