{"thread":{"id":"50808","subject":"[PATCH] commit-graph: fix sparse 'NULL pointer' warning","startedAt":"2019-03-23T01:20:02Z","lastAt":"2019-03-25T17:03:13Z","messageCount":3,"participants":["Ramsay Jones","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"372293","messageId":"1908832c-8dd0-377e-917b-acb33b00273c@ramsayjones.plus.com","threadId":"50808","inReplyTo":null,"subject":"[PATCH] commit-graph: fix sparse 'NULL pointer' warning","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2019-03-23T01:19:34Z","receivedAt":"2019-03-23T01:20:02Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Ævar,\n\nIf you need to re-roll your 'ab/commit-graph-fixes' branch, could you\nplease squash this into the relevant patch (commit aeb244adbc\n(\"commit-graph: don't early exit(1) on e.g. \\\"git status\\\"\", 2019-02-21).\n\nThis same commit (aeb244adbc) also removes the last call, outside of the\ncommit-graph.c file, to the function load_commit_graph_one(). So, this\nfunction is now a file-local symbol and could be marked 'static'.\n\nAlso, the function verify_commit_graph_lite(), introduced in commit\nd8acf37ff7 (\"commit-graph: fix segfault on e.g. \\\"git status\\\"\",\n2019-02-21), currently has no external callers. This function is also\na file-local symbol and could be marked 'static', unless you have plans\nfor future external calls?\n\nThanks!\n\nATB,\nRamsay Jones\n\n commit-graph.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 4696ee0036..680c6f5714 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -100,7 +100,7 @@ struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st)\n \tif (graph_size < GRAPH_MIN_SIZE) {\n \t\tclose(fd);\n \t\terror(_(\"commit-graph file is too small\"));\n-\t\treturn 0;\n+\t\treturn NULL;\n \t}\n \tgraph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0);\n \tret = parse_commit_graph(graph_map, fd, graph_size);\n-- \n2.21.0\n"},{"id":"372415","messageId":"871s2vcgb1.fsf@evledraar.gmail.com","threadId":"50808","inReplyTo":"1908832c-8dd0-377e-917b-acb33b00273c@ramsayjones.plus.com","subject":"Re: [PATCH] commit-graph: fix sparse 'NULL pointer' warning","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2019-03-25T12:02:58Z","receivedAt":"2019-03-25T12:03:03Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Mar 23 2019, Ramsay Jones wrote:\n\n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>\n> Hi Ævar,\n>\n> If you need to re-roll your 'ab/commit-graph-fixes' branch, could you\n> please squash this into the relevant patch (commit aeb244adbc\n> (\"commit-graph: don't early exit(1) on e.g. \\\"git status\\\"\", 2019-02-21).\n\nThanks. Will squash & re-submit. It's still just in \"pu\". Is there a\ncompiler that warns about it? Didn't on clang/gcc, but then again it's\njust-as-valid-C & just a style issue, so compilers don't care...\n\n> This same commit (aeb244adbc) also removes the last call, outside of the\n> commit-graph.c file, to the function load_commit_graph_one(). So, this\n> function is now a file-local symbol and could be marked 'static'.\n>\n> Also, the function verify_commit_graph_lite(), introduced in commit\n> d8acf37ff7 (\"commit-graph: fix segfault on e.g. \\\"git status\\\"\",\n> 2019-02-21), currently has no external callers. This function is also\n> a file-local symbol and could be marked 'static', unless you have plans\n> for future external calls?\n\nFixing these too. Just missed them. Thanks.\n\n>  commit-graph.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/commit-graph.c b/commit-graph.c\n> index 4696ee0036..680c6f5714 100644\n> --- a/commit-graph.c\n> +++ b/commit-graph.c\n> @@ -100,7 +100,7 @@ struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st)\n>  \tif (graph_size < GRAPH_MIN_SIZE) {\n>  \t\tclose(fd);\n>  \t\terror(_(\"commit-graph file is too small\"));\n> -\t\treturn 0;\n> +\t\treturn NULL;\n>  \t}\n>  \tgraph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0);\n>  \tret = parse_commit_graph(graph_map, fd, graph_size);\n"},{"id":"372440","messageId":"755f0706-9738-fc10-23a3-e1797c6925dd@ramsayjones.plus.com","threadId":"50808","inReplyTo":"871s2vcgb1.fsf@evledraar.gmail.com","subject":"Re: [PATCH] commit-graph: fix sparse 'NULL pointer' warning","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2019-03-25T17:03:07Z","receivedAt":"2019-03-25T17:03:13Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 25/03/2019 12:02, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Sat, Mar 23 2019, Ramsay Jones wrote:\n> \n>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>> ---\n>>\n>> Hi Ævar,\n>>\n>> If you need to re-roll your 'ab/commit-graph-fixes' branch, could you\n>> please squash this into the relevant patch (commit aeb244adbc\n>> (\"commit-graph: don't early exit(1) on e.g. \\\"git status\\\"\", 2019-02-21).\n> \n> Thanks. Will squash & re-submit. It's still just in \"pu\". Is there a\n> compiler that warns about it? Didn't on clang/gcc, but then again it's\n> just-as-valid-C & just a style issue, so compilers don't care...\n\nThis is a 'sparse' warning (see subject line). :-D\n\nI run the 'sparse' Makefile target on each branch and save to\na file, sp-out, nsp-out and psp-out, then diff from branch to\nbranch. So, currently, the diff between the 'next' and 'pu'\nbranches look like:\n\n  $ diff nsp-out psp-out\n  25a26\n  > commit-graph.c:103:24: warning: Using plain integer as NULL pointer\n  123a125\n  >     SP promisor-remote.c\n  188a191\n  > upload-pack.c:1167:56: warning: Using plain integer as NULL pointer\n  289d291\n  <     SP builtin/rebase--interactive.c\n  $ \n\nAlternatively, I can simply run 'sparse' over a single file:\n\n  $ make commit-graph.sp\n      SP commit-graph.c\n  commit-graph.c:103:24: warning: Using plain integer as NULL pointer\n  $ \n\nOf course, you need to have 'sparse' installed ... ;-)\n\n> \n>> This same commit (aeb244adbc) also removes the last call, outside of the\n>> commit-graph.c file, to the function load_commit_graph_one(). So, this\n>> function is now a file-local symbol and could be marked 'static'.\n>>\n>> Also, the function verify_commit_graph_lite(), introduced in commit\n>> d8acf37ff7 (\"commit-graph: fix segfault on e.g. \\\"git status\\\"\",\n>> 2019-02-21), currently has no external callers. This function is also\n>> a file-local symbol and could be marked 'static', unless you have plans\n>> for future external calls?\n> \n> Fixing these too. Just missed them. Thanks.\n\nAnd these resulted from running my static-check.pl script.\n\nATB,\nRamsay Jones\n\n"}]}