]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Coalesce v0 and v1 fields of rend_intro_cell_t
authorNick Mathewson <nickm@torproject.org>
Tue, 30 Dec 2014 17:07:28 +0000 (12:07 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 30 Dec 2014 17:07:39 +0000 (12:07 -0500)
This saves a tiny bit of code, and makes a longstanding coverity
false positive go away.

src/or/rendservice.c
src/or/rendservice.h

index 196145e210fdc9a8ddfc6ee65af99290682106ca..d4fbe739fe6be8a0d45bf74f5892a8b474932f27 100644 (file)
@@ -1527,8 +1527,7 @@ find_rp_for_intro(const rend_intro_cell_t *intro,
   }
 
   if (intro->version == 0 || intro->version == 1) {
-    if (intro->version == 1) rp_nickname = (const char *)(intro->u.v1.rp);
-    else rp_nickname = (const char *)(intro->u.v0.rp);
+    rp_nickname = (const char *)(intro->u.v0_v1.rp);
 
     node = node_get_by_nickname(rp_nickname, 0);
     if (!node) {
@@ -1777,11 +1776,7 @@ rend_service_parse_intro_for_v0_or_v1(
     goto err;
   }
 
-  if (intro->version == 1) {
-    memcpy(intro->u.v1.rp, rp_nickname, endptr - rp_nickname + 1);
-  } else {
-    memcpy(intro->u.v0.rp, rp_nickname, endptr - rp_nickname + 1);
-  }
+  memcpy(intro->u.v0_v1.rp, rp_nickname, endptr - rp_nickname + 1);
 
   return ver_specific_len;
 
index c2342ef57312413b37ab93d74e17642f76d84280..05502cac5dbe38dbfbb28596f50cf4ed36e6a3ba 100644 (file)
@@ -37,14 +37,10 @@ struct rend_intro_cell_s {
   uint8_t version;
   /* Version-specific parts */
   union {
-    struct {
-      /* Rendezvous point nickname */
-      uint8_t rp[20];
-    } v0;
     struct {
       /* Rendezvous point nickname or hex-encoded key digest */
       uint8_t rp[42];
-    } v1;
+    } v0_v1;
     struct {
       /* The extend_info_t struct has everything v2 uses */
       extend_info_t *extend_info;