[ovs-dev,v2,8/9] raft.c: cmd->eid should always be non-null.
diff mbox series

Message ID 1555111588-79659-8-git-send-email-hzhou8@ebay.com
State New
Headers show
Series
  • [ovs-dev,v2,1/9] ovsdb.at: Move ovsdb macros from ovsdb.at to ovsdb-macros.at.
Related show

Commit Message

Han Zhou April 12, 2019, 11:26 p.m. UTC
From: Han Zhou <hzhou8@ebay.com>

raft_command's eid should always be non-null in all 3 cases. Fix the
comment, and also replace if condition with assert.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
v1->v2: moved the member under "All cases" section, according to Ben's
suggestion.

 ovsdb/raft.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/ovsdb/raft.c b/ovsdb/raft.c
index abcc9c0..02bdf11 100644
--- a/ovsdb/raft.c
+++ b/ovsdb/raft.c
@@ -108,13 +108,11 @@  struct raft_command {
     struct hmap_node hmap_node; /* In struct raft's 'commands' hmap. */
     unsigned int n_refs;        /* Reference count.  */
     enum raft_command_status status; /* Execution status. */
+    struct uuid eid;            /* Entry ID of result. */
 
     /* Case 1 only. */
     uint64_t index;             /* Index in log (0 if being relayed). */
 
-    /* Cases 2 and 3. */
-    struct uuid eid;            /* Entry ID of result. */
-
     /* Case 2 only. */
     long long int timestamp;    /* Issue or last ping time, for expiration. */
 
@@ -1974,9 +1972,8 @@  raft_command_initiate(struct raft *raft,
     }
 
     struct raft_command *cmd = raft_command_create_incomplete(raft, index);
-    if (eid) {
-        cmd->eid = *eid;
-    }
+    ovs_assert(eid);
+    cmd->eid = *eid;
 
     raft_waiter_create(raft, RAFT_W_ENTRY, true)->entry.index = cmd->index;