Skip to content

Commit c2e86ad

Browse files
bebarinogitster
authored andcommitted
Fix sparse warnings
Fix warnings from 'make check'. - These files don't include 'builtin.h' causing sparse to complain that cmd_* isn't declared: builtin/clone.c:364, builtin/fetch-pack.c:797, builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78, builtin/merge-index.c:69, builtin/merge-recursive.c:22 builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426 builtin/notes.c:822, builtin/pack-redundant.c:596, builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149, builtin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25, builtin/var.c:75 - These files have symbols which should be marked static since they're only file scope: submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13, submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79, unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123, url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48 - These files redeclare symbols to be different types: builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571, usage.c:49, usage.c:58, usage.c:63, usage.c:72 - These files use a literal integer 0 when they really should use a NULL pointer: daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362 While we're in the area, clean up some unused #includes in builtin files (mostly exec_cmd.h). Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08c8d55 commit c2e86ad

35 files changed

+43
-48
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Clone a repository into a different directory that does not yet exist.
99
*/
1010

11-
#include "cache.h"
11+
#include "builtin.h"
1212
#include "parse-options.h"
1313
#include "fetch-pack.h"
1414
#include "refs.h"

builtin/fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "builtin.h"
22
#include "refs.h"
33
#include "pkt-line.h"
44
#include "commit.h"

builtin/fmt-merge-msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct src_data {
3131
int head_status;
3232
};
3333

34-
void init_src_data(struct src_data *data)
34+
static void init_src_data(struct src_data *data)
3535
{
3636
data->branch.strdup_strings = 1;
3737
data->tag.strdup_strings = 1;

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) Linus Torvalds, 2005
55
* Copyright (C) Junio C Hamano, 2005
66
*/
7-
#include "cache.h"
7+
#include "builtin.h"
88
#include "blob.h"
99
#include "quote.h"
1010
#include "parse-options.h"

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void parse_pack_header(void)
207207
static NORETURN void bad_object(unsigned long offset, const char *format,
208208
...) __attribute__((format (printf, 2, 3)));
209209

210-
static void bad_object(unsigned long offset, const char *format, ...)
210+
static NORETURN void bad_object(unsigned long offset, const char *format, ...)
211211
{
212212
va_list params;
213213
char buf[1024];

builtin/merge-index.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include "cache.h"
1+
#include "builtin.h"
22
#include "run-command.h"
3-
#include "exec_cmd.h"
43

54
static const char *pgm;
65
static int one_shot, quiet;

builtin/merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "builtin.h"
22
#include "commit.h"
33
#include "tag.h"
44
#include "merge-recursive.h"

builtin/merge-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "builtin.h"
22
#include "tree-walk.h"
33
#include "xdiff-interface.h"
44
#include "blob.h"

builtin/mktag.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include "cache.h"
1+
#include "builtin.h"
22
#include "tag.h"
3-
#include "exec_cmd.h"
43

54
/*
65
* A signature file has a very simple fixed format: four lines

builtin/notes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c)
423423
free(c);
424424
}
425425

426-
int notes_copy_from_stdin(int force, const char *rewrite_cmd)
426+
static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
427427
{
428428
struct strbuf buf = STRBUF_INIT;
429429
struct notes_rewrite_cfg *c = NULL;
@@ -819,7 +819,7 @@ static int merge_commit(struct notes_merge_options *o)
819819
t = xcalloc(1, sizeof(struct notes_tree));
820820
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
821821

822-
o->local_ref = resolve_ref("NOTES_MERGE_REF", sha1, 0, 0);
822+
o->local_ref = resolve_ref("NOTES_MERGE_REF", sha1, 0, NULL);
823823
if (!o->local_ref)
824824
die("Failed to resolve NOTES_MERGE_REF");
825825

0 commit comments

Comments
 (0)