aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-blame.c3
-rw-r--r--builtin-branch.c6
-rwxr-xr-xbuiltin-fast-export.c3
-rw-r--r--builtin-http-fetch.c3
-rw-r--r--builtin-pack-objects.c3
-rw-r--r--builtin-revert.c3
-rw-r--r--connect.c3
-rw-r--r--diff.c9
-rw-r--r--dir.c3
-rw-r--r--http-push.c18
-rw-r--r--imap-send.c5
-rw-r--r--interpolate.c3
-rw-r--r--pretty.c3
-rw-r--r--remote.c3
-rw-r--r--setup.c3
-rw-r--r--sha1_name.c6
-rw-r--r--xdiff-interface.c3
17 files changed, 27 insertions, 53 deletions
diff --git a/builtin-blame.c b/builtin-blame.c
index 59d7237f2..bfd562d7d 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -123,8 +123,7 @@ static inline struct origin *origin_incref(struct origin *o)
static void origin_decref(struct origin *o)
{
if (o && --o->refcnt <= 0) {
- if (o->file.ptr)
- free(o->file.ptr);
+ free(o->file.ptr);
free(o);
}
}
diff --git a/builtin-branch.c b/builtin-branch.c
index a7844454a..5bc4526f6 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -121,8 +121,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
continue;
}
- if (name)
- free(name);
+ free(name);
name = xstrdup(mkpath(fmt, argv[i]));
if (!resolve_ref(name, sha1, 1, NULL)) {
@@ -167,8 +166,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
}
}
- if (name)
- free(name);
+ free(name);
return(ret);
}
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 4bd1356d5..e1c56303e 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -196,8 +196,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
? strlen(reencoded) : message
? strlen(message) : 0),
reencoded ? reencoded : message ? message : "");
- if (reencoded)
- free(reencoded);
+ free(reencoded);
for (i = 0, p = commit->parents; p; p = p->next) {
int mark = get_object_mark(&p->item->object);
diff --git a/builtin-http-fetch.c b/builtin-http-fetch.c
index 7f450c61d..299093ff9 100644
--- a/builtin-http-fetch.c
+++ b/builtin-http-fetch.c
@@ -80,8 +80,7 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
walker_free(walker);
- if (rewritten_url)
- free(rewritten_url);
+ free(rewritten_url);
return rc;
}
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 586ae1197..1bba6e6a6 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1429,8 +1429,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
* accounting lock. Compiler will optimize the strangeness
* away when THREADED_DELTA_SEARCH is not defined.
*/
- if (trg_entry->delta_data)
- free(trg_entry->delta_data);
+ free(trg_entry->delta_data);
cache_lock();
if (trg_entry->delta_data) {
delta_cache_size -= trg_entry->delta_size;
diff --git a/builtin-revert.c b/builtin-revert.c
index e219859f9..b6dee6a56 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -397,8 +397,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
else
return execl_git_cmd("commit", "-n", "-F", defmsg, NULL);
}
- if (reencoded_message)
- free(reencoded_message);
+ free(reencoded_message);
return 0;
}
diff --git a/connect.c b/connect.c
index 5ac357278..d12b10597 100644
--- a/connect.c
+++ b/connect.c
@@ -68,8 +68,7 @@ struct ref **get_remote_heads(int in, struct ref **list,
name_len = strlen(name);
if (len != name_len + 41) {
- if (server_capabilities)
- free(server_capabilities);
+ free(server_capabilities);
server_capabilities = xstrdup(name + name_len + 1);
}
diff --git a/diff.c b/diff.c
index 18859a70e..ad1616423 100644
--- a/diff.c
+++ b/diff.c
@@ -118,8 +118,7 @@ static int parse_funcname_pattern(const char *var, const char *ep, const char *v
pp->next = funcname_pattern_list;
funcname_pattern_list = pp;
}
- if (pp->pattern)
- free(pp->pattern);
+ free(pp->pattern);
pp->pattern = xstrdup(value);
return 0;
}
@@ -492,10 +491,8 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
ecbdata->diff_words->plus.text.size)
diff_words_show(ecbdata->diff_words);
- if (ecbdata->diff_words->minus.text.ptr)
- free (ecbdata->diff_words->minus.text.ptr);
- if (ecbdata->diff_words->plus.text.ptr)
- free (ecbdata->diff_words->plus.text.ptr);
+ free (ecbdata->diff_words->minus.text.ptr);
+ free (ecbdata->diff_words->plus.text.ptr);
free(ecbdata->diff_words);
ecbdata->diff_words = NULL;
}
diff --git a/dir.c b/dir.c
index 1f507daff..edc458e02 100644
--- a/dir.c
+++ b/dir.c
@@ -704,8 +704,7 @@ static struct path_simplify *create_simplify(const char **pathspec)
static void free_simplify(struct path_simplify *simplify)
{
- if (simplify)
- free(simplify);
+ free(simplify);
}
int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen, const char **pathspec)
diff --git a/http-push.c b/http-push.c
index 0beb7406c..406270f6f 100644
--- a/http-push.c
+++ b/http-push.c
@@ -664,8 +664,7 @@ static void release_request(struct transfer_request *request)
close(request->local_fileno);
if (request->local_stream)
fclose(request->local_stream);
- if (request->url != NULL)
- free(request->url);
+ free(request->url);
free(request);
}
@@ -1283,10 +1282,8 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
strbuf_release(&in_buffer);
if (lock->token == NULL || lock->timeout <= 0) {
- if (lock->token != NULL)
- free(lock->token);
- if (lock->owner != NULL)
- free(lock->owner);
+ free(lock->token);
+ free(lock->owner);
free(url);
free(lock);
lock = NULL;
@@ -1344,8 +1341,7 @@ static int unlock_remote(struct remote_lock *lock)
prev->next = prev->next->next;
}
- if (lock->owner != NULL)
- free(lock->owner);
+ free(lock->owner);
free(lock->url);
free(lock->token);
free(lock);
@@ -2035,8 +2031,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
}
free(url);
- if (*symref != NULL)
- free(*symref);
+ free(*symref);
*symref = NULL;
hashclr(sha1);
@@ -2435,8 +2430,7 @@ int main(int argc, char **argv)
}
cleanup:
- if (rewritten_url)
- free(rewritten_url);
+ free(rewritten_url);
if (info_ref_lock)
unlock_remote(info_ref_lock);
free(remote);
diff --git a/imap-send.c b/imap-send.c
index 9025d9aa3..10cce15a4 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -472,7 +472,7 @@ v_issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb,
if (socket_write( &imap->buf.sock, buf, bufl ) != bufl) {
free( cmd->cmd );
free( cmd );
- if (cb && cb->data)
+ if (cb)
free( cb->data );
return NULL;
}
@@ -858,8 +858,7 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
normal:
if (cmdp->cb.done)
cmdp->cb.done( ctx, cmdp, resp );
- if (cmdp->cb.data)
- free( cmdp->cb.data );
+ free( cmdp->cb.data );
free( cmdp->cmd );
free( cmdp );
if (!tcmd || tcmd == cmdp)
diff --git a/interpolate.c b/interpolate.c
index 6ef53f246..7f03bd99c 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -11,8 +11,7 @@ void interp_set_entry(struct interp *table, int slot, const char *value)
char *oldval = table[slot].value;
char *newval = NULL;
- if (oldval)
- free(oldval);
+ free(oldval);
if (value)
newval = xstrdup(value);
diff --git a/pretty.c b/pretty.c
index a5b2d8c60..703f52176 100644
--- a/pretty.c
+++ b/pretty.c
@@ -30,8 +30,7 @@ enum cmit_fmt get_commit_format(const char *arg)
if (*arg == '=')
arg++;
if (!prefixcmp(arg, "format:")) {
- if (user_format)
- free(user_format);
+ free(user_format);
user_format = xstrdup(arg + 7);
return CMIT_FMT_USERFORMAT;
}
diff --git a/remote.c b/remote.c
index 45560d900..7e1937286 100644
--- a/remote.c
+++ b/remote.c
@@ -593,8 +593,7 @@ void free_refs(struct ref *ref)
struct ref *next;
while (ref) {
next = ref->next;
- if (ref->peer_ref)
- free(ref->peer_ref);
+ free(ref->peer_ref);
free(ref);
ref = next;
}
diff --git a/setup.c b/setup.c
index dc247a84c..89c81e54e 100644
--- a/setup.c
+++ b/setup.c
@@ -448,8 +448,7 @@ int check_repository_format_version(const char *var, const char *value)
} else if (strcmp(var, "core.worktree") == 0) {
if (!value)
return config_error_nonbool(var);
- if (git_work_tree_cfg)
- free(git_work_tree_cfg);
+ free(git_work_tree_cfg);
git_work_tree_cfg = xstrdup(value);
inside_work_tree = -1;
}
diff --git a/sha1_name.c b/sha1_name.c
index c2805e736..9d088cc2c 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -625,8 +625,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
commit = pop_most_recent_commit(&list, ONELINE_SEEN);
if (!parse_object(commit->object.sha1))
continue;
- if (temp_commit_buffer)
- free(temp_commit_buffer);
+ free(temp_commit_buffer);
if (commit->buffer)
p = commit->buffer;
else {
@@ -643,8 +642,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
break;
}
}
- if (temp_commit_buffer)
- free(temp_commit_buffer);
+ free(temp_commit_buffer);
free_commit_list(list);
for (l = backup; l; l = l->next)
clear_commit_marks(l->item, ONELINE_SEEN);
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 4b8e5cca8..bba236428 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -233,8 +233,7 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value)
expression = value;
if (regcomp(&reg->re, expression, 0))
die("Invalid regexp to look for hunk header: %s", expression);
- if (buffer)
- free(buffer);
+ free(buffer);
value = ep + 1;
}
}