[tor-bugs] #29209 [Core Tor/Tor]: Reduce visibility of more data type internals

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Apr 24 20:17:04 UTC 2019


#29209: Reduce visibility of more data type internals
----------------------------------------+----------------------------------
 Reporter:  nickm                       |          Owner:  (none)
     Type:  task                        |         Status:  needs_review
 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:11 catalyst]:
 > or
 >
 > {{{
 > #define F_PRIV(x) x ## _ ## _private
 > struct foobar_t {
 >   int f_count;
 >   char *F_PRIV(f_thing);
 >   long f_id;
 > };
 > #ifdef FOOBAR_PRIVATE
 > #define f_thing F_PRIV(f_thing)
 > #endif
 > }}}

 oops sorry that should probably be
 {{{
 /* f_stuff => _f_stuff__private */
 /* use x ## _ ## _private instead of x ## __private to avoid reserved
 namespace */
 #define F_PRIV(x) _ ## x ## _ ## _private
 struct foobar_t {
   int f_count;
   char *F_PRIV(f_thing);
   long f_id;
 };
 #ifdef FOOBAR_PRIVATE
 #define f_thing F_PRIV(f_thing)
 #endif
 }}}
 (I forgot to have the macro add the underscore prefix)

 Note the underscore-prefixed reserved names space rules are a little
 tricky -- identifiers starting with two underscores or a single underscore
 followed by a capital letter are reserved for ''any'' use, which means
 they shouldn't appear anywhere except as allowed by a documented C (or OS)
 interface or extension. (stuff like `__attribute__` in GCC) The single
 underscore prefix unless followed by a capital letter is reserved for
 file-scope identifiers, which a struct member is not. (C99 ยง7.1.3)

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29209#comment:12>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list