From 8c53f0719b04e0b6328c2e175e3c5d2dc8a0c282 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 12 Jan 2015 20:59:09 -0500 Subject: use xstrdup_or_null to replace ternary conditionals This replaces "x ? xstrdup(x) : NULL" with xstrdup_or_null(x). The change is fairly mechanical, with the exception of resolve_refdup, which can eliminate a temporary variable. There are still a few hits grepping for "?.*xstrdup", but these are of slightly different forms and cannot be converted (e.g., "x ? xstrdup(x->foo) : NULL"). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- remote.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'remote.c') diff --git a/remote.c b/remote.c index ce785f8953..179bceff8a 100644 --- a/remote.c +++ b/remote.c @@ -975,8 +975,8 @@ struct ref *copy_ref(const struct ref *ref) cpy = xmalloc(sizeof(struct ref) + len + 1); memcpy(cpy, ref, sizeof(struct ref) + len + 1); cpy->next = NULL; - cpy->symref = ref->symref ? xstrdup(ref->symref) : NULL; - cpy->remote_status = ref->remote_status ? xstrdup(ref->remote_status) : NULL; + cpy->symref = xstrdup_or_null(ref->symref); + cpy->remote_status = xstrdup_or_null(ref->remote_status); cpy->peer_ref = copy_ref(ref->peer_ref); return cpy; } -- cgit v1.2.3