summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-03-06 22:57:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-06 22:57:57 (GMT)
commitf56a5f4fed296647ae8978645f9c627410717398 (patch)
tree693afac09ae1fd40b7ab39ae8b8122cde6050b7f /sha1_name.c
parentd86679fa061e22e33596814630513b6a7b4d4767 (diff)
parent2ce63e9fac242a70cd6d9e1325063bbb2e5091f8 (diff)
downloadgit-f56a5f4fed296647ae8978645f9c627410717398.zip
git-f56a5f4fed296647ae8978645f9c627410717398.tar.gz
git-f56a5f4fed296647ae8978645f9c627410717398.tar.bz2
Merge branch 'rs/simple-cleanups' into maint
Code cleanups. * rs/simple-cleanups: sha1_name: use strlcpy() to copy strings pretty: use starts_with() to check for a prefix for-each-ref: use skip_prefix() to avoid duplicate string comparison connect: use strcmp() for string comparison
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/sha1_name.c b/sha1_name.c
index cf2a83b..95f9f8f 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1391,9 +1391,7 @@ static int get_sha1_with_context_1(const char *name,
namelen = strlen(cp);
}
- strncpy(oc->path, cp,
- sizeof(oc->path));
- oc->path[sizeof(oc->path)-1] = '\0';
+ strlcpy(oc->path, cp, sizeof(oc->path));
if (!active_cache)
read_cache();
@@ -1443,9 +1441,7 @@ static int get_sha1_with_context_1(const char *name,
name, len);
}
hashcpy(oc->tree, tree_sha1);
- strncpy(oc->path, filename,
- sizeof(oc->path));
- oc->path[sizeof(oc->path)-1] = '\0';
+ strlcpy(oc->path, filename, sizeof(oc->path));
free(new_filename);
return ret;