Skip to content

Commit

Permalink
*.[ch]: remove extern from function declarations using sed
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Denton-L authored and gitster committed May 5, 2019
1 parent 5545442 commit b199d71
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ extern const char *git_mailmap_blob;
/* IO helper functions */
void maybe_flush_or_die(FILE *, const char *);
__attribute__((format (printf, 2, 3)))
extern void fprintf_or_die(FILE *, const char *fmt, ...);
void fprintf_or_die(FILE *, const char *fmt, ...);

#define COPY_READ_ERROR (-2)
#define COPY_WRITE_ERROR (-3)
Expand Down Expand Up @@ -1724,7 +1724,7 @@ void write_file_buf(const char *path, const char *buf, size_t len);
* write_file(path, "counter: %d", ctr);
*/
__attribute__((format (printf, 2, 3)))
extern void write_file(const char *path, const char *fmt, ...);
void write_file(const char *path, const char *fmt, ...);

/* pager.c */
void setup_pager(void);
Expand Down
2 changes: 1 addition & 1 deletion commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,6 @@ int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused)
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused);

LAST_ARG_MUST_BE_NULL
extern int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...);
int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...);

#endif /* COMMIT_H */
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct key_value_info {
enum config_scope scope;
};

extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);

#define LOOKUP_CONFIG(mapping, var) \
Expand Down
2 changes: 1 addition & 1 deletion exec-cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void setup_path(void);
const char **prepare_git_cmd(struct argv_array *out, const char **argv);
int execv_git_cmd(const char **argv); /* NULL terminated */
LAST_ARG_MUST_BE_NULL
extern int execl_git_cmd(const char *cmd, ...);
int execl_git_cmd(const char *cmd, ...);
char *system_path(const char *path);

#endif /* GIT_EXEC_CMD_H */
20 changes: 10 additions & 10 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@ struct strbuf;
/* General helper functions */
void vreportf(const char *prefix, const char *err, va_list params);
NORETURN void usage(const char *err);
extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));

#ifndef NO_OPENSSL
#ifdef APPLE_COMMON_CRYPTO
Expand Down Expand Up @@ -769,7 +769,7 @@ FILE *git_fopen(const char*, const char*);
#undef snprintf
#endif
#define snprintf git_snprintf
extern int git_snprintf(char *str, size_t maxsize,
int git_snprintf(char *str, size_t maxsize,
const char *format, ...);
#ifdef vsnprintf
#undef vsnprintf
Expand Down Expand Up @@ -855,7 +855,7 @@ void *xrealloc(void *ptr, size_t size);
void *xcalloc(size_t nmemb, size_t size);
void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);
extern int xopen(const char *path, int flags, ...);
int xopen(const char *path, int flags, ...);
ssize_t xread(int fd, void *buf, size_t len);
ssize_t xwrite(int fd, const void *buf, size_t len);
ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
Expand Down Expand Up @@ -966,7 +966,7 @@ static inline size_t xsize_t(off_t len)
}

__attribute__((format (printf, 3, 4)))
extern int xsnprintf(char *dst, size_t max, const char *fmt, ...);
int xsnprintf(char *dst, size_t max, const char *fmt, ...);

#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 256
Expand Down
14 changes: 7 additions & 7 deletions khash.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ static const double __ac_HASH_UPPER = 0.77;
} kh_##name##_t;

#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
extern kh_##name##_t *kh_init_##name(void); \
extern void kh_destroy_##name(kh_##name##_t *h); \
extern void kh_clear_##name(kh_##name##_t *h); \
extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
extern void kh_del_##name(kh_##name##_t *h, khint_t x);
kh_##name##_t *kh_init_##name(void); \
void kh_destroy_##name(kh_##name##_t *h); \
void kh_clear_##name(kh_##name##_t *h); \
khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
void kh_del_##name(kh_##name##_t *h, khint_t x);

#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
SCOPE kh_##name##_t *kh_init_##name(void) { \
Expand Down
30 changes: 15 additions & 15 deletions path.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ struct strbuf;
/*
* Return a statically allocated path.
*/
extern const char *mkpath(const char *fmt, ...)
const char *mkpath(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));

/*
* Return a path.
*/
extern char *mkpathdup(const char *fmt, ...)
char *mkpathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));

/*
* Construct a path and place the result in the provided buffer `buf`.
*/
extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
char *mksnpath(char *buf, size_t n, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));

