* [PATCH 1/4] cgit.c: remove useless null check
2015-10-08 22:23 [PATCH 0/4] Initial Coverity fixes john
@ 2015-10-08 22:23 ` john
2015-10-08 22:23 ` [PATCH 2/4] scan-tree: remove useless strdup() john
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: john @ 2015-10-08 22:23 UTC (permalink / raw)
Everywhere else in this function we do not check whether the value is
null and parse_configfile() never passes a null value to this callback.
Coverity-id: 13846
Signed-off-by: John Keeping <john at keeping.me.uk>
---
cgit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cgit.c b/cgit.c
index 28a2f14..5937b9e 100644
--- a/cgit.c
+++ b/cgit.c
@@ -110,7 +110,7 @@ static void config_cb(const char *name, const char *value)
ctx.repo->path = trim_end(value, '/');
else if (ctx.repo && starts_with(name, "repo."))
repo_config(ctx.repo, name + 5, value);
- else if (!strcmp(name, "readme") && value != NULL)
+ else if (!strcmp(name, "readme"))
string_list_append(&ctx.cfg.readme, xstrdup(value));
else if (!strcmp(name, "root-title"))
ctx.cfg.root_title = xstrdup(value);
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] scan-tree: remove useless strdup()
2015-10-08 22:23 [PATCH 0/4] Initial Coverity fixes john
2015-10-08 22:23 ` [PATCH 1/4] cgit.c: remove useless null check john
@ 2015-10-08 22:23 ` john
2015-10-08 22:23 ` [PATCH 3/4] ui-blob: remove useless null check john
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: john @ 2015-10-08 22:23 UTC (permalink / raw)
parse_configfile() takes a "const char *" and doesn't hold any
references to it after it returns; there is no reason to pass it a
duplicate.
Coverity-id: 13941
Signed-off-by: John Keeping <john at keeping.me.uk>
---
scan-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scan-tree.c b/scan-tree.c
index 8e3cf52..b5a10ff 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -174,7 +174,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
strbuf_addstr(path, "cgitrc");
if (!stat(path->buf, &st))
- parse_configfile(xstrdup(path->buf), &repo_config);
+ parse_configfile(path->buf, &repo_config);
strbuf_release(&rel);
}
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] ui-blob: remove useless null check
2015-10-08 22:23 [PATCH 0/4] Initial Coverity fixes john
2015-10-08 22:23 ` [PATCH 1/4] cgit.c: remove useless null check john
2015-10-08 22:23 ` [PATCH 2/4] scan-tree: remove useless strdup() john
@ 2015-10-08 22:23 ` john
2015-10-08 22:23 ` [PATCH 4/4] ui-refs: " john
2015-10-09 8:54 ` [PATCH 0/4] Initial Coverity fixes Jason
4 siblings, 0 replies; 6+ messages in thread
From: john @ 2015-10-08 22:23 UTC (permalink / raw)
We have already called strlen() on "path" by the time we get here, so we
know it can't be null.
Coverity-id: 13954
Signed-off-by: John Keeping <john at keeping.me.uk>
---
ui-blob.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui-blob.c b/ui-blob.c
index b333f86..d3c3a10 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -85,7 +85,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
if (get_sha1(head, sha1))
return -1;
type = sha1_object_info(sha1, &size);
- if (type == OBJ_COMMIT && path) {
+ if (type == OBJ_COMMIT) {
commit = lookup_commit_reference(sha1);
read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.found_path)
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] ui-refs: remove useless null check
2015-10-08 22:23 [PATCH 0/4] Initial Coverity fixes john
` (2 preceding siblings ...)
2015-10-08 22:23 ` [PATCH 3/4] ui-blob: remove useless null check john
@ 2015-10-08 22:23 ` john
2015-10-09 8:54 ` [PATCH 0/4] Initial Coverity fixes Jason
4 siblings, 0 replies; 6+ messages in thread
From: john @ 2015-10-08 22:23 UTC (permalink / raw)
There is no way that "tag" can be null here.
Coverity-id: 13950
Signed-off-by: John Keeping <john at keeping.me.uk>
---
ui-refs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui-refs.c b/ui-refs.c
index be3572c..295a4c7 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -135,7 +135,7 @@ static int print_tag(struct refinfo *ref)
tag = (struct tag *)obj;
obj = tag->tagged;
info = ref->tag;
- if (!tag || !info)
+ if (!info)
return 1;
}
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/4] Initial Coverity fixes
2015-10-08 22:23 [PATCH 0/4] Initial Coverity fixes john
` (3 preceding siblings ...)
2015-10-08 22:23 ` [PATCH 4/4] ui-refs: " john
@ 2015-10-09 8:54 ` Jason
4 siblings, 0 replies; 6+ messages in thread
From: Jason @ 2015-10-09 8:54 UTC (permalink / raw)
Great! Thanks. Merged. We'll see what happens.
^ permalink raw reply [flat|nested] 6+ messages in thread