Skip to content

Commit b199d71

Browse files
Denton-Lgitster
authored andcommitted
*.[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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5545442 commit b199d71

File tree

11 files changed

+49
-49
lines changed

11 files changed

+49
-49
lines changed

cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ extern const char *git_mailmap_blob;
16901690
/* IO helper functions */
16911691
void maybe_flush_or_die(FILE *, const char *);
16921692
__attribute__((format (printf, 2, 3)))
1693-
extern void fprintf_or_die(FILE *, const char *fmt, ...);
1693+
void fprintf_or_die(FILE *, const char *fmt, ...);
16941694

16951695
#define COPY_READ_ERROR (-2)
16961696
#define COPY_WRITE_ERROR (-3)
@@ -1724,7 +1724,7 @@ void write_file_buf(const char *path, const char *buf, size_t len);
17241724
* write_file(path, "counter: %d", ctr);
17251725
*/
17261726
__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, ...);
17281728

17291729
/* pager.c */
17301730
void setup_pager(void);

commit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,6 @@ int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused)
379379
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused);
380380

381381
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, ...);
383383

384384
#endif /* COMMIT_H */

config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ struct key_value_info {
265265
enum config_scope scope;
266266
};
267267

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)));
269269
NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
270270

271271
#define LOOKUP_CONFIG(mapping, var) \

exec-cmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void setup_path(void);
1010
const char **prepare_git_cmd(struct argv_array *out, const char **argv);
1111
int execv_git_cmd(const char **argv); /* NULL terminated */
1212
LAST_ARG_MUST_BE_NULL
13-
extern int execl_git_cmd(const char *cmd, ...);
13+
int execl_git_cmd(const char *cmd, ...);
1414
char *system_path(const char *path);
1515

1616
#endif /* GIT_EXEC_CMD_H */

git-compat-util.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ struct strbuf;
448448
/* General helper functions */
449449
void vreportf(const char *prefix, const char *err, va_list params);
450450
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)));
458458

459459
#ifndef NO_OPENSSL
460460
#ifdef APPLE_COMMON_CRYPTO
@@ -769,7 +769,7 @@ FILE *git_fopen(const char*, const char*);
769769
#undef snprintf
770770
#endif
771771
#define snprintf git_snprintf
772-
extern int git_snprintf(char *str, size_t maxsize,
772+
int git_snprintf(char *str, size_t maxsize,
773773
const char *format, ...);
774774
#ifdef vsnprintf
775775
#undef vsnprintf
@@ -855,7 +855,7 @@ void *xrealloc(void *ptr, size_t size);
855855
void *xcalloc(size_t nmemb, size_t size);
856856
void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
857857
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, ...);
859859
ssize_t xread(int fd, void *buf, size_t len);
860860
ssize_t xwrite(int fd, const void *buf, size_t len);
861861
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)
966966
}
967967

968968
__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, ...);
970970

971971
#ifndef HOST_NAME_MAX
972972
#define HOST_NAME_MAX 256

khash.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ static const double __ac_HASH_UPPER = 0.77;
7070
} kh_##name##_t;
7171

7272
#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);
8080

8181
#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
8282
SCOPE kh_##name##_t *kh_init_##name(void) { \

path.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ struct strbuf;
1313
/*
1414
* Return a statically allocated path.
1515
*/
16-
extern const char *mkpath(const char *fmt, ...)
16+
const char *mkpath(const char *fmt, ...)
1717
__attribute__((format (printf, 1, 2)));
1818

1919
/*
2020
* Return a path.
2121
*/
22-
extern char *mkpathdup(const char *fmt, ...)
22+
char *mkpathdup(const char *fmt, ...)
2323
__attribute__((format (printf, 1, 2)));
2424

2525
/*
2626
* Construct a path and place the result in the provided buffer `buf`.
2727
*/
28-
extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
28+
char *mksnpath(char *buf, size_t n, const char *fmt, ...)
2929
__attribute__((format (printf, 3, 4)));
3030

