[tor-bugs] #32415 [Core Tor/Tor]: Rename every struct we declare to end with _t.

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Nov 12 01:31:58 UTC 2019


#32415: Rename every struct we declare to end with _t.
--------------------------+------------------------------------
 Reporter:  nickm         |          Owner:  nickm
     Type:  task          |         Status:  needs_revision
 Priority:  Medium        |      Milestone:  Tor: 0.4.3.x-final
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:                |  Actual Points:  .2
Parent ID:                |         Points:  .1
 Reviewer:  teor          |        Sponsor:  Sponsor31-can
--------------------------+------------------------------------
Changes (by teor):

 * status:  needs_review => needs_revision
 * actualpoints:  .1 => .2


Comment:

 Here are some missed structs, excluding those structs that are defined by
 libraries:

 {{{
 $ git grep 'struct *[a-zA-Z0-9_]*[^t ] *{' \
     src/{app,core,feature,lib,test,tools} \
   | grep -v ': *static '
 src/lib/cc/compat_compiler.h: *   struct a { int foo; int bar; } x;
 src/lib/cc/compat_compiler.h: *   struct base { ... };
 src/lib/cc/compat_compiler.h: *   struct subtype { int x; struct base b; }
 x;
 src/lib/container/handles.h: *     struct walrus {
 src/lib/container/map.c:  struct maptype {
 \
 src/lib/math/prob_distr.h:*     struct foo {
 ... (spurious matches) ...
 }}}

 {{{
 $ git grep 'struct  *[a-zA-Z0-9_]*[^t ] \**[a-zA-Z0-9_]*[,)]' \
     src/{app,core,feature,lib,test,tools} \
   | grep -v -e time -e addr -e sipkey -e tm -e SEC -e PR -e passwd -e
 event
 src/core/or/channel.c:channel_rsa_id_group_set_badness(struct
 channel_list_s *lst, int force)
 src/lib/cc/compat_compiler.h: *   ptrdiff_t bar_offset = offsetof(struct
 a, bar);
 src/lib/cc/compat_compiler.h: *   struct *sp = SUBTYPE_P(bp, struct
 subtype, b);
 src/lib/container/handles.h: *     struct wlr_handle_t
 *wlr_handle_new(struct walrus *);
 src/lib/container/handles.h: *     void wlr_handles_clear(struct walrus
 *);
 src/lib/container/handles.h:  linkage  name ## _handle_t *name ##
 _handle_new(struct structname *object); \
 src/lib/container/handles.h:  linkage void name ## _handles_clear(struct
 structname *object);
 src/lib/container/handles.h:  name ## _handle_new(struct structname
 *object)                        \
 src/lib/container/handles.h:  name ## _handles_clear(struct structname
 *object)                     \
 ... (spurious matches) ...
 }}}


 Most of these are comments, which should be manually fixed to match our
 style.

 `struct maptype` is a macro argument, we should go a global rename, just
 like we did for the probability dist functions:
 * `struct map_t` - too short?
 * `struct maptype_t` - seems repetitive?
 * `struct map_value_t` ?

 `struct channel_list_s` is defined by TOR_LIST_HEAD(), I'm not sure if it
 will work if we pass channel_t twice. If not, we should pass something
 ending in `_t`.

 `struct structname` should probably become `struct handle_value_t`, using
 the same pattern we use for map.

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


More information about the tor-bugs mailing list