Sparse: fix some "symbol not declared" warnings (Part 1)
RFC PATCH 3/10 Sparse: fix some "symbol not declared" warnings (Part 1)
The complete warning message reads something like:
symbol 'whatever' was not declared. Should be static?
In this commit, the answer is no; the various cmd_something() functions have been correctly declared in "builtin.h". However, the header file has not been included in the source, which elicits the above warning from sparse.
Also, cmd_for_each_ref(), cmd_fsck() and cmd_merge_file() required some tweaks to their declaration, in order to conform to the correct prototype.
Signed-off-by Ramsay Jones <[email protected]>
--- builtin-bundle.c | 1 + builtin-checkout-index.c | 1 + builtin-fetch--tool.c | 1 + builtin-for-each-ref.c | 3 ++- builtin-fsck.c | 3 ++- builtin-gc.c | 1 + builtin-merge-base.c | 1 + builtin-merge-file.c | 7 ++++--- builtin-pack-refs.c | 1 + builtin-rerere.c | 1 + builtin-runstatus.c | 1 + builtin-show-ref.c | 1 + 12 files changed, 17 insertions(+), 5 deletions(-)
builtin-bundle.c +1 -0
@@ -5,6 +5,7 @@#include "revision.h" #include "list-objects.h" #include "run-command.h" +#include "builtin.h" /* * Basic handler for bundle files to connect repositories via sneakernet.
builtin-checkout-index.c +1 -0
@@ -40,6 +40,7 @@#include "strbuf.h" #include "quote.h" #include "cache-tree.h" +#include "builtin.h" #define CHECKOUT_ALL 4static int line_termination ='\n' ;
builtin-fetch--tool.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "refs.h" #include "commit.h" +#include "builtin.h" #define CHUNK_SIZE 1024
builtin-for-each-ref.c +2 -1
@@ -6,6 +6,7 @@#include "tree.h" #include "blob.h" #include "quote.h" +#include "builtin.h" /* Quoting styles */ #define QUOTE_NONE 0
@@ -796,7 +797,7 @@ static struct ref_sort *default_sort(void)return sort; } -int cmd_for_each_ref (int ac,const char **av,char *prefix) +int cmd_for_each_ref (int ac,const char **av,const char *prefix) {int i, num_refs;const char *format =NULL ;
builtin-fsck.c +2 -1
@@ -7,6 +7,7 @@#include "pack.h" #include "cache-tree.h" #include "tree-walk.h" +#include "builtin.h" #define REACHABLE 0x0001#define SEEN 0x0002
@@ -607,7 +608,7 @@ static const char fsck_usage[] ="git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] " "[--strict] <head-sha1>*]" ; -int cmd_fsck (int argc,char **argv,const char *prefix) +int cmd_fsck (int argc,const char **argv,const char *prefix) {int i, heads;
builtin-gc.c +1 -0
@@ -12,6 +12,7 @@#include "cache.h" #include "run-command.h" +#include "builtin.h" #define FAILED_RUN "failed to run %s"
builtin-merge-base.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "commit.h" +#include "builtin.h" static int show_merge_base (struct commit *rev1,struct commit *rev2,int show_all) {
builtin-merge-file.c +4 -3
@@ -1,13 +1,14 @@#include "cache.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" +#include "builtin.h" static const char merge_file_usage[] ="git merge-file [-p | --stdout] [-q | --quiet] [-L name1 [-L orig [-L name2]]] file1 orig_file file2" ; -int cmd_merge_file (int argc,char **argv,char **envp) +int cmd_merge_file (int argc,const char **argv,const char *prefix) { -char *names[3 ]; +const char *names[3 ];mmfile_t mmfs[3 ];mmbuffer_t result = {NULL ,0 };xpparam_t xpp = {XDF_NEED_MINIMAL };
@@ -47,7 +48,7 @@ int cmd_merge_file(int argc, char **argv, char **envp)free (mmfs[i].ptr);if (ret >=0 ) { -char *filename = argv[1 ]; +const char *filename = argv[1 ];FILE *f = to_stdout ? stdout :fopen (filename,"wb" );if (!f)
builtin-pack-refs.c +1 -0
@@ -2,6 +2,7 @@#include "refs.h" #include "object.h" #include "tag.h" +#include "builtin.h" static const char builtin_pack_refs_usage[] ="git-pack-refs [--all] [--prune | --no-prune]" ;
builtin-rerere.c +1 -0
@@ -2,6 +2,7 @@#include "path-list.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" +#include "builtin.h" #include <time.h>
builtin-runstatus.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "wt-status.h" +#include "builtin.h" extern int wt_status_use_color;
builtin-show-ref.c +1 -0
@@ -3,6 +3,7 @@#include "object.h" #include "tag.h" #include "path-list.h" +#include "builtin.h" static const char show_ref_usage[] ="git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] < ref-list" ;
Signature · 1 line
1.5.2