3131
/*
@@ -37,7 +37,7 @@ extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
3737
* Constructs a path into the common git directory of repository `repo` and
3838
* append it in the provided buffer `sb`.
3939
*/
40-
extern void strbuf_git_common_path(struct strbuf *sb,
40+
void strbuf_git_common_path(struct strbuf *sb,
4141
const struct repository *repo,
4242
const char *fmt, ...)
4343
__attribute__((format (printf, 3, 4)));
@@ -46,7 +46,7 @@ extern void strbuf_git_common_path(struct strbuf *sb,
4646
* Return a statically allocated path into the main repository's
4747
* (the_repository) common git directory.
4848
*/
49-
extern const char *git_common_path(const char *fmt, ...)
49+
const char *git_common_path(const char *fmt, ...)
5050
__attribute__((format (printf, 1, 2)));
5151

5252

@@ -66,15 +66,15 @@ extern const char *git_common_path(const char *fmt, ...)
6666
/*
6767
* Return a path into the git directory of repository `repo`.
6868
*/
69-
extern char *repo_git_path(const struct repository *repo,
69+
char *repo_git_path(const struct repository *repo,
7070
const char *fmt, ...)
7171
__attribute__((format (printf, 2, 3)));
7272

7373
/*
7474
* Construct a path into the git directory of repository `repo` and append it
7575
* to the provided buffer `sb`.
7676
*/
77-
extern void strbuf_repo_git_path(struct strbuf *sb,
77+
void strbuf_repo_git_path(struct strbuf *sb,
7878
const struct repository *repo,
7979
const char *fmt, ...)
8080
__attribute__((format (printf, 3, 4)));
@@ -83,36 +83,36 @@ extern void strbuf_repo_git_path(struct strbuf *sb,
8383
* Return a statically allocated path into the main repository's
8484
* (the_repository) git directory.
8585
*/
86-
extern const char *git_path(const char *fmt, ...)
86+
const char *git_path(const char *fmt, ...)
8787
__attribute__((format (printf, 1, 2)));
8888

8989
/*
9090
* Return a path into the main repository's (the_repository) git directory.
9191
*/
92-
extern char *git_pathdup(const char *fmt, ...)
92+
char *git_pathdup(const char *fmt, ...)
9393
__attribute__((format (printf, 1, 2)));
9494

9595
/*
9696
* Construct a path into the main repository's (the_repository) git directory
9797
* and place it in the provided buffer `buf`, the contents of the buffer will
9898
* be overridden.
9999
*/
100-
extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
100+
char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
101101
__attribute__((format (printf, 2, 3)));
102102

103103
/*
104104
* Construct a path into the main repository's (the_repository) git directory
105105
* and append it to the provided buffer `sb`.
106106
*/
107-
extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
107+
void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
108108
__attribute__((format (printf, 2, 3)));
109109

110110
/*
111111
* Return a path into the worktree of repository `repo`.
112112
*
113113
* If the repository doesn't have a worktree NULL is returned.
114114
*/
115-
extern char *repo_worktree_path(const struct repository *repo,
115+
char *repo_worktree_path(const struct repository *repo,
116116
const char *fmt, ...)
117117
__attribute__((format (printf, 2, 3)));
118118

@@ -122,7 +122,7 @@ extern char *repo_worktree_path(const struct repository *repo,
122122
*
123123
* If the repository doesn't have a worktree nothing will be appended to `sb`.
124124
*/
125-
extern void strbuf_repo_worktree_path(struct strbuf *sb,
125+
void strbuf_repo_worktree_path(struct strbuf *sb,
126126
const struct repository *repo,
127127
const char *fmt, ...)
128128
__attribute__((format (printf, 3, 4)));
@@ -131,15 +131,15 @@ extern void strbuf_repo_worktree_path(struct strbuf *sb,
131131
* Return a path into a submodule's git directory located at `path`. `path`
132132
* must only reference a submodule of the main repository (the_repository).
133133
*/
134-
extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
134+
char *git_pathdup_submodule(const char *path, const char *fmt, ...)
135135
__attribute__((format (printf, 2, 3)));
136136

137137
/*
138138
* Construct a path into a submodule's git directory located at `path` and
139139
* append it to the provided buffer `sb`. `path` must only reference a
140140
* submodule of the main repository (the_repository).
141141
*/
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,
143143
const char *fmt, ...)
144144
__attribute__((format (printf, 3, 4)));
145145

quote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct strbuf;
3131

3232
void sq_quote_buf(struct strbuf *, const char *src);
3333
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, ...);
3535

3636
/*
3737
* These match their non-pretty variants, except that they avoid

run-command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int run_command(struct child_process *);
6969
*/
7070
const char *find_hook(const char *name);
7171
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, ...);
7373
int run_hook_ve(const char *const *env, const char *name, va_list args);
7474

7575
#define RUN_COMMAND_NO_STDIN 1

trace.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ uint64_t trace_performance_enter(void);
2828
#ifndef HAVE_VARIADIC_MACROS
2929

3030
__attribute__((format (printf, 1, 2)))
31-
extern void trace_printf(const char *format, ...);
31+
void trace_printf(const char *format, ...);
3232

3333
__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, ...);
3535

3636
__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, ...);
3838

3939
void trace_strbuf(struct trace_key *key, const struct strbuf *data);
4040

4141
/* Prints elapsed time (in nanoseconds) if GIT_TRACE_PERFORMANCE is enabled. */
4242
__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, ...);
4444

4545
/* Prints elapsed time since 'start' if GIT_TRACE_PERFORMANCE is enabled. */
4646
__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, ...);
4848

4949
__attribute__((format (printf, 1, 2)))
5050
void trace_performance_leave(const char *format, ...);
@@ -132,18 +132,18 @@ void trace_performance_leave(const char *format, ...);
132132

133133
/* backend functions, use non-*fl macros instead */
134134
__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,
136136
const char *format, ...);
137137
__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,
139139
const char *format, ...);
140140
void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
141141
const struct strbuf *data);
142142
__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,
144144
uint64_t nanos, const char *fmt, ...);
145145
__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,
147147
uint64_t nanos, const char *fmt, ...);
148148
static inline int trace_pass_fl(struct trace_key *key)
149149
{

worktree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int is_worktree_being_bisected(const struct worktree *wt, const char *target);
104104
* Similar to git_path() but can produce paths for a specified
105105
* worktree instead of current one
106106
*/
107-
extern const char *worktree_git_path(const struct worktree *wt,
107+
const char *worktree_git_path(const struct worktree *wt,
108108
const char *fmt, ...)
109109
__attribute__((format (printf, 2, 3)));
110110

0 commit comments

Comments
 (0)