summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-03-05 20:45:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-05 20:45:42 (GMT)
commit8a6444d50ea73350ae7e6083ecc63393749e5bb0 (patch)
tree949f413a7105dc06326fc3fc5108ebff92397f57 /sha1_name.c
parentca704731b1fdf77b8f6d296bcde206c67ed9d73a (diff)
parent2ce63e9fac242a70cd6d9e1325063bbb2e5091f8 (diff)
downloadgit-8a6444d50ea73350ae7e6083ecc63393749e5bb0.zip
git-8a6444d50ea73350ae7e6083ecc63393749e5bb0.tar.gz
git-8a6444d50ea73350ae7e6083ecc63393749e5bb0.tar.bz2
Merge branch 'rs/simple-cleanups'
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;