*.[ch]: remove extern from function declarations using sed

There has been a push to remove extern from function declarations. Finish the job by removing all instances of "extern" for function declarations in headers using sed. This was done by running the following on my system with sed 4.2.2: $ git ls-files \*.{c,h} | grep -v ^compat/ | xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/' Files under `compat/` are intentionally excluded as some are directly copied from external sources and we should avoid churning them as much as possible. Then, leftover instances of extern were found by running $ git grep -w -C3 extern \*.{c,h} and manually checking the output. No other instances were found. Note that the regex used specifically excludes function variables which _should_ be left as extern. Not the most elegant way to do it but it gets the job done. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Apr 29, 2019 at 04:28 UTC b199d7147a218c3b10b077f9caad0f207bc34d7a
11 files changed +49 -49
cache.h
+2 -2
@@ -1690,7 +1690,7 @@ extern const char *git_mailmap_blob;
1690 /* IO helper functions */
1691 void maybe_flush_or_die(FILE *, const char *);
1692 __attribute__((format (printf, 2, 3)))
1693 -extern void fprintf_or_die(FILE *, const char *fmt, ...);
1693 +void fprintf_or_die(FILE *, const char *fmt, ...);
1694
1695 #define COPY_READ_ERROR (-2)
1696 #define COPY_WRITE_ERROR (-3)
@@ -1724,7 +1724,7 @@ void write_file_buf(const char *path, const char *buf, size_t len);
1724 * write_file(path, "counter: %d", ctr);
1725 */
1726 __attribute__((format (printf, 2, 3)))
1727 -extern void write_file(const char *path, const char *fmt, ...);
1727 +void write_file(const char *path, const char *fmt, ...);
1728
1729 /* pager.c */
1730 void setup_pager(void);
commit.h
+1 -1
@@ -379,6 +379,6 @@ int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused)
379 int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused);
380
381 LAST_ARG_MUST_BE_NULL
382 -extern int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...);
382 +int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...);
383
384 #endif /* COMMIT_H */
config.h
+1 -1
@@ -265,7 +265,7 @@ struct key_value_info {
265 enum config_scope scope;
266 };
267
268 -extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
268 +NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
269 NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
270
271 #define LOOKUP_CONFIG(mapping, var) \
exec-cmd.h
+1 -1
@@ -10,7 +10,7 @@ void setup_path(void);
10 const char **prepare_git_cmd(struct argv_array *out, const char **argv);
11 int execv_git_cmd(const char **argv); /* NULL terminated */
12 LAST_ARG_MUST_BE_NULL
13 -extern int execl_git_cmd(const char *cmd, ...);
13 +int execl_git_cmd(const char *cmd, ...);
14 char *system_path(const char *path);
15
16 #endif /* GIT_EXEC_CMD_H */
git-compat-util.h
+10 -10
@@ -448,13 +448,13 @@ struct strbuf;
448 /* General helper functions */
449 void vreportf(const char *prefix, const char *err, va_list params);
450 NORETURN void usage(const char *err);
451 -extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
452 -extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
453 -extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
454 -extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
455 -extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
456 -extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
457 -extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
451 +NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
452 +NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
453 +NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
454 +int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
455 +int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
456 +void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
457 +void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
458
459 #ifndef NO_OPENSSL
460 #ifdef APPLE_COMMON_CRYPTO
@@ -769,7 +769,7 @@ FILE *git_fopen(const char*, const char*);
769 #undef snprintf
770 #endif
771 #define snprintf git_snprintf
772 -extern int git_snprintf(char *str, size_t maxsize,
772 +int git_snprintf(char *str, size_t maxsize,
773 const char *format, ...);
774 #ifdef vsnprintf
775 #undef vsnprintf
@@ -855,7 +855,7 @@ void *xrealloc(void *ptr, size_t size);
855 void *xcalloc(size_t nmemb, size_t size);
856 void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
857 void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);
858 -extern int xopen(const char *path, int flags, ...);
858 +int xopen(const char *path, int flags, ...);
859 ssize_t xread(int fd, void *buf, size_t len);
860 ssize_t xwrite(int fd, const void *buf, size_t len);
861 ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
@@ -966,7 +966,7 @@ static inline size_t xsize_t(off_t len)
966 }
967
968 __attribute__((format (printf, 3, 4)))
969 -extern int xsnprintf(char *dst, size_t max, const char *fmt, ...);
969 +int xsnprintf(char *dst, size_t max, const char *fmt, ...);
970
971 #ifndef HOST_NAME_MAX
972 #define HOST_NAME_MAX 256
khash.h
+7 -7
@@ -70,13 +70,13 @@ static const double __ac_HASH_UPPER = 0.77;
70 } kh_##name##_t;
71
72 #define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
73 - extern kh_##name##_t *kh_init_##name(void); \
74 - extern void kh_destroy_##name(kh_##name##_t *h); \
75 - extern void kh_clear_##name(kh_##name##_t *h); \
76 - extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
77 - extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
78 - extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
79 - extern void kh_del_##name(kh_##name##_t *h, khint_t x);
73 + kh_##name##_t *kh_init_##name(void); \
74 + void kh_destroy_##name(kh_##name##_t *h); \
75 + void kh_clear_##name(kh_##name##_t *h); \
76 + khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
77 + int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
78 + khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
79 + void kh_del_##name(kh_##name##_t *h, khint_t x);
80
81 #define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
82 SCOPE kh_##name##_t *kh_init_##name(void) { \
path.h
+15 -15
@@ -13,19 +13,19 @@ struct strbuf;
13 /*
14 * Return a statically allocated path.
15 */
16 -extern const char *mkpath(const char *fmt, ...)
16 +const char *mkpath(const char *fmt, ...)
17 __attribute__((format (printf, 1, 2)));
18
19 /*
20 * Return a path.
21 */
22 -extern char *mkpathdup(const char *fmt, ...)
22 +char *mkpathdup(const char *fmt, ...)
23 __attribute__((format (printf, 1, 2)));
24
25 /*
26 * Construct a path and place the result in the provided buffer `buf`.
27 */
28 -extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
28 +char *mksnpath(char *buf, size_t n, const char *fmt, ...)
29 __attribute__((format (printf, 3, 4)));
30
31 /*
@@ -37,7 +37,7 @@ extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
37 * Constructs a path into the common git directory of repository `repo` and
38 * append it in the provided buffer `sb`.
39 */
40 -extern void strbuf_git_common_path(struct strbuf *sb,
40 +void strbuf_git_common_path(struct strbuf *sb,
41 const struct repository *repo,
42 const char *fmt, ...)
43 __attribute__((format (printf, 3, 4)));
@@ -46,7 +46,7 @@ extern void strbuf_git_common_path(struct strbuf *sb,
46 * Return a statically allocated path into the main repository's
47 * (the_repository) common git directory.
48 */
49 -extern const char *git_common_path(const char *fmt, ...)
49 +const char *git_common_path(const char *fmt, ...)
50 __attribute__((format (printf, 1, 2)));
51
52
@@ -66,7 +66,7 @@ extern const char *git_common_path(const char *fmt, ...)
66 /*
67 * Return a path into the git directory of repository `repo`.
68 */
69 -extern char *repo_git_path(const struct repository *repo,
69 +char *repo_git_path(const struct repository *repo,
70 const char *fmt, ...)
71 __attribute__((format (printf, 2, 3)));
72
@@ -74,7 +74,7 @@ extern char *repo_git_path(const struct repository *repo,
74 * Construct a path into the git directory of repository `repo` and append it
75 * to the provided buffer `sb`.
76 */
77 -extern void strbuf_repo_git_path(struct strbuf *sb,
77 +void strbuf_repo_git_path(struct strbuf *sb,
78 const struct repository *repo,
79 const char *fmt, ...)
80 __attribute__((format (printf, 3, 4)));
@@ -83,13 +83,13 @@ extern void strbuf_repo_git_path(struct strbuf *sb,
83 * Return a statically allocated path into the main repository's
84 * (the_repository) git directory.
85 */
86 -extern const char *git_path(const char *fmt, ...)
86 +const char *git_path(const char *fmt, ...)
87 __attribute__((format (printf, 1, 2)));
88
89 /*
90 * Return a path into the main repository's (the_repository) git directory.
91 */
92 -extern char *git_pathdup(const char *fmt, ...)
92 +char *git_pathdup(const char *fmt, ...)
93 __attribute__((format (printf, 1, 2)));
94
95 /*
@@ -97,14 +97,14 @@ extern char *git_pathdup(const char *fmt, ...)
97 * and place it in the provided buffer `buf`, the contents of the buffer will
98 * be overridden.
99 */
100 -extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
100 +char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
101 __attribute__((format (printf, 2, 3)));
102
103 /*
104 * Construct a path into the main repository's (the_repository) git directory
105 * and append it to the provided buffer `sb`.
106 */
107 -extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
107 +void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
108 __attribute__((format (printf, 2, 3)));
109
110 /*
@@ -112,7 +112,7 @@ extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
112 *
113 * If the repository doesn't have a worktree NULL is returned.
114 */
115 -extern char *repo_worktree_path(const struct repository *repo,
115 +char *repo_worktree_path(const struct repository *repo,
116 const char *fmt, ...)
117 __attribute__((format (printf, 2, 3)));
118
@@ -122,7 +122,7 @@ extern char *repo_worktree_path(const struct repository *repo,
122 *
123 * If the repository doesn't have a worktree nothing will be appended to `sb`.
124 */
125 -extern void strbuf_repo_worktree_path(struct strbuf *sb,
125 +void strbuf_repo_worktree_path(struct strbuf *sb,
126 const struct repository *repo,
127 const char *fmt, ...)
128 __attribute__((format (printf, 3, 4)));
@@ -131,7 +131,7 @@ extern void strbuf_repo_worktree_path(struct strbuf *sb,
131 * Return a path into a submodule's git directory located at `path`. `path`
132 * must only reference a submodule of the main repository (the_repository).
133 */
134 -extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
134 +char *git_pathdup_submodule(const char *path, const char *fmt, ...)
135 __attribute__((format (printf, 2, 3)));
136
137 /*
@@ -139,7 +139,7 @@ extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
139 * append it to the provided buffer `sb`. `path` must only reference a
140 * submodule of the main repository (the_repository).
141 */
142 -extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
142 +int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
143 const char *fmt, ...)
144 __attribute__((format (printf, 3, 4)));
145
quote.h
+1 -1
@@ -31,7 +31,7 @@ struct strbuf;
31
32 void sq_quote_buf(struct strbuf *, const char *src);
33 void sq_quote_argv(struct strbuf *, const char **argv);
34 -extern void sq_quotef(struct strbuf *, const char *fmt, ...);
34 +void sq_quotef(struct strbuf *, const char *fmt, ...);
35
36 /*
37 * These match their non-pretty variants, except that they avoid
run-command.h
+1 -1
@@ -69,7 +69,7 @@ int run_command(struct child_process *);
69 */
70 const char *find_hook(const char *name);
71 LAST_ARG_MUST_BE_NULL
72 -extern int run_hook_le(const char *const *env, const char *name, ...);
72 +int run_hook_le(const char *const *env, const char *name, ...);
73 int run_hook_ve(const char *const *env, const char *name, va_list args);
74
75 #define RUN_COMMAND_NO_STDIN 1
trace.h
+9 -9
@@ -28,23 +28,23 @@ uint64_t trace_performance_enter(void);
28 #ifndef HAVE_VARIADIC_MACROS
29
30 __attribute__((format (printf, 1, 2)))
31 -extern void trace_printf(const char *format, ...);
31 +void trace_printf(const char *format, ...);
32
33 __attribute__((format (printf, 2, 3)))
34 -extern void trace_printf_key(struct trace_key *key, const char *format, ...);
34 +void trace_printf_key(struct trace_key *key, const char *format, ...);
35
36 __attribute__((format (printf, 2, 3)))
37 -extern void trace_argv_printf(const char **argv, const char *format, ...);
37 +void trace_argv_printf(const char **argv, const char *format, ...);
38
39 void trace_strbuf(struct trace_key *key, const struct strbuf *data);
40
41 /* Prints elapsed time (in nanoseconds) if GIT_TRACE_PERFORMANCE is enabled. */
42 __attribute__((format (printf, 2, 3)))
43 -extern void trace_performance(uint64_t nanos, const char *format, ...);
43 +void trace_performance(uint64_t nanos, const char *format, ...);
44
45 /* Prints elapsed time since 'start' if GIT_TRACE_PERFORMANCE is enabled. */
46 __attribute__((format (printf, 2, 3)))
47 -extern void trace_performance_since(uint64_t start, const char *format, ...);
47 +void trace_performance_since(uint64_t start, const char *format, ...);
48
49 __attribute__((format (printf, 1, 2)))
50 void trace_performance_leave(const char *format, ...);
@@ -132,18 +132,18 @@ void trace_performance_leave(const char *format, ...);
132
133 /* backend functions, use non-*fl macros instead */
134 __attribute__((format (printf, 4, 5)))
135 -extern void trace_printf_key_fl(const char *file, int line, struct trace_key *key,
135 +void trace_printf_key_fl(const char *file, int line, struct trace_key *key,
136 const char *format, ...);
137 __attribute__((format (printf, 4, 5)))
138 -extern void trace_argv_printf_fl(const char *file, int line, const char **argv,
138 +void trace_argv_printf_fl(const char *file, int line, const char **argv,
139 const char *format, ...);
140 void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
141 const struct strbuf *data);
142 __attribute__((format (printf, 4, 5)))
143 -extern void trace_performance_fl(const char *file, int line,
143 +void trace_performance_fl(const char *file, int line,
144 uint64_t nanos, const char *fmt, ...);
145 __attribute__((format (printf, 4, 5)))
146 -extern void trace_performance_leave_fl(const char *file, int line,
146 +void trace_performance_leave_fl(const char *file, int line,
147 uint64_t nanos, const char *fmt, ...);
148 static inline int trace_pass_fl(struct trace_key *key)
149 {
worktree.h
+1 -1
@@ -104,7 +104,7 @@ int is_worktree_being_bisected(const struct worktree *wt, const char *target);
104 * Similar to git_path() but can produce paths for a specified
105 * worktree instead of current one
106 */
107 -extern const char *worktree_git_path(const struct worktree *wt,
107 +const char *worktree_git_path(const struct worktree *wt,
108 const char *fmt, ...)
109 __attribute__((format (printf, 2, 3)));
110