Don't display "last_connection_attempt" if there is not one
authorJennifer Richards <jennifer@painless-security.com>
Thu, 26 Apr 2018 23:33:01 +0000 (19:33 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Thu, 26 Apr 2018 23:33:01 +0000 (19:33 -0400)
trp/trp_peer_encoders.c

index 8aafece..b169e17 100644 (file)
@@ -64,15 +64,13 @@ static json_t *last_attempt_to_json_string(TRP_PEER *peer)
   char *s = NULL;
   json_t *jstr = NULL;
 
-  if (tr_cmp_timespec(trp_peer_get_last_conn_attempt(peer), &ts_zero) == 0) {
-    s = strdup("");
-  } else {
+  if (tr_cmp_timespec(trp_peer_get_last_conn_attempt(peer), &ts_zero) > 0) {
     s = timespec_to_str(trp_peer_get_last_conn_attempt(peer));
-  }
 
-  if (s) {
-    jstr = json_string(s);
-    free(s);
+    if (s) {
+      jstr = json_string(s);
+      free(s);
+    }
   }
 
   return jstr;