/*
Expand All @@ -37,7 +37,7 @@ extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
* Constructs a path into the common git directory of repository `repo` and
* append it in the provided buffer `sb`.
*/
extern void strbuf_git_common_path(struct strbuf *sb,
void strbuf_git_common_path(struct strbuf *sb,
const struct repository *repo,
const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
Expand All @@ -46,7 +46,7 @@ extern void strbuf_git_common_path(struct strbuf *sb,
* Return a statically allocated path into the main repository's
* (the_repository) common git directory.
*/
extern const char *git_common_path(const char *fmt, ...)
const char *git_common_path(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));


Expand All @@ -66,15 +66,15 @@ extern const char *git_common_path(const char *fmt, ...)
/*
* Return a path into the git directory of repository `repo`.
*/
extern char *repo_git_path(const struct repository *repo,
char *repo_git_path(const struct repository *repo,
const char *fmt, ...)
__attribute__((format (printf, 2, 3)));

/*
* Construct a path into the git directory of repository `repo` and append it
* to the provided buffer `sb`.
*/
extern void strbuf_repo_git_path(struct strbuf *sb,
void strbuf_repo_git_path(struct strbuf *sb,
const struct repository *repo,
const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
Expand All @@ -83,36 +83,36 @@ extern void strbuf_repo_git_path(struct strbuf *sb,
* Return a statically allocated path into the main repository's
* (the_repository) git directory.
*/
extern const char *git_path(const char *fmt, ...)
const char *git_path(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));

/*
* Return a path into the main repository's (the_repository) git directory.
*/
extern char *git_pathdup(const char *fmt, ...)
char *git_pathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));

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

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

/*
* Return a path into the worktree of repository `repo`.
*
* If the repository doesn't have a worktree NULL is returned.
*/
extern char *repo_worktree_path(const struct repository *repo,
char *repo_worktree_path(const struct repository *repo,
const char *fmt, ...)
__attribute__((format (printf, 2, 3)));

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

/*
* Construct a path into a submodule's git directory located at `path` and
* append it to the provided buffer `sb`. `path` must only reference a
* submodule of the main repository (the_repository).
*/
extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
const char *fmt, ...)
__attribute__((format (printf, 3, 4)));

Expand Down
2 changes: 1 addition & 1 deletion quote.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct strbuf;

void sq_quote_buf(struct strbuf *, const char *src);
void sq_quote_argv(struct strbuf *, const char **argv);
extern void sq_quotef(struct strbuf *, const char *fmt, ...);
void sq_quotef(struct strbuf *, const char *fmt, ...);

/*
* These match their non-pretty variants, except that they avoid
Expand Down
2 changes: 1 addition & 1 deletion run-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int run_command(struct child_process *);
*/
const char *find_hook(const char *name);
LAST_ARG_MUST_BE_NULL
extern int run_hook_le(const char *const *env, const char *name, ...);
int run_hook_le(const char *const *env, const char *name, ...);
int run_hook_ve(const char *const *env, const char *name, va_list args);

#define RUN_COMMAND_NO_STDIN 1
Expand Down
18 changes: 9 additions & 9 deletions trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ uint64_t trace_performance_enter(void);
#ifndef HAVE_VARIADIC_MACROS

__attribute__((format (printf, 1, 2)))
extern void trace_printf(const char *format, ...);
void trace_printf(const char *format, ...);

__attribute__((format (printf, 2, 3)))
extern void trace_printf_key(struct trace_key *key, const char *format, ...);
void trace_printf_key(struct trace_key *key, const char *format, ...);

__attribute__((format (printf, 2, 3)))
extern void trace_argv_printf(const char **argv, const char *format, ...);
void trace_argv_printf(const char **argv, const char *format, ...);

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

/* Prints elapsed time (in nanoseconds) if GIT_TRACE_PERFORMANCE is enabled. */
__attribute__((format (printf, 2, 3)))
extern void trace_performance(uint64_t nanos, const char *format, ...);
void trace_performance(uint64_t nanos, const char *format, ...);

/* Prints elapsed time since 'start' if GIT_TRACE_PERFORMANCE is enabled. */
__attribute__((format (printf, 2, 3)))
extern void trace_performance_since(uint64_t start, const char *format, ...);
void trace_performance_since(uint64_t start, const char *format, ...);

__attribute__((format (printf, 1, 2)))
void trace_performance_leave(const char *format, ...);
Expand Down Expand Up @@ -132,18 +132,18 @@ void trace_performance_leave(const char *format, ...);

/* backend functions, use non-*fl macros instead */
__attribute__((format (printf, 4, 5)))
extern void trace_printf_key_fl(const char *file, int line, struct trace_key *key,
void trace_printf_key_fl(const char *file, int line, struct trace_key *key,
const char *format, ...);
__attribute__((format (printf, 4, 5)))
extern void trace_argv_printf_fl(const char *file, int line, const char **argv,
void trace_argv_printf_fl(const char *file, int line, const char **argv,
const char *format, ...);
void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
const struct strbuf *data);
__attribute__((format (printf, 4, 5)))
extern void trace_performance_fl(const char *file, int line,
void trace_performance_fl(const char *file, int line,
uint64_t nanos, const char *fmt, ...);
__attribute__((format (printf, 4, 5)))
extern void trace_performance_leave_fl(const char *file, int line,
void trace_performance_leave_fl(const char *file, int line,
uint64_t nanos, const char *fmt, ...);
static inline int trace_pass_fl(struct trace_key *key)
{
Expand Down
2 changes: 1 addition & 1 deletion worktree.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int is_worktree_being_bisected(const struct worktree *wt, const char *target);
* Similar to git_path() but can produce paths for a specified
* worktree instead of current one
*/
extern const char *worktree_git_path(const struct worktree *wt,
const char *worktree_git_path(const struct worktree *wt,
const char *fmt, ...)
__attribute__((format (printf, 2, 3)));

Expand Down

0 comments on commit b199d71

Please sign in to comment.