[tor-bugs] #29209 [Core Tor/Tor]: Reduce visibility of more data type internals
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu May 2 02:15:10 UTC 2019
#29209: Reduce visibility of more data type internals
----------------------------------------+----------------------------------
Reporter: nickm | Owner: (none)
Type: task | Status: new
Priority: Medium | Milestone: Tor:
| 0.4.1.x-final
Component: Core Tor/Tor | Version:
Severity: Normal | Resolution:
Keywords: technical-debt refactoring | Actual Points: 3.5
Parent ID: | Points: 15
Reviewer: nickm | Sponsor: Sponsor31-can
----------------------------------------+----------------------------------
Comment (by catalyst):
Replying to [comment:19 nickm]:
> My understanding is that the leading underscore is also reserved for
external identifiers; even if it's safe for struct members, it's something
we don't want to encourage.
We chatted a bit about this on IRC. I still like leading underscores for
hiding struct members, because I think it makes it easier to search for
inappropriate uses. (I also think it's easier to search for leading
underscore than for some specific long suffix(es).)
I think generally speaking we should avoid using identifiers with leading
underscores in `.c` files, even when we use them for hiding struct
members. Any `.c` file that uses the private members should only access
them using helper macros defined in headers. These macros will hide the
use of the leading underscores.
It's fairly easy to write small Coccinelle scripts for matching
* uses of identifiers starting with an underscore
* uses of struct members starting with an underscore
There are quite a few places where we already use identifiers with leading
underscores for parameter names and local variables. The C standard allows
these uses. I think there isn't much harm for leading underscores for
parameters and locals.
Nick suggests waiting until after we merge #30236 to update that patch to
use `_ ## x _ ## _module_name_private_field`. I'll open a new ticket for
that.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29209#comment:20>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list