*.h: remove extern from function declarations
RFC PATCH 1/1 *.h: remove extern from function declarations
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.
This was done by running the following on my system:
$ git ls-files '*.h' | xargs sed -i'' -e 's/^\(\s*\)extern \(.*(\)/\1\2/'
Then, leftover instances of extern were found by running
$ git grep -w extern '*.h'
and manually checking the output. No other instances were found.
Not the most elegant way to do it but it gets the job done.
---
Junio mentioned that there was a push to drop extern from function declarations in headers[1]. I decided to do a mass refactoring so we could get rid of everything at once, although I'm not sure if that's welcome. But I'll send the patch anyway since I already wrote it.
I merged my change with "pu" and these are the files that it conflicts with:
builtin.h
cache.h
config.h
dir.h
http.h
packfile.h
promisor-remote.h
protocol.h
tree-walk.h
Resolution is pretty easy, though:
$ git merge -Xours --no-commit <THIS-BRANCH> $ git ls-files '*.h' | xargs sed -i'' -e 's/^\(\s*\)extern \(.*(\)/\1\2/' $ git commit -a
--- advice.h | 2 +- archive.h | 14 +- bisect.h | 12 +- blame.h | 2 +- branch.h | 12 +- builtin.h | 252 +++++++++++++------------- bulk-checkin.h | 6 +- cache.h | 344 ++++++++++++++++++------------------ checkout.h | 2 +- column.h | 12 +- commit.h | 72 ++++---- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 10 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 28 +-- compat/win32/pthread.h | 6 +- config.h | 184 +++++++++---------- connect.h | 20 +-- csum-file.h | 20 +-- decorate.h | 4 +- delta.h | 6 +- dir.h | 70 ++++---- exec-cmd.h | 16 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 132 +++++++------- grep.h | 22 +-- hashmap.h | 30 ++-- help.h | 30 ++-- http.h | 52 +++--- khash.h | 14 +- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 10 +- ls-refs.h | 2 +- mailinfo.h | 6 +- merge-blobs.h | 2 +- object-store.h | 16 +- object.h | 12 +- oidmap.h | 10 +- pack.h | 24 +-- packfile.h | 76 ++++---- path.h | 32 ++-- pkt-line.h | 6 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 32 ++-- reachable.h | 4 +- reflog-walk.h | 16 +- refs.h | 2 +- remote.h | 12 +- replace-object.h | 2 +- resolve-undo.h | 14 +- run-command.h | 8 +- serve.h | 4 +- sha1-lookup.h | 2 +- streaming.h | 8 +- string-list.h | 2 +- sub-process.h | 2 +- submodule-config.h | 20 +-- tag.h | 14 +- tempfile.h | 26 +-- trace.h | 34 ++-- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 4 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 2 +- worktree.h | 22 +-- xdiff-interface.h | 10 +- 76 files changed, 963 insertions(+), 963 deletions(-)
advice.h +1 -1
@@ -31,7 +31,7 @@ int git_default_advice_config(const char *var, const char *value); __attribute__((format (printf,1 ,2 )))void advise (const char *advice, ...);int error_resolve_conflict (const char *me); -extern void NORETURN die_resolve_conflict(const char *me); +void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void);void detach_advice (const char *new_name);
archive.h +7 -7
@@ -23,7 +23,7 @@ struct archiver_args {/* main api */ -extern int write_archive (int argc,const char **argv,const char *prefix, +int write_archive (int argc,const char **argv,const char *prefix,struct repository *repo,const char *name_hint,int remote);
@@ -39,19 +39,19 @@ struct archiver {unsigned flags;void *data; }; -extern void register_archiver (struct archiver *); +void register_archiver (struct archiver *); -extern void init_tar_archiver (void ); -extern void init_zip_archiver (void ); -extern void init_archivers (void ); +void init_tar_archiver (void ); +void init_zip_archiver (void ); +void init_archivers (void );typedef int (*write_archive_entry_fn_t )(struct archiver_args *args,const struct object_id *oid,const char *path,size_t pathlen,unsigned int mode); -extern int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); -extern void *object_file_to_archive (const struct archiver_args *args, +int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); +void *object_file_to_archive (const struct archiver_args *args,const char *path,const struct object_id *oid,unsigned int mode,enum object_type *type,unsigned long *sizep);
bisect.h +6 -6
@@ -11,10 +11,10 @@ struct repository;* Otherwise, it will be either all non-SAMETREE commits or the single * best commit, as chosen by `find_all`. */ -extern void find_bisection (struct commit_list **list,int *reaches,int *all, +void find_bisection (struct commit_list **list,int *reaches,int *all,int find_all); -extern struct commit_list *filter_skipped(struct commit_list *list, +struct commit_list *filter_skipped(struct commit_list *list, struct commit_list **tried, int show_all, int *count,
@@ -31,14 +31,14 @@ struct rev_list_info { const char *header_prefix; }; -extern int bisect_next_all (struct repository *r, +int bisect_next_all (struct repository *r,const char *prefix,int no_checkout); -extern int estimate_bisect_steps (int all); +int estimate_bisect_steps (int all); -extern void read_bisect_terms (const char **bad,const char **good); +void read_bisect_terms (const char **bad,const char **good); -extern int bisect_clean_state (void ); +int bisect_clean_state (void );#endif
blame.h +1 -1
@@ -177,6 +177,6 @@ struct blame_entry *blame_entry_prepend(struct blame_entry *head, long start, long end, struct blame_origin *o); -extern struct blame_origin *get_blame_suspects (struct commit *commit); +struct blame_origin *get_blame_suspects (struct commit *commit);#endif /* BLAME_H */
branch.h +6 -6
@@ -50,7 +50,7 @@ void create_branch(struct repository *r,* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_branchname (const char *name,struct strbuf *ref); +int validate_branchname (const char *name,struct strbuf *ref);/* * Check if a branch 'name' can be created as a new branch; die otherwise.
@@ -58,7 +58,7 @@ extern int validate_branchname(const char *name, struct strbuf *ref);* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_new_branchname (const char *name,struct strbuf *ref,int force); +int validate_new_branchname (const char *name,struct strbuf *ref,int force);/* * Remove information about the state of working on the current
@@ -72,26 +72,26 @@ void remove_branch_state(struct repository *r);* Returns 0 on success. */ #define BRANCH_CONFIG_VERBOSE 01 -extern int install_branch_config (int flag,const char *local,const char *origin,const char *remote); +int install_branch_config (int flag,const char *local,const char *origin,const char *remote);/* * Read branch description */ -extern int read_branch_desc (struct strbuf *,const char *branch_name); +int read_branch_desc (struct strbuf *,const char *branch_name);/* * Check if a branch is checked out in the main worktree or any linked * worktree and die (with a message describing its checkout location) if * it is. */ -extern void die_if_checked_out (const char *branch,int ignore_current_worktree); +void die_if_checked_out (const char *branch,int ignore_current_worktree);/* * Update all per-worktree HEADs pointing at the old ref to point the new ref. * This will be used when renaming a branch. Returns 0 if successful, non-zero * otherwise. */ -extern int replace_each_worktree_head_symref (const char *oldref,const char *newref, +int replace_each_worktree_head_symref (const char *oldref,const char *newref,const char *logmsg);#endif
builtin.h +126 -126
271 lines not on this page · raw message
bulk-checkin.h +3 -3
@@ -6,11 +6,11 @@#include "cache.h" -extern int index_bulk_checkin (struct object_id *oid, +int index_bulk_checkin (struct object_id *oid,int fd,size_t size,enum object_type type,const char *path,unsigned flags); -extern void plug_bulk_checkin (void ); -extern void unplug_bulk_checkin (void ); +void plug_bulk_checkin (void ); +void unplug_bulk_checkin (void );#endif
cache.h +172 -172
668 lines not on this page · raw message
checkout.h +1 -1
@@ -8,7 +8,7 @@* tracking branch. Return the name of the remote if such a branch * exists, NULL otherwise. */ -extern const char *unique_tracking_name (const char *name, +const char *unique_tracking_name (const char *name,struct object_id *oid,int *dwim_remotes_matched);
column.h +6 -6
@@ -27,20 +27,20 @@ struct column_options { };struct option ; -extern int parseopt_column_callback (const struct option *,const char *,int ); -extern int git_column_config (const char *var,const char *value, +int parseopt_column_callback (const struct option *,const char *,int ); +int git_column_config (const char *var,const char *value,const char *command,unsigned int *colopts); -extern int finalize_colopts (unsigned int *colopts,int stdout_is_tty); +int finalize_colopts (unsigned int *colopts,int stdout_is_tty);static inline int column_active (unsigned int colopts) {return (colopts &COL_ENABLE_MASK ) ==COL_ENABLED ; }struct string_list ; -extern void print_columns (const struct string_list *list,unsigned int colopts, +void print_columns (const struct string_list *list,unsigned int colopts,const struct column_options *opts); -extern int run_column_filter (int colopts,const struct column_options *); -extern int stop_column_filter (void ); +int run_column_filter (int colopts,const struct column_options *); +int stop_column_filter (void );#endif
commit.h +36 -36
162 lines not on this page · raw message
compat/mingw.h +3 -3
@@ -11,7 +11,7 @@ typedef _sigset_t sigset_t;#undef _POSIX_THREAD_SAFE_FUNCTIONS#endif -extern int mingw_core_config (const char *var,const char *value,void *cb); +int mingw_core_config (const char *var,const char *value,void *cb);#define platform_core_config mingw_core_config/*
@@ -449,7 +449,7 @@ static inline void convert_slashes(char *path) *path ='/' ; }#define PATH_SEP ';' -extern char *mingw_query_user_email (void ); +char *mingw_query_user_email (void );#define query_user_email mingw_query_user_email#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"
@@ -586,4 +586,4 @@ static int mingw_main(c,v)/* * Used by Pthread API implementation for Windows */ -extern int err_win_to_posix (DWORD winerr); +int err_win_to_posix (DWORD winerr);
compat/nedmalloc/malloc.c.h +3 -3
@@ -1327,7 +1327,7 @@ int mspace_mallopt(int, int);#include <unistd.h> /* for sbrk, sysconf */ #else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void *sbrk (ptrdiff_t ); +void *sbrk (ptrdiff_t );#endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */
@@ -1444,7 +1444,7 @@ unsigned char _BitScanReverse(unsigned long *index, unsigned long mask);# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)# else # if defined(BSD ) || defined(DGUX ) || defined(HAVE_GETPAGESIZE ) -extern size_t getpagesize (); +size_t getpagesize ();# define malloc_getpagesize getpagesize()# else # ifdef WIN32 /* use supplied emulation of getpagesize */
@@ -1899,7 +1899,7 @@ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER;/* skipped internal declaration from pthread.h */ #ifdef linux#ifndef PTHREAD_MUTEX_RECURSIVE -extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, +int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, int __kind));#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP#define pthread_mutexattr_settype (x,y) pthread_mutexattr_setkind_np(x,y)
compat/obstack.h +5 -5
@@ -182,13 +182,13 @@ struct obstack /* control current object in current chunk *//* Declare the external functions we use; they are in obstack.c. */ -extern void _obstack_newchunk (struct obstack *,int ); -extern int _obstack_begin (struct obstack *,int ,int , +void _obstack_newchunk (struct obstack *,int ); +int _obstack_begin (struct obstack *,int ,int ,void *(*) (long ),void (*) (void *)); -extern int _obstack_begin_1 (struct obstack *,int ,int , +int _obstack_begin_1 (struct obstack *,int ,int ,void *(*) (void *,long ),void (*) (void *,void *),void *); -extern int _obstack_memory_used (struct obstack *); +int _obstack_memory_used (struct obstack *);void obstack_free (struct obstack *,void *);
@@ -197,7 +197,7 @@ void obstack_free (struct obstack *, void *);more memory. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ -extern void (*obstack_alloc_failed_handler) (void ); +void (*obstack_alloc_failed_handler) (void );/* Pointer to beginning of object being allocated or to be allocated next. Note that this might not be the final address of the object
compat/poll/poll.h +1 -1
@@ -57,7 +57,7 @@ struct pollfdtypedef unsigned long nfds_t ; -extern int poll (struct pollfd *pfd,nfds_t nfd,int timeout); +int poll (struct pollfd *pfd,nfds_t nfd,int timeout);/* Define INFTIM only if doing so conforms to POSIX. */ #if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
compat/regex/regex.h +14 -14
@@ -465,19 +465,19 @@ typedef struct#ifdef __USE_GNU/* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); +reg_syntax_t re_set_syntax (reg_syntax_t __syntax);/* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern (const char *__pattern,size_t __length, +const char *re_compile_pattern (const char *__pattern,size_t __length,struct re_pattern_buffer *__buffer);/* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); +int re_compile_fastmap (struct re_pattern_buffer *__buffer);/* Search in the string STRING (with length LENGTH) for the pattern
@@ -485,14 +485,14 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search (struct re_pattern_buffer *__buffer,const char *__cstring, +int re_search (struct re_pattern_buffer *__buffer,const char *__cstring,int __length,int __start,int __range,struct re_registers *__regs);/* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 (struct re_pattern_buffer *__buffer, +int re_search_2 (struct re_pattern_buffer *__buffer,const char *__string1,int __length1,const char *__string2,int __length2,int __start,int __range,struct re_registers *__regs,int __stop);
@@ -500,12 +500,12 @@ extern int re_search_2 (struct re_pattern_buffer *__buffer,/* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern int re_match (struct re_pattern_buffer *__buffer,const char *__cstring, +int re_match (struct re_pattern_buffer *__buffer,const char *__cstring,int __length,int __start,struct re_registers *__regs);/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 (struct re_pattern_buffer *__buffer, +int re_match_2 (struct re_pattern_buffer *__buffer,const char *__string1,int __length1,const char *__string2,int __length2,int __start,struct re_registers *__regs,int __stop);
@@ -523,7 +523,7 @@ extern int re_match_2 (struct re_pattern_buffer *__buffer,Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ -extern void re_set_registers (struct re_pattern_buffer *__buffer, +void re_set_registers (struct re_pattern_buffer *__buffer,struct re_registers *__regs,unsigned int __num_regs,regoff_t *__starts,regoff_t *__ends);
@@ -532,8 +532,8 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)# ifndef _CRAY/* 4.2 bsd compatibility. */ -extern char *re_comp (const char *); -extern int re_exec (const char *); +char *re_comp (const char *); +int re_exec (const char *);# endif #endif
@@ -559,19 +559,19 @@ extern int re_exec (const char *);#endif /* POSIX compatibility. */ -extern int regcomp (regex_t *__restrict __preg, +int regcomp (regex_t *__restrict __preg,const char *__restrict __pattern,int __cflags); -extern int regexec (const regex_t *__restrict __preg, +int regexec (const regex_t *__restrict __preg,const char *__restrict __cstring,size_t __nmatch,regmatch_t __pmatch[__restrict_arr],int __eflags); -extern size_t regerror (int __errcode,const regex_t *__restrict __preg, +size_t regerror (int __errcode,const regex_t *__restrict __preg,char *__restrict __errbuf,size_t __errbuf_size); -extern void regfree (regex_t *__preg); +void regfree (regex_t *__preg);#ifdef __cplusplus
compat/win32/pthread.h +3 -3
@@ -50,7 +50,7 @@ typedef struct {DWORD tid; } pthread_t; -extern int pthread_create (pthread_t *thread,const void *unused, +int pthread_create (pthread_t *thread,const void *unused,void *(*start_routine)(void *),void *arg);/*
@@ -59,10 +59,10 @@ extern int pthread_create(pthread_t *thread, const void *unused,*/ #define pthread_join (a, b) win32_pthread_join(&(a), (b)) -extern int win32_pthread_join (pthread_t *thread,void **value_ptr); +int win32_pthread_join (pthread_t *thread,void **value_ptr);#define pthread_equal (t1, t2) ((t1).tid == (t2).tid) -extern pthread_t pthread_self (void ); +pthread_t pthread_self (void ); static inline void NORETURN pthread_exit(void *ret) {
config.h +92 -92
256 lines not on this page · raw message
connect.h +10 -10
@@ -7,19 +7,19 @@#define CONNECT_DIAG_URL (1u << 1)#define CONNECT_IPV4 (1u << 2)#define CONNECT_IPV6 (1u << 3) -extern struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); -extern int finish_connect (struct child_process *conn); -extern int git_connection_is_socket (struct child_process *conn); -extern int server_supports (const char *feature); -extern int parse_feature_request (const char *features,const char *feature); -extern const char *server_feature_value (const char *feature,int *len_ret); -extern int url_is_local_not_ssh (const char *url); +struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); +int finish_connect (struct child_process *conn); +int git_connection_is_socket (struct child_process *conn); +int server_supports (const char *feature); +int parse_feature_request (const char *features,const char *feature); +const char *server_feature_value (const char *feature,int *len_ret); +int url_is_local_not_ssh (const char *url);struct packet_reader ; -extern enum protocol_version discover_version (struct packet_reader *reader); +enum protocol_version discover_version (struct packet_reader *reader); -extern int server_supports_v2 (const char *c,int die_on_error); -extern int server_supports_feature (const char *c,const char *feature, +int server_supports_v2 (const char *c,int die_on_error); +int server_supports_feature (const char *c,const char *feature,int die_on_error);#endif
csum-file.h +10 -10
@@ -25,22 +25,22 @@ struct hashfile_checkpoint {git_hash_ctx ctx; }; -extern void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); -extern int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *); +void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); +int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *);/* finalize_hashfile flags */ #define CSUM_CLOSE 1#define CSUM_FSYNC 2#define CSUM_HASH_IN_STREAM 4 -extern struct hashfile *hashfd (int fd,const char *name); -extern struct hashfile *hashfd_check (const char *name); -extern struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); -extern int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); -extern void hashwrite (struct hashfile *,const void *,unsigned int ); -extern void hashflush (struct hashfile *f); -extern void crc32_begin (struct hashfile *); -extern uint32_t crc32_end (struct hashfile *); +struct hashfile *hashfd (int fd,const char *name); +struct hashfile *hashfd_check (const char *name); +struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); +int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); +void hashwrite (struct hashfile *,const void *,unsigned int ); +void hashflush (struct hashfile *f); +void crc32_begin (struct hashfile *); +uint32_t crc32_end (struct hashfile *);static inline void hashwrite_u8 (struct hashfile *f,uint8_t data) {
decorate.h +2 -2
@@ -50,12 +50,12 @@ struct decoration {* NULL), returning the previously associated pointer. If there is no previous * association, this function returns NULL. */ -extern void *add_decoration (struct decoration *n,const struct object *obj,void *decoration); +void *add_decoration (struct decoration *n,const struct object *obj,void *decoration);/* * Return the pointer associated to the given object. If there is no * association, this function returns NULL. */ -extern void *lookup_decoration (struct decoration *n,const struct object *obj); +void *lookup_decoration (struct decoration *n,const struct object *obj);#endif
delta.h +3 -3
@@ -21,14 +21,14 @@ create_delta_index(const void *buf, unsigned long bufsize);* * Given pointer must be what create_delta_index() returned, or NULL. */ -extern void free_delta_index (struct delta_index *index); +void free_delta_index (struct delta_index *index);/* * sizeof_delta_index: returns memory usage of delta index * * Given pointer must be what create_delta_index() returned, or NULL. */ -extern unsigned long sizeof_delta_index (struct delta_index *index); +unsigned long sizeof_delta_index (struct delta_index *index);/* * create_delta: create a delta from given index for the given buffer
@@ -75,7 +75,7 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,* *trg_bufsize is updated with its size. On failure a NULL pointer is * returned. The returned buffer must be freed by the caller. */ -extern void *patch_delta (const void *src_buf,unsigned long src_size, +void *patch_delta (const void *src_buf,unsigned long src_size,const void *delta_buf,unsigned long delta_size,unsigned long *dst_size);
dir.h +35 -35
145 lines not on this page · raw message
exec-cmd.h +8 -8
@@ -3,14 +3,14 @@struct argv_array ; -extern void git_set_exec_path (const char *exec_path); -extern void git_resolve_executable_dir (const char *path); -extern const char *git_exec_path (void ); -extern void setup_path (void ); -extern const char **prepare_git_cmd (struct argv_array *out,const char **argv); -extern int execv_git_cmd (const char **argv);/* NULL terminated */ +void git_set_exec_path (const char *exec_path); +void git_resolve_executable_dir (const char *path); +const char *git_exec_path (void ); +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, ...); -extern char *system_path (const char *path); +int execl_git_cmd(const char *cmd, ...); +char *system_path (const char *path);#endif /* GIT_EXEC_CMD_H */
fmt-merge-msg.h +1 -1
@@ -2,6 +2,6 @@#define FMT_MERGE_MSG_H extern int merge_log_config; -extern int fmt_merge_msg_config (const char *key,const char *value,void *cb); +int fmt_merge_msg_config (const char *key,const char *value,void *cb);#endif /* FMT_MERGE_MSG_H */
fsmonitor.h +7 -7
@@ -10,31 +10,31 @@ extern struct trace_key trace_fsmonitor;* Read the fsmonitor index extension and (if configured) restore the * CE_FSMONITOR_VALID state. */ -extern int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz); +int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz);/* * Fill the fsmonitor_dirty ewah bits with their state from the index, * before it is split during writing. */ -extern void fill_fsmonitor_bitmap (struct index_state *istate); +void fill_fsmonitor_bitmap (struct index_state *istate);/* * Write the CE_FSMONITOR_VALID state into the fsmonitor index * extension. Reads from the fsmonitor_dirty ewah in the index. */ -extern void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate); +void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate);/* * Add/remove the fsmonitor index extension */ -extern void add_fsmonitor (struct index_state *istate); -extern void remove_fsmonitor (struct index_state *istate); +void add_fsmonitor (struct index_state *istate); +void remove_fsmonitor (struct index_state *istate);/* * Add/remove the fsmonitor index extension as necessary based on the current * core.fsmonitor setting. */ -extern void tweak_fsmonitor (struct index_state *istate); +void tweak_fsmonitor (struct index_state *istate);/* * Run the configured fsmonitor integration script and clear the
@@ -42,7 +42,7 @@ extern void tweak_fsmonitor(struct index_state *istate);* any corresponding untracked cache directory structures. Optimized to only * run the first time it is called. */ -extern void refresh_fsmonitor (struct index_state *istate); +void refresh_fsmonitor (struct index_state *istate);/* * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
gettext.h +4 -4
@@ -28,11 +28,11 @@#define FORMAT_PRESERVING (n) __attribute__((format_arg(n))) -extern int use_gettext_poison (void ); +int use_gettext_poison (void );#ifndef NO_GETTEXT -extern void git_setup_gettext (void ); -extern int gettext_width (const char *s); +void git_setup_gettext (void ); +int gettext_width (const char *s);#else static inline void git_setup_gettext (void ) {
@@ -87,6 +87,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)#endif const char *get_preferred_languages (void ); -extern int is_utf8_locale (void ); +int is_utf8_locale (void );#endif
git-compat-util.h +66 -66
273 lines not on this page · raw message
grep.h +11 -11
@@ -186,17 +186,17 @@ struct grep_opt {void *output_priv; }; -extern void init_grep_defaults (struct repository *); -extern int grep_config (const char *var,const char *value,void *); -extern void grep_init (struct grep_opt *,struct repository *repo,const char *prefix); +void init_grep_defaults (struct repository *); +int grep_config (const char *var,const char *value,void *); +void grep_init (struct grep_opt *,struct repository *repo,const char *prefix);void grep_commit_pattern_type (enum grep_pattern_type ,struct grep_opt *opt); -extern void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); -extern void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); -extern void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); -extern void compile_grep_patterns (struct grep_opt *opt); -extern void free_grep_patterns (struct grep_opt *opt); -extern int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size); +void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); +void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); +void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); +void compile_grep_patterns (struct grep_opt *opt); +void free_grep_patterns (struct grep_opt *opt); +int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size);struct grep_source {char *name;
@@ -226,8 +226,8 @@ void grep_source_load_driver(struct grep_source *gs,int grep_source (struct grep_opt *opt,struct grep_source *gs); -extern struct grep_opt *grep_opt_dup (const struct grep_opt *opt); -extern int grep_threads_ok (const struct grep_opt *opt); +struct grep_opt *grep_opt_dup (const struct grep_opt *opt); +int grep_threads_ok (const struct grep_opt *opt);/* * Mutex used around access to the attributes machinery if
hashmap.h +15 -15
@@ -104,11 +104,11 @@* `memihash_cont` is a variant of `memihash` that allows a computation to be * continued with another chunk of data. */ -extern unsigned int strhash (const char *buf); -extern unsigned int strihash (const char *buf); -extern unsigned int memhash (const void *buf,size_t len); -extern unsigned int memihash (const void *buf,size_t len); -extern unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len); +unsigned int strhash (const char *buf); +unsigned int strihash (const char *buf); +unsigned int memhash (const void *buf,size_t len); +unsigned int memihash (const void *buf,size_t len); +unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len);/* * Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code
@@ -216,7 +216,7 @@ struct hashmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void hashmap_init (struct hashmap *map, +void hashmap_init (struct hashmap *map,hashmap_cmp_fn equals_function,const void *equals_function_data,size_t initial_size);
@@ -227,7 +227,7 @@ extern void hashmap_init(struct hashmap *map,* If `free_entries` is true, each hashmap_entry in the map is freed as well * using stdlibs free(). */ -extern void hashmap_free (struct hashmap *map,int free_entries); +void hashmap_free (struct hashmap *map,int free_entries);/* hashmap_entry functions */
@@ -284,7 +284,7 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)* If an entry with matching hash code is found, `key` and `keydata` are passed * to `hashmap_cmp_fn` to decide whether the entry matches the key. */ -extern void *hashmap_get (const struct hashmap *map,const void *key, +void *hashmap_get (const struct hashmap *map,const void *key,const void *keydata);/*
@@ -316,7 +316,7 @@ static inline void *hashmap_get_from_hash(const struct hashmap *map,* `entry` is the hashmap_entry to start the search from, obtained via a previous * call to `hashmap_get` or `hashmap_get_next`. */ -extern void *hashmap_get_next (const struct hashmap *map,const void *entry); +void *hashmap_get_next (const struct hashmap *map,const void *entry);/* * Adds a hashmap entry. This allows to add duplicate entries (i.e.
@@ -325,7 +325,7 @@ extern void *hashmap_get_next(const struct hashmap *map, const void *entry);* `map` is the hashmap structure. * `entry` is the entry to add. */ -extern void hashmap_add (struct hashmap *map,void *entry); +void hashmap_add (struct hashmap *map,void *entry);/* * Adds or replaces a hashmap entry. If the hashmap contains duplicate
@@ -335,7 +335,7 @@ extern void hashmap_add(struct hashmap *map, void *entry);* `entry` is the entry to add or replace. * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *hashmap_put (struct hashmap *map,void *entry); +void *hashmap_put (struct hashmap *map,void *entry);/* * Removes a hashmap entry matching the specified key. If the hashmap contains
@@ -344,7 +344,7 @@ extern void *hashmap_put(struct hashmap *map, void *entry);* * Argument explanation is the same as in `hashmap_get`. */ -extern void *hashmap_remove (struct hashmap *map,const void *key, +void *hashmap_remove (struct hashmap *map,const void *key,const void *keydata);/*
@@ -365,10 +365,10 @@ struct hashmap_iter { };/* Initializes a `hashmap_iter` structure. */ -extern void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter); +void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter);/* Returns the next hashmap_entry, or NULL if there are no more entries. */ -extern void *hashmap_iter_next (struct hashmap_iter *iter); +void *hashmap_iter_next (struct hashmap_iter *iter);/* Initializes the iterator and returns the first entry, if any. */ static inline void *hashmap_iter_first(struct hashmap *map,
@@ -429,7 +429,7 @@ static inline void hashmap_enable_item_counting(struct hashmap *map)* * Uses a hashmap to store the pool of interned strings. */ -extern const void *memintern (const void *data,size_t len); +const void *memintern (const void *data,size_t len);static inline const char *strintern (const char *string) {return memintern (string,strlen (string));
help.h +15 -15
@@ -19,31 +19,31 @@ static inline void mput_char(char c, unsigned int num)putchar (c); } -extern void list_common_cmds_help (void ); -extern void list_all_cmds_help (void ); -extern void list_common_guides_help (void ); -extern void list_config_help (int for_human); +void list_common_cmds_help (void ); +void list_all_cmds_help (void ); +void list_common_guides_help (void ); +void list_config_help (int for_human); -extern void list_all_main_cmds (struct string_list *list); -extern void list_all_other_cmds (struct string_list *list); -extern void list_cmds_by_category (struct string_list *list, +void list_all_main_cmds (struct string_list *list); +void list_all_other_cmds (struct string_list *list); +void list_cmds_by_category (struct string_list *list,const char *category); -extern void list_cmds_by_config (struct string_list *list); -extern const char *help_unknown_cmd (const char *cmd); -extern void load_command_list (const char *prefix, +void list_cmds_by_config (struct string_list *list); +const char *help_unknown_cmd (const char *cmd); +void load_command_list (const char *prefix,struct cmdnames *main_cmds,struct cmdnames *other_cmds); -extern void add_cmdname (struct cmdnames *cmds,const char *name,int len); +void add_cmdname (struct cmdnames *cmds,const char *name,int len);/* Here we require that excludes is a sorted list. */ -extern void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); -extern int is_in_cmdlist (struct cmdnames *cmds,const char *name); -extern void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds); +void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); +int is_in_cmdlist (struct cmdnames *cmds,const char *name); +void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds);/* * call this to die(), when it is suspected that the user mistyped a * ref to the command, to give suggested "correct" refs. */ -extern void help_unknown_ref (const char *ref,const char *cmd,const char *error); +void help_unknown_ref (const char *ref,const char *cmd,const char *error); static inline void list_config_item(struct string_list *list, const char *prefix,
http.h +26 -26
101 lines not on this page · raw message
khash.h +7 -7
@@ -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) { \
kwset.h +5 -5
@@ -37,16 +37,16 @@ typedef struct kwset_t* kwset_t;if enough memory cannot be obtained. The argument if non-NULL specifies a table of character translations to be applied to all pattern and search text. */ -extern kwset_t kwsalloc (unsigned char const *); +kwset_t kwsalloc (unsigned char const *);/* Incrementally extend the keyword set to include the given string. Return NULL for success, or an error message. Remember an index number for each keyword included in the set. */ -extern const char *kwsincr (kwset_t ,char const *,size_t ); +const char *kwsincr (kwset_t ,char const *,size_t );/* When the keyword set has been completely built, prepare it for use. Return NULL for success, or an error message. */ -extern const char *kwsprep (kwset_t ); +const char *kwsprep (kwset_t );/* Search through the given buffer for a member of the keyword set. Return a pointer to the leftmost longest match found, or NULL if
@@ -54,8 +54,8 @@ extern const char *kwsprep(kwset_t);the matching substring in the integer it points to. Similarly, if foundindex is non-NULL, store the index of the particular keyword found therein. */ -extern size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *); +size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *);/* Deallocate the given keyword set and all its associated storage. */ -extern void kwsfree (kwset_t ); +void kwsfree (kwset_t );
line-log.h +8 -8
@@ -25,17 +25,17 @@ struct diff_ranges {struct range_set target; }; -extern void range_set_init (struct range_set *,size_t prealloc); -extern void range_set_release (struct range_set *); +void range_set_init (struct range_set *,size_t prealloc); +void range_set_release (struct range_set *);/* Range includes start; excludes end */ -extern void range_set_append_unsafe (struct range_set *,long start,long end); +void range_set_append_unsafe (struct range_set *,long start,long end);/* New range must begin at or after end of last added range */ -extern void range_set_append (struct range_set *,long start,long end); +void range_set_append (struct range_set *,long start,long end);/* * In-place pass of sorting and merging the ranges in the range set, * to sort and make the ranges disjoint. */ -extern void sort_and_merge_range_set (struct range_set *); +void sort_and_merge_range_set (struct range_set *);/* Linked list of interesting files and their associated ranges. The * list must be kept sorted by path.
@@ -54,10 +54,10 @@ struct line_log_data { struct diff_ranges diff; }; -extern void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); +void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); -extern int line_log_filter (struct rev_info *rev); +int line_log_filter (struct rev_info *rev); -extern int line_log_print (struct rev_info *rev,struct commit *commit); +int line_log_print (struct rev_info *rev,struct commit *commit);#endif /* LINE_LOG_H */
lockfile.h +5 -5
@@ -159,7 +159,7 @@ struct lock_file {* timeout_ms is -1, retry indefinitely. The flags argument and error * handling are described above. */ -extern int hold_lock_file_for_update_timeout ( +int hold_lock_file_for_update_timeout (struct lock_file *lk,const char *path,int flags,long timeout_ms);
@@ -188,7 +188,7 @@ static inline int is_lock_file_locked(struct lock_file *lk)* of `hold_lock_file_for_update()` to lock `path`. `err` should be the * `errno` set by the failing call. */ -extern void unable_to_lock_message (const char *path,int err, +void unable_to_lock_message (const char *path,int err,struct strbuf *buf);/*
@@ -197,7 +197,7 @@ extern void unable_to_lock_message(const char *path, int err,* `errno` set by the failing * call. */ -extern NORETURN void unable_to_lock_die(const char *path, int err); +NORETURN void unable_to_lock_die(const char *path, int err);/* * Associate a stdio stream with the lockfile (which must still be
@@ -234,7 +234,7 @@ static inline FILE *get_lock_file_fp(struct lock_file *lk)* Return the path of the file that is locked by the specified * lock_file object. The caller must free the memory. */ -extern char *get_locked_file_path (struct lock_file *lk); +char *get_locked_file_path (struct lock_file *lk);/* * If the lockfile is still open, close it (and the file pointer if it
@@ -282,7 +282,7 @@ static inline int reopen_lock_file(struct lock_file *lk)* call `commit_lock_file()` for a `lock_file` object that is not * currently locked. */ -extern int commit_lock_file (struct lock_file *lk); +int commit_lock_file (struct lock_file *lk);/* * Like `commit_lock_file()`, but rename the lockfile to the provided
ls-refs.h +1 -1
@@ -4,7 +4,7 @@struct repository ;struct argv_array ;struct packet_reader ; -extern int ls_refs (struct repository *r,struct argv_array *keys, +int ls_refs (struct repository *r,struct argv_array *keys,struct packet_reader *request);#endif /* LS_REFS_H */
mailinfo.h +3 -3
@@ -39,8 +39,8 @@ struct mailinfo { int input_error; }; -extern void setup_mailinfo (struct mailinfo *); -extern int mailinfo (struct mailinfo *,const char *msg,const char *patch); -extern void clear_mailinfo (struct mailinfo *); +void setup_mailinfo (struct mailinfo *); +int mailinfo (struct mailinfo *,const char *msg,const char *patch); +void clear_mailinfo (struct mailinfo *);#endif /* MAILINFO_H */
merge-blobs.h +1 -1
@@ -4,7 +4,7 @@struct blob ;struct index_state ; -extern void *merge_blobs (struct index_state *,const char *, +void *merge_blobs (struct index_state *,const char *,struct blob *,struct blob *,struct blob *,unsigned long *);
object-store.h +8 -8
@@ -162,7 +162,7 @@ const char *loose_object_path(struct repository *r, struct strbuf *buf,void *map_loose_object (struct repository *r,const struct object_id *oid,unsigned long *size); -extern void *read_object_file_extended (struct repository *r, +void *read_object_file_extended (struct repository *r,const struct object_id *oid,enum object_type *type,unsigned long *size,int lookup_replace);
@@ -180,20 +180,20 @@ static inline void *repo_read_object_file(struct repository *r,/* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info (struct repository *r,const struct object_id *,unsigned long *); -extern int hash_object_file (const void *buf,unsigned long len, +int hash_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int write_object_file (const void *buf,unsigned long len, +int write_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int hash_object_file_literally (const void *buf,unsigned long len, +int hash_object_file_literally (const void *buf,unsigned long len,const char *type,struct object_id *oid,unsigned flags); -extern int pretend_object_file (void *,unsigned long ,enum object_type , +int pretend_object_file (void *,unsigned long ,enum object_type ,struct object_id *oid); -extern int force_object_loose (const struct object_id *oid,time_t mtime); +int force_object_loose (const struct object_id *oid,time_t mtime);/* * Open the loose object at path, check its hash, and return the contents,
@@ -227,9 +227,9 @@ int repo_has_object_file_with_flags(struct repository *r,* with the specified name. This function does not respect replace * references. */ -extern int has_loose_object_nonlocal (const struct object_id *); +int has_loose_object_nonlocal (const struct object_id *); -extern void assert_oid_type (const struct object_id *oid,enum object_type expect); +void assert_oid_type (const struct object_id *oid,enum object_type expect);struct object_info {/* Request */
object.h +6 -6
@@ -90,19 +90,19 @@ struct object {struct object_id oid; }; -extern const char *type_name (unsigned int type); -extern int type_from_string_gently (const char *str,ssize_t ,int gentle); +const char *type_name (unsigned int type); +int type_from_string_gently (const char *str,ssize_t ,int gentle);#define type_from_string (str) type_from_string_gently(str, -1, 0)/* * Return the current number of buckets in the object hashmap. */ -extern unsigned int get_max_object_index (void ); +unsigned int get_max_object_index (void );/* * Return the object from the specified bucket in the object hashmap. */ -extern struct object *get_indexed_object (unsigned int ); +struct object *get_indexed_object (unsigned int );/* * This can be used to see if we have heard of the object before, but
@@ -118,7 +118,7 @@ extern struct object *get_indexed_object(unsigned int);*/ struct object *lookup_object (struct repository *r,const unsigned char *sha1); -extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj); +void *create_object (struct repository *r,const unsigned char *sha1,void *obj);void *object_as_type (struct repository *r,struct object *obj,enum object_type type,int quiet);
@@ -189,6 +189,6 @@ void clear_object_flags(unsigned flags);/* * Clear the specified object flags from all in-core commit objects. */ -extern void clear_commit_marks_all (unsigned int flags); +void clear_commit_marks_all (unsigned int flags);#endif /* OBJECT_H */
oidmap.h +5 -5
@@ -33,7 +33,7 @@ struct oidmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void oidmap_init (struct oidmap *map,size_t initial_size); +void oidmap_init (struct oidmap *map,size_t initial_size);/* * Frees an oidmap structure and allocated memory.
@@ -41,12 +41,12 @@ extern void oidmap_init(struct oidmap *map, size_t initial_size);* If `free_entries` is true, each oidmap_entry in the map is freed as well * using stdlibs free(). */ -extern void oidmap_free (struct oidmap *map,int free_entries); +void oidmap_free (struct oidmap *map,int free_entries);/* * Returns the oidmap entry for the specified oid, or NULL if not found. */ -extern void *oidmap_get (const struct oidmap *map, +void *oidmap_get (const struct oidmap *map,const struct object_id *key);/*
@@ -57,14 +57,14 @@ extern void *oidmap_get(const struct oidmap *map,* * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *oidmap_put (struct oidmap *map,void *entry); +void *oidmap_put (struct oidmap *map,void *entry);/* * Removes an oidmap entry matching the specified oid. * * Returns the removed entry, or NULL if not found. */ -extern void *oidmap_remove (struct oidmap *map,const struct object_id *key); +void *oidmap_remove (struct oidmap *map,const struct object_id *key);struct oidmap_iter {
pack.h +12 -12
@@ -55,7 +55,7 @@ struct pack_idx_option {uint32_t *anomaly; }; -extern void reset_pack_idx_option (struct pack_idx_option *); +void reset_pack_idx_option (struct pack_idx_option *);/* * Packed object index header
@@ -79,28 +79,28 @@ struct progress;/* Note, the data argument could be NULL if object type is blob */ typedef int (*verify_fn )(const struct object_id *,enum object_type ,unsigned long ,void *,int *); -extern const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); -extern int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); -extern int verify_pack_index (struct packed_git *); -extern int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); -extern off_t write_pack_header (struct hashfile *f,uint32_t ); -extern void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); -extern char *index_pack_lockfile (int fd); +const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); +int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); +int verify_pack_index (struct packed_git *); +int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); +off_t write_pack_header (struct hashfile *f,uint32_t ); +void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); +char *index_pack_lockfile (int fd);/* * The "hdr" output buffer should be at least this big, which will handle sizes * up to 2^67. */ #define MAX_PACK_OBJECT_HEADER 10 -extern int encode_in_pack_object_header (unsigned char *hdr,int hdr_len, +int encode_in_pack_object_header (unsigned char *hdr,int hdr_len,enum object_type ,uintmax_t );#define PH_ERROR_EOF (-1)#define PH_ERROR_PACK_SIGNATURE (-2)#define PH_ERROR_PROTOCOL (-3) -extern int read_pack_header (int fd,struct pack_header *); +int read_pack_header (int fd,struct pack_header *); -extern struct hashfile *create_tmp_packfile (char **pack_tmp_name); -extern void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]); +struct hashfile *create_tmp_packfile (char **pack_tmp_name); +void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]);#endif
packfile.h +38 -38
75 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.921.gb27c68c4e9
Part of the diff is not shown here. View the raw message.
Quoted 4 lines · Denton Liu
Junio mentioned that there was a push to drop extern from function declarations in headers[1]. I decided to do a mass refactoring so we could get rid of everything at once, although I'm not sure if that's welcome. But I'll send the patch anyway since I already wrote it.
The bothersome thing with a mass change is that it probably conflicts with topics in flight. Like for example, my patch that removes all of the externs in packfile.h. :)
Merging with pu is a good way to gauge the damage (though it's not the whole story, as there are other long-running forks like git-for-windows).
Quoted 2 lines
I merged my change with "pu" and these are the files that it conflicts with:
So it sounds like you did that and the result is not _too_ bad. But I'm not sure about doing it automatically with sed. For example...
packfile.h void for_each_file_in_pack_dir(const char *objdir, · line 46
Quoted 11 lines
packfile.h +1
-1@@ -43,10 +43,10 @@ void for_each_file_in_pack_dir(const char *objdir,#define PACKDIR_FILE_PACK 1#define PACKDIR_FILE_IDX 2#define PACKDIR_FILE_GARBAGE 4 -extern void (*report_garbage)(unsigned seen_bits,const char *path); +void (*report_garbage)(unsigned seen_bits,const char *path);
This one is a function pointer, and so the extern is actually changing the visibility of the declared variable. It needs to stay.
(I didn't read the whole patch carefully, but I knew to look for this one in particular since I had to deal with it in my patch, too).
-Peff
Quoted 18 lines · Jeff King
So it sounds like you did that and the result is not _too_ bad. But I'm not sure about doing it automatically with sed. For example...
packfile.h void for_each_file_in_pack_dir(const char *objdir, · line 46
Quoted 11 lines
packfile.h +1
-1@@ -43,10 +43,10 @@ void for_each_file_in_pack_dir(const char *objdir,#define PACKDIR_FILE_PACK 1#define PACKDIR_FILE_IDX 2#define PACKDIR_FILE_GARBAGE 4 -extern void (*report_garbage)(unsigned seen_bits,const char *path); +void (*report_garbage)(unsigned seen_bits,const char *path);This one is a function pointer, and so the extern is actually changing the visibility of the declared variable. It needs to stay.
Quoted 2 lines
(I didn't read the whole patch carefully, but I knew to look for this one in particular since I had to deal with it in my patch, too).
Yeah, after reviewing your recent packfile patch, the above hunk was what I went to hunt for directly in Denton's message ;-)
As I care much more about correctness than "conflicts with in-flight topics too much", I'd prefer people to understand why we avoid the wholesale update is because of an unnecessary bug like this one, not the one-time conflict resolution load that can be subcontracted out to "rerere" once dealt with ;-)
A wholesale rewrite using a tool more suited for the job (e.g. spatch) is a different story, and raises the confidence level of the end result a lot more than a "sed and then eyeball" rewrite, but any tool that allows transformation that is sophisticated enough allows bugs in the instructions we give to the tool, so...
v2 cover remove extern from function declarations
In reply to Denton LiuHi all, thanks for the feedback.
I didn't realise that Coccinelle could be used to remove modifiers but turns out I was wrong. However, Coccinelle seems to choke whenever there's an __attribute__ or when there are varargs and I couldn't figure out how to work around that. As a result, this patchset is written in two parts: one using spatch and another using sed to get the rest.
Hopefully the sed patch is more easily digestable now.
Change since v1:
* Use spatch with sed instead of sed alone
* Fix sed expression to ignore function variables
Denton Liu (3):
*.[ch]: remove extern from function declarations using spatch *.[ch]: remove extern from function declarations using sed
cocci: prevent extern function declarations
advice.h | 2 +- archive.h | 14 +- bisect.h | 12 +- blame.h | 2 +- branch.h | 12 +- builtin.h | 252 +++++++++++----------- bulk-checkin.h | 6 +- cache.h | 344 +++++++++++++++--------------- checkout.h | 2 +- column.h | 12 +- commit.h | 72 +++---- compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 8 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 28 +-- compat/win32/pthread.h | 6 +- config.h | 184 ++++++++-------- connect.h | 20 +- contrib/coccinelle/noextern.cocci | 6 + csum-file.h | 20 +- decorate.h | 4 +- delta.h | 10 +- dir.h | 70 +++--- exec-cmd.h | 16 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 128 +++++------ grep.h | 22 +- hashmap.h | 30 +-- help.h | 30 +-- http.h | 52 ++--- khash.h | 14 +- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 10 +- ls-refs.h | 2 +- mailinfo.h | 6 +- merge-blobs.h | 2 +- object-store.h | 16 +- object.h | 12 +- oidmap.h | 10 +- pack.h | 24 +-- packfile.h | 74 +++---- path.h | 32 +-- pkt-line.h | 6 +- ppc/sha1.c | 2 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 32 +-- reachable.h | 4 +- reflog-walk.h | 16 +- refs.h | 2 +- remote.h | 12 +- replace-object.h | 2 +- resolve-undo.h | 14 +- run-command.h | 8 +- serve.h | 4 +- sha1-lookup.h | 2 +- streaming.h | 8 +- string-list.h | 2 +- sub-process.h | 2 +- submodule-config.h | 20 +- tag.h | 14 +- tempfile.h | 26 +-- trace.h | 34 +-- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 4 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 2 +- worktree.h | 22 +- xdiff-interface.h | 10 +- 79 files changed, 969 insertions(+), 963 deletions(-) create mode 100644 contrib/coccinelle/noextern.cocci
Interdiff against v1:
compat/mingw.c +1 -1
@@ -2483,7 +2483,7 @@ typedef struct {int newmode; } _startupinfo; -extern int __wgetmainargs (int *argc,wchar_t ***argv,wchar_t ***env,int glob, +int __wgetmainargs (int *argc,wchar_t ***argv,wchar_t ***env,int glob,_startupinfo *si); static NORETURN void die_startup(void)
compat/obstack.h +1 -1
@@ -197,7 +197,7 @@ void obstack_free (struct obstack *, void *);more memory. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ -void (*obstack_alloc_failed_handler) (void ); +extern void (*obstack_alloc_failed_handler) (void );/* Pointer to beginning of object being allocated or to be allocated next. Note that this might not be the final address of the object
contrib/coccinelle/noextern.cocci new file +6 -0
@@ -0,0 +1,6 @@ +@@ +type T; +identifier f; +@@ +- extern + T f(...);
delta.h +2 -2
@@ -13,7 +13,7 @@ struct delta_index;* before free_delta_index() is called. The returned pointer must be freed * using free_delta_index(). */ -extern struct delta_index * +struct delta_index *create_delta_index (const void *buf,unsigned long bufsize);/*
@@ -40,7 +40,7 @@ unsigned long sizeof_delta_index(struct delta_index *index);* returned and *delta_size is updated with its size. The returned buffer * must be freed by the caller. */ -extern void * +void *create_delta (const struct delta_index *index,const void *buf,unsigned long bufsize,unsigned long *delta_size,unsigned long max_delta_size);
git-compat-util.h +2 -2
@@ -484,9 +484,9 @@ static inline int const_error(void) void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));void set_error_routine (void (*routine)(const char *err,va_list params)); -void (*get_error_routine (void ))(const char *err,va_list params); +extern void (*get_error_routine (void ))(const char *err,va_list params);void set_warn_routine (void (*routine)(const char *warn,va_list params)); -void (*get_warn_routine (void ))(const char *warn,va_list params); +extern void (*get_warn_routine (void ))(const char *warn,va_list params);void set_die_is_recursing_routine (int (*routine)(void ));int starts_with (const char *str,const char *prefix);
packfile.h +1 -1
@@ -43,7 +43,7 @@ void for_each_file_in_pack_dir(const char *objdir,#define PACKDIR_FILE_PACK 1#define PACKDIR_FILE_IDX 2#define PACKDIR_FILE_GARBAGE 4 -void (*report_garbage)(unsigned seen_bits,const char *path); +extern void (*report_garbage)(unsigned seen_bits,const char *path);void reprepare_packed_git (struct repository *r);void install_packed_git (struct repository *r,struct packed_git *pack);
ppc/sha1.c +1 -1
@@ -10,7 +10,7 @@#include <string.h> #include "sha1.h" -extern void ppc_sha1_core (uint32_t *hash,const unsigned char *p, +void ppc_sha1_core (uint32_t *hash,const unsigned char *p,unsigned int nblocks);int ppc_SHA1_Init (ppc_SHA_CTX *c)
Signature · 1 line
2.21.0.921.gb27c68c4e9
PATCH v2 1/3 *.[ch]: remove extern from function declarations using spatch
There has been a push to remove extern from function declarations. Remove some instances of "extern" for function declarations which are caught by Coccinelle. Note that Coccinelle has some difficulty with processing functions with __attribute__ or varargs so some extern declarations are left behind to be dealt with in a future patch.
This was the Coccinelle patch used:
@@ type T; identifier f; @@ - extern T f(...);
and it was run with:
$ spatch --sp-file contrib/coccinelle/noextern.cocci --dir . --include-headers --in-place
--- advice.h | 2 +- archive.h | 14 +- bisect.h | 12 +- blame.h | 2 +- branch.h | 12 +- builtin.h | 252 +++++++++++++------------- bulk-checkin.h | 6 +- cache.h | 340 ++++++++++++++++++------------------ checkout.h | 2 +- column.h | 12 +- commit.h | 70 ++++---- compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 4 +- compat/obstack.h | 8 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 28 +-- compat/win32/pthread.h | 6 +- config.h | 182 +++++++++---------- connect.h | 20 +-- csum-file.h | 20 +-- decorate.h | 4 +- delta.h | 10 +- dir.h | 70 ++++---- exec-cmd.h | 14 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 108 ++++++------ grep.h | 22 +-- hashmap.h | 30 ++-- help.h | 30 ++-- http.h | 52 +++--- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 10 +- ls-refs.h | 2 +- mailinfo.h | 6 +- merge-blobs.h | 2 +- object-store.h | 16 +- object.h | 12 +- oidmap.h | 10 +- pack.h | 24 +-- packfile.h | 74 ++++---- path.h | 2 +- pkt-line.h | 6 +- ppc/sha1.c | 2 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 30 ++-- reachable.h | 4 +- reflog-walk.h | 16 +- refs.h | 2 +- remote.h | 12 +- replace-object.h | 2 +- resolve-undo.h | 14 +- run-command.h | 6 +- serve.h | 4 +- sha1-lookup.h | 2 +- streaming.h | 8 +- string-list.h | 2 +- sub-process.h | 2 +- submodule-config.h | 20 +-- tag.h | 14 +- tempfile.h | 26 +-- trace.h | 16 +- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 4 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 2 +- worktree.h | 20 +-- xdiff-interface.h | 10 +- 77 files changed, 913 insertions(+), 913 deletions(-)
advice.h +1 -1
@@ -31,7 +31,7 @@ int git_default_advice_config(const char *var, const char *value); __attribute__((format (printf,1 ,2 )))void advise (const char *advice, ...);int error_resolve_conflict (const char *me); -extern void NORETURN die_resolve_conflict(const char *me); +void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void);void detach_advice (const char *new_name);
archive.h +7 -7
@@ -23,7 +23,7 @@ struct archiver_args {/* main api */ -extern int write_archive (int argc,const char **argv,const char *prefix, +int write_archive (int argc,const char **argv,const char *prefix,struct repository *repo,const char *name_hint,int remote);
@@ -39,19 +39,19 @@ struct archiver {unsigned flags;void *data; }; -extern void register_archiver (struct archiver *); +void register_archiver (struct archiver *); -extern void init_tar_archiver (void ); -extern void init_zip_archiver (void ); -extern void init_archivers (void ); +void init_tar_archiver (void ); +void init_zip_archiver (void ); +void init_archivers (void );typedef int (*write_archive_entry_fn_t )(struct archiver_args *args,const struct object_id *oid,const char *path,size_t pathlen,unsigned int mode); -extern int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); -extern void *object_file_to_archive (const struct archiver_args *args, +int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); +void *object_file_to_archive (const struct archiver_args *args,const char *path,const struct object_id *oid,unsigned int mode,enum object_type *type,unsigned long *sizep);
bisect.h +6 -6
@@ -11,10 +11,10 @@ struct repository;* Otherwise, it will be either all non-SAMETREE commits or the single * best commit, as chosen by `find_all`. */ -extern void find_bisection (struct commit_list **list,int *reaches,int *all, +void find_bisection (struct commit_list **list,int *reaches,int *all,int find_all); -extern struct commit_list *filter_skipped(struct commit_list *list, +struct commit_list *filter_skipped(struct commit_list *list, struct commit_list **tried, int show_all, int *count,
@@ -31,14 +31,14 @@ struct rev_list_info { const char *header_prefix; }; -extern int bisect_next_all (struct repository *r, +int bisect_next_all (struct repository *r,const char *prefix,int no_checkout); -extern int estimate_bisect_steps (int all); +int estimate_bisect_steps (int all); -extern void read_bisect_terms (const char **bad,const char **good); +void read_bisect_terms (const char **bad,const char **good); -extern int bisect_clean_state (void ); +int bisect_clean_state (void );#endif
blame.h +1 -1
@@ -177,6 +177,6 @@ struct blame_entry *blame_entry_prepend(struct blame_entry *head, long start, long end, struct blame_origin *o); -extern struct blame_origin *get_blame_suspects (struct commit *commit); +struct blame_origin *get_blame_suspects (struct commit *commit);#endif /* BLAME_H */
branch.h +6 -6
@@ -50,7 +50,7 @@ void create_branch(struct repository *r,* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_branchname (const char *name,struct strbuf *ref); +int validate_branchname (const char *name,struct strbuf *ref);/* * Check if a branch 'name' can be created as a new branch; die otherwise.
@@ -58,7 +58,7 @@ extern int validate_branchname(const char *name, struct strbuf *ref);* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_new_branchname (const char *name,struct strbuf *ref,int force); +int validate_new_branchname (const char *name,struct strbuf *ref,int force);/* * Remove information about the state of working on the current
@@ -72,26 +72,26 @@ void remove_branch_state(struct repository *r);* Returns 0 on success. */ #define BRANCH_CONFIG_VERBOSE 01 -extern int install_branch_config (int flag,const char *local,const char *origin,const char *remote); +int install_branch_config (int flag,const char *local,const char *origin,const char *remote);/* * Read branch description */ -extern int read_branch_desc (struct strbuf *,const char *branch_name); +int read_branch_desc (struct strbuf *,const char *branch_name);/* * Check if a branch is checked out in the main worktree or any linked * worktree and die (with a message describing its checkout location) if * it is. */ -extern void die_if_checked_out (const char *branch,int ignore_current_worktree); +void die_if_checked_out (const char *branch,int ignore_current_worktree);/* * Update all per-worktree HEADs pointing at the old ref to point the new ref. * This will be used when renaming a branch. Returns 0 if successful, non-zero * otherwise. */ -extern int replace_each_worktree_head_symref (const char *oldref,const char *newref, +int replace_each_worktree_head_symref (const char *oldref,const char *newref,const char *logmsg);#endif
builtin.h +126 -126
271 lines not on this page · raw message
bulk-checkin.h +3 -3
@@ -6,11 +6,11 @@#include "cache.h" -extern int index_bulk_checkin (struct object_id *oid, +int index_bulk_checkin (struct object_id *oid,int fd,size_t size,enum object_type type,const char *path,unsigned flags); -extern void plug_bulk_checkin (void ); -extern void unplug_bulk_checkin (void ); +void plug_bulk_checkin (void ); +void unplug_bulk_checkin (void );#endif
cache.h +170 -170
663 lines not on this page · raw message
checkout.h +1 -1
@@ -8,7 +8,7 @@* tracking branch. Return the name of the remote if such a branch * exists, NULL otherwise. */ -extern const char *unique_tracking_name (const char *name, +const char *unique_tracking_name (const char *name,struct object_id *oid,int *dwim_remotes_matched);
column.h +6 -6
@@ -27,20 +27,20 @@ struct column_options { };struct option ; -extern int parseopt_column_callback (const struct option *,const char *,int ); -extern int git_column_config (const char *var,const char *value, +int parseopt_column_callback (const struct option *,const char *,int ); +int git_column_config (const char *var,const char *value,const char *command,unsigned int *colopts); -extern int finalize_colopts (unsigned int *colopts,int stdout_is_tty); +int finalize_colopts (unsigned int *colopts,int stdout_is_tty);static inline int column_active (unsigned int colopts) {return (colopts &COL_ENABLE_MASK ) ==COL_ENABLED ; }struct string_list ; -extern void print_columns (const struct string_list *list,unsigned int colopts, +void print_columns (const struct string_list *list,unsigned int colopts,const struct column_options *opts); -extern int run_column_filter (int colopts,const struct column_options *); -extern int stop_column_filter (void ); +int run_column_filter (int colopts,const struct column_options *); +int stop_column_filter (void );#endif
commit.h +35 -35
155 lines not on this page · raw message
compat/mingw.c +1 -1
@@ -2483,7 +2483,7 @@ typedef struct {int newmode; } _startupinfo; -extern int __wgetmainargs (int *argc,wchar_t ***argv,wchar_t ***env,int glob, +int __wgetmainargs (int *argc,wchar_t ***argv,wchar_t ***env,int glob,_startupinfo *si); static NORETURN void die_startup(void)
compat/mingw.h +3 -3
@@ -11,7 +11,7 @@ typedef _sigset_t sigset_t;#undef _POSIX_THREAD_SAFE_FUNCTIONS#endif -extern int mingw_core_config (const char *var,const char *value,void *cb); +int mingw_core_config (const char *var,const char *value,void *cb);#define platform_core_config mingw_core_config/*
@@ -449,7 +449,7 @@ static inline void convert_slashes(char *path) *path ='/' ; }#define PATH_SEP ';' -extern char *mingw_query_user_email (void ); +char *mingw_query_user_email (void );#define query_user_email mingw_query_user_email#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"
@@ -586,4 +586,4 @@ static int mingw_main(c,v)/* * Used by Pthread API implementation for Windows */ -extern int err_win_to_posix (DWORD winerr); +int err_win_to_posix (DWORD winerr);
compat/nedmalloc/malloc.c.h +2 -2
@@ -1327,7 +1327,7 @@ int mspace_mallopt(int, int);#include <unistd.h> /* for sbrk, sysconf */ #else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void *sbrk (ptrdiff_t ); +void *sbrk (ptrdiff_t );#endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */
@@ -1444,7 +1444,7 @@ unsigned char _BitScanReverse(unsigned long *index, unsigned long mask);# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)# else # if defined(BSD ) || defined(DGUX ) || defined(HAVE_GETPAGESIZE ) -extern size_t getpagesize (); +size_t getpagesize ();# define malloc_getpagesize getpagesize()# else # ifdef WIN32 /* use supplied emulation of getpagesize */
compat/obstack.h +4 -4
@@ -182,13 +182,13 @@ struct obstack /* control current object in current chunk *//* Declare the external functions we use; they are in obstack.c. */ -extern void _obstack_newchunk (struct obstack *,int ); -extern int _obstack_begin (struct obstack *,int ,int , +void _obstack_newchunk (struct obstack *,int ); +int _obstack_begin (struct obstack *,int ,int ,void *(*) (long ),void (*) (void *)); -extern int _obstack_begin_1 (struct obstack *,int ,int , +int _obstack_begin_1 (struct obstack *,int ,int ,void *(*) (void *,long ),void (*) (void *,void *),void *); -extern int _obstack_memory_used (struct obstack *); +int _obstack_memory_used (struct obstack *);void obstack_free (struct obstack *,void *);
compat/poll/poll.h +1 -1
@@ -57,7 +57,7 @@ struct pollfdtypedef unsigned long nfds_t ; -extern int poll (struct pollfd *pfd,nfds_t nfd,int timeout); +int poll (struct pollfd *pfd,nfds_t nfd,int timeout);/* Define INFTIM only if doing so conforms to POSIX. */ #if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
compat/regex/regex.h +14 -14
@@ -465,19 +465,19 @@ typedef struct#ifdef __USE_GNU/* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); +reg_syntax_t re_set_syntax (reg_syntax_t __syntax);/* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern (const char *__pattern,size_t __length, +const char *re_compile_pattern (const char *__pattern,size_t __length,struct re_pattern_buffer *__buffer);/* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); +int re_compile_fastmap (struct re_pattern_buffer *__buffer);/* Search in the string STRING (with length LENGTH) for the pattern
@@ -485,14 +485,14 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search (struct re_pattern_buffer *__buffer,const char *__cstring, +int re_search (struct re_pattern_buffer *__buffer,const char *__cstring,int __length,int __start,int __range,struct re_registers *__regs);/* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 (struct re_pattern_buffer *__buffer, +int re_search_2 (struct re_pattern_buffer *__buffer,const char *__string1,int __length1,const char *__string2,int __length2,int __start,int __range,struct re_registers *__regs,int __stop);
@@ -500,12 +500,12 @@ extern int re_search_2 (struct re_pattern_buffer *__buffer,/* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern int re_match (struct re_pattern_buffer *__buffer,const char *__cstring, +int re_match (struct re_pattern_buffer *__buffer,const char *__cstring,int __length,int __start,struct re_registers *__regs);/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 (struct re_pattern_buffer *__buffer, +int re_match_2 (struct re_pattern_buffer *__buffer,const char *__string1,int __length1,const char *__string2,int __length2,int __start,struct re_registers *__regs,int __stop);
@@ -523,7 +523,7 @@ extern int re_match_2 (struct re_pattern_buffer *__buffer,Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ -extern void re_set_registers (struct re_pattern_buffer *__buffer, +void re_set_registers (struct re_pattern_buffer *__buffer,struct re_registers *__regs,unsigned int __num_regs,regoff_t *__starts,regoff_t *__ends);
@@ -532,8 +532,8 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)# ifndef _CRAY/* 4.2 bsd compatibility. */ -extern char *re_comp (const char *); -extern int re_exec (const char *); +char *re_comp (const char *); +int re_exec (const char *);# endif #endif
@@ -559,19 +559,19 @@ extern int re_exec (const char *);#endif /* POSIX compatibility. */ -extern int regcomp (regex_t *__restrict __preg, +int regcomp (regex_t *__restrict __preg,const char *__restrict __pattern,int __cflags); -extern int regexec (const regex_t *__restrict __preg, +int regexec (const regex_t *__restrict __preg,const char *__restrict __cstring,size_t __nmatch,regmatch_t __pmatch[__restrict_arr],int __eflags); -extern size_t regerror (int __errcode,const regex_t *__restrict __preg, +size_t regerror (int __errcode,const regex_t *__restrict __preg,char *__restrict __errbuf,size_t __errbuf_size); -extern void regfree (regex_t *__preg); +void regfree (regex_t *__preg);#ifdef __cplusplus
compat/win32/pthread.h +3 -3
@@ -50,7 +50,7 @@ typedef struct {DWORD tid; } pthread_t; -extern int pthread_create (pthread_t *thread,const void *unused, +int pthread_create (pthread_t *thread,const void *unused,void *(*start_routine)(void *),void *arg);/*
@@ -59,10 +59,10 @@ extern int pthread_create(pthread_t *thread, const void *unused,*/ #define pthread_join (a, b) win32_pthread_join(&(a), (b)) -extern int win32_pthread_join (pthread_t *thread,void **value_ptr); +int win32_pthread_join (pthread_t *thread,void **value_ptr);#define pthread_equal (t1, t2) ((t1).tid == (t2).tid) -extern pthread_t pthread_self (void ); +pthread_t pthread_self (void ); static inline void NORETURN pthread_exit(void *ret) {
config.h +91 -91
254 lines not on this page · raw message
connect.h +10 -10
@@ -7,19 +7,19 @@#define CONNECT_DIAG_URL (1u << 1)#define CONNECT_IPV4 (1u << 2)#define CONNECT_IPV6 (1u << 3) -extern struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); -extern int finish_connect (struct child_process *conn); -extern int git_connection_is_socket (struct child_process *conn); -extern int server_supports (const char *feature); -extern int parse_feature_request (const char *features,const char *feature); -extern const char *server_feature_value (const char *feature,int *len_ret); -extern int url_is_local_not_ssh (const char *url); +struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); +int finish_connect (struct child_process *conn); +int git_connection_is_socket (struct child_process *conn); +int server_supports (const char *feature); +int parse_feature_request (const char *features,const char *feature); +const char *server_feature_value (const char *feature,int *len_ret); +int url_is_local_not_ssh (const char *url);struct packet_reader ; -extern enum protocol_version discover_version (struct packet_reader *reader); +enum protocol_version discover_version (struct packet_reader *reader); -extern int server_supports_v2 (const char *c,int die_on_error); -extern int server_supports_feature (const char *c,const char *feature, +int server_supports_v2 (const char *c,int die_on_error); +int server_supports_feature (const char *c,const char *feature,int die_on_error);#endif
csum-file.h +10 -10
@@ -25,22 +25,22 @@ struct hashfile_checkpoint {git_hash_ctx ctx; }; -extern void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); -extern int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *); +void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); +int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *);/* finalize_hashfile flags */ #define CSUM_CLOSE 1#define CSUM_FSYNC 2#define CSUM_HASH_IN_STREAM 4 -extern struct hashfile *hashfd (int fd,const char *name); -extern struct hashfile *hashfd_check (const char *name); -extern struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); -extern int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); -extern void hashwrite (struct hashfile *,const void *,unsigned int ); -extern void hashflush (struct hashfile *f); -extern void crc32_begin (struct hashfile *); -extern uint32_t crc32_end (struct hashfile *); +struct hashfile *hashfd (int fd,const char *name); +struct hashfile *hashfd_check (const char *name); +struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); +int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); +void hashwrite (struct hashfile *,const void *,unsigned int ); +void hashflush (struct hashfile *f); +void crc32_begin (struct hashfile *); +uint32_t crc32_end (struct hashfile *);static inline void hashwrite_u8 (struct hashfile *f,uint8_t data) {
decorate.h +2 -2
@@ -50,12 +50,12 @@ struct decoration {* NULL), returning the previously associated pointer. If there is no previous * association, this function returns NULL. */ -extern void *add_decoration (struct decoration *n,const struct object *obj,void *decoration); +void *add_decoration (struct decoration *n,const struct object *obj,void *decoration);/* * Return the pointer associated to the given object. If there is no * association, this function returns NULL. */ -extern void *lookup_decoration (struct decoration *n,const struct object *obj); +void *lookup_decoration (struct decoration *n,const struct object *obj);#endif
delta.h +5 -5
@@ -13,7 +13,7 @@ struct delta_index;* before free_delta_index() is called. The returned pointer must be freed * using free_delta_index(). */ -extern struct delta_index * +struct delta_index *create_delta_index (const void *buf,unsigned long bufsize);/*
@@ -21,14 +21,14 @@ create_delta_index(const void *buf, unsigned long bufsize);* * Given pointer must be what create_delta_index() returned, or NULL. */ -extern void free_delta_index (struct delta_index *index); +void free_delta_index (struct delta_index *index);/* * sizeof_delta_index: returns memory usage of delta index * * Given pointer must be what create_delta_index() returned, or NULL. */ -extern unsigned long sizeof_delta_index (struct delta_index *index); +unsigned long sizeof_delta_index (struct delta_index *index);/* * create_delta: create a delta from given index for the given buffer
@@ -40,7 +40,7 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);* returned and *delta_size is updated with its size. The returned buffer * must be freed by the caller. */ -extern void * +void *create_delta (const struct delta_index *index,const void *buf,unsigned long bufsize,unsigned long *delta_size,unsigned long max_delta_size);
@@ -75,7 +75,7 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,* *trg_bufsize is updated with its size. On failure a NULL pointer is * returned. The returned buffer must be freed by the caller. */ -extern void *patch_delta (const void *src_buf,unsigned long src_size, +void *patch_delta (const void *src_buf,unsigned long src_size,const void *delta_buf,unsigned long delta_size,unsigned long *dst_size);
dir.h +35 -35
145 lines not on this page · raw message
exec-cmd.h +7 -7
@@ -3,14 +3,14 @@struct argv_array ; -extern void git_set_exec_path (const char *exec_path); -extern void git_resolve_executable_dir (const char *path); -extern const char *git_exec_path (void ); -extern void setup_path (void ); -extern const char **prepare_git_cmd (struct argv_array *out,const char **argv); -extern int execv_git_cmd (const char **argv);/* NULL terminated */ +void git_set_exec_path (const char *exec_path); +void git_resolve_executable_dir (const char *path); +const char *git_exec_path (void ); +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, ...); -extern char *system_path (const char *path); +char *system_path (const char *path);#endif /* GIT_EXEC_CMD_H */
fmt-merge-msg.h +1 -1
@@ -2,6 +2,6 @@#define FMT_MERGE_MSG_H extern int merge_log_config; -extern int fmt_merge_msg_config (const char *key,const char *value,void *cb); +int fmt_merge_msg_config (const char *key,const char *value,void *cb);#endif /* FMT_MERGE_MSG_H */
fsmonitor.h +7 -7
@@ -10,31 +10,31 @@ extern struct trace_key trace_fsmonitor;* Read the fsmonitor index extension and (if configured) restore the * CE_FSMONITOR_VALID state. */ -extern int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz); +int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz);/* * Fill the fsmonitor_dirty ewah bits with their state from the index, * before it is split during writing. */ -extern void fill_fsmonitor_bitmap (struct index_state *istate); +void fill_fsmonitor_bitmap (struct index_state *istate);/* * Write the CE_FSMONITOR_VALID state into the fsmonitor index * extension. Reads from the fsmonitor_dirty ewah in the index. */ -extern void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate); +void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate);/* * Add/remove the fsmonitor index extension */ -extern void add_fsmonitor (struct index_state *istate); -extern void remove_fsmonitor (struct index_state *istate); +void add_fsmonitor (struct index_state *istate); +void remove_fsmonitor (struct index_state *istate);/* * Add/remove the fsmonitor index extension as necessary based on the current * core.fsmonitor setting. */ -extern void tweak_fsmonitor (struct index_state *istate); +void tweak_fsmonitor (struct index_state *istate);/* * Run the configured fsmonitor integration script and clear the
@@ -42,7 +42,7 @@ extern void tweak_fsmonitor(struct index_state *istate);* any corresponding untracked cache directory structures. Optimized to only * run the first time it is called. */ -extern void refresh_fsmonitor (struct index_state *istate); +void refresh_fsmonitor (struct index_state *istate);/* * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
gettext.h +4 -4
@@ -28,11 +28,11 @@#define FORMAT_PRESERVING (n) __attribute__((format_arg(n))) -extern int use_gettext_poison (void ); +int use_gettext_poison (void );#ifndef NO_GETTEXT -extern void git_setup_gettext (void ); -extern int gettext_width (const char *s); +void git_setup_gettext (void ); +int gettext_width (const char *s);#else static inline void git_setup_gettext (void ) {
@@ -87,6 +87,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)#endif const char *get_preferred_languages (void ); -extern int is_utf8_locale (void ); +int is_utf8_locale (void );#endif
git-compat-util.h +54 -54
242 lines not on this page · raw message
grep.h +11 -11
@@ -186,17 +186,17 @@ struct grep_opt {void *output_priv; }; -extern void init_grep_defaults (struct repository *); -extern int grep_config (const char *var,const char *value,void *); -extern void grep_init (struct grep_opt *,struct repository *repo,const char *prefix); +void init_grep_defaults (struct repository *); +int grep_config (const char *var,const char *value,void *); +void grep_init (struct grep_opt *,struct repository *repo,const char *prefix);void grep_commit_pattern_type (enum grep_pattern_type ,struct grep_opt *opt); -extern void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); -extern void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); -extern void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); -extern void compile_grep_patterns (struct grep_opt *opt); -extern void free_grep_patterns (struct grep_opt *opt); -extern int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size); +void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); +void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); +void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); +void compile_grep_patterns (struct grep_opt *opt); +void free_grep_patterns (struct grep_opt *opt); +int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size);struct grep_source {char *name;
@@ -226,8 +226,8 @@ void grep_source_load_driver(struct grep_source *gs,int grep_source (struct grep_opt *opt,struct grep_source *gs); -extern struct grep_opt *grep_opt_dup (const struct grep_opt *opt); -extern int grep_threads_ok (const struct grep_opt *opt); +struct grep_opt *grep_opt_dup (const struct grep_opt *opt); +int grep_threads_ok (const struct grep_opt *opt);/* * Mutex used around access to the attributes machinery if
hashmap.h +15 -15
@@ -104,11 +104,11 @@* `memihash_cont` is a variant of `memihash` that allows a computation to be * continued with another chunk of data. */ -extern unsigned int strhash (const char *buf); -extern unsigned int strihash (const char *buf); -extern unsigned int memhash (const void *buf,size_t len); -extern unsigned int memihash (const void *buf,size_t len); -extern unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len); +unsigned int strhash (const char *buf); +unsigned int strihash (const char *buf); +unsigned int memhash (const void *buf,size_t len); +unsigned int memihash (const void *buf,size_t len); +unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len);/* * Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code
@@ -216,7 +216,7 @@ struct hashmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void hashmap_init (struct hashmap *map, +void hashmap_init (struct hashmap *map,hashmap_cmp_fn equals_function,const void *equals_function_data,size_t initial_size);
@@ -227,7 +227,7 @@ extern void hashmap_init(struct hashmap *map,* If `free_entries` is true, each hashmap_entry in the map is freed as well * using stdlibs free(). */ -extern void hashmap_free (struct hashmap *map,int free_entries); +void hashmap_free (struct hashmap *map,int free_entries);/* hashmap_entry functions */
@@ -284,7 +284,7 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)* If an entry with matching hash code is found, `key` and `keydata` are passed * to `hashmap_cmp_fn` to decide whether the entry matches the key. */ -extern void *hashmap_get (const struct hashmap *map,const void *key, +void *hashmap_get (const struct hashmap *map,const void *key,const void *keydata);/*
@@ -316,7 +316,7 @@ static inline void *hashmap_get_from_hash(const struct hashmap *map,* `entry` is the hashmap_entry to start the search from, obtained via a previous * call to `hashmap_get` or `hashmap_get_next`. */ -extern void *hashmap_get_next (const struct hashmap *map,const void *entry); +void *hashmap_get_next (const struct hashmap *map,const void *entry);/* * Adds a hashmap entry. This allows to add duplicate entries (i.e.
@@ -325,7 +325,7 @@ extern void *hashmap_get_next(const struct hashmap *map, const void *entry);* `map` is the hashmap structure. * `entry` is the entry to add. */ -extern void hashmap_add (struct hashmap *map,void *entry); +void hashmap_add (struct hashmap *map,void *entry);/* * Adds or replaces a hashmap entry. If the hashmap contains duplicate
@@ -335,7 +335,7 @@ extern void hashmap_add(struct hashmap *map, void *entry);* `entry` is the entry to add or replace. * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *hashmap_put (struct hashmap *map,void *entry); +void *hashmap_put (struct hashmap *map,void *entry);/* * Removes a hashmap entry matching the specified key. If the hashmap contains
@@ -344,7 +344,7 @@ extern void *hashmap_put(struct hashmap *map, void *entry);* * Argument explanation is the same as in `hashmap_get`. */ -extern void *hashmap_remove (struct hashmap *map,const void *key, +void *hashmap_remove (struct hashmap *map,const void *key,const void *keydata);/*
@@ -365,10 +365,10 @@ struct hashmap_iter { };/* Initializes a `hashmap_iter` structure. */ -extern void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter); +void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter);/* Returns the next hashmap_entry, or NULL if there are no more entries. */ -extern void *hashmap_iter_next (struct hashmap_iter *iter); +void *hashmap_iter_next (struct hashmap_iter *iter);/* Initializes the iterator and returns the first entry, if any. */ static inline void *hashmap_iter_first(struct hashmap *map,
@@ -429,7 +429,7 @@ static inline void hashmap_enable_item_counting(struct hashmap *map)* * Uses a hashmap to store the pool of interned strings. */ -extern const void *memintern (const void *data,size_t len); +const void *memintern (const void *data,size_t len);static inline const char *strintern (const char *string) {return memintern (string,strlen (string));
help.h +15 -15
@@ -19,31 +19,31 @@ static inline void mput_char(char c, unsigned int num)putchar (c); } -extern void list_common_cmds_help (void ); -extern void list_all_cmds_help (void ); -extern void list_common_guides_help (void ); -extern void list_config_help (int for_human); +void list_common_cmds_help (void ); +void list_all_cmds_help (void ); +void list_common_guides_help (void ); +void list_config_help (int for_human); -extern void list_all_main_cmds (struct string_list *list); -extern void list_all_other_cmds (struct string_list *list); -extern void list_cmds_by_category (struct string_list *list, +void list_all_main_cmds (struct string_list *list); +void list_all_other_cmds (struct string_list *list); +void list_cmds_by_category (struct string_list *list,const char *category); -extern void list_cmds_by_config (struct string_list *list); -extern const char *help_unknown_cmd (const char *cmd); -extern void load_command_list (const char *prefix, +void list_cmds_by_config (struct string_list *list); +const char *help_unknown_cmd (const char *cmd); +void load_command_list (const char *prefix,struct cmdnames *main_cmds,struct cmdnames *other_cmds); -extern void add_cmdname (struct cmdnames *cmds,const char *name,int len); +void add_cmdname (struct cmdnames *cmds,const char *name,int len);/* Here we require that excludes is a sorted list. */ -extern void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); -extern int is_in_cmdlist (struct cmdnames *cmds,const char *name); -extern void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds); +void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); +int is_in_cmdlist (struct cmdnames *cmds,const char *name); +void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds);/* * call this to die(), when it is suspected that the user mistyped a * ref to the command, to give suggested "correct" refs. */ -extern void help_unknown_ref (const char *ref,const char *cmd,const char *error); +void help_unknown_ref (const char *ref,const char *cmd,const char *error); static inline void list_config_item(struct string_list *list, const char *prefix,
http.h +26 -26
101 lines not on this page · raw message
kwset.h +5 -5
@@ -37,16 +37,16 @@ typedef struct kwset_t* kwset_t;if enough memory cannot be obtained. The argument if non-NULL specifies a table of character translations to be applied to all pattern and search text. */ -extern kwset_t kwsalloc (unsigned char const *); +kwset_t kwsalloc (unsigned char const *);/* Incrementally extend the keyword set to include the given string. Return NULL for success, or an error message. Remember an index number for each keyword included in the set. */ -extern const char *kwsincr (kwset_t ,char const *,size_t ); +const char *kwsincr (kwset_t ,char const *,size_t );/* When the keyword set has been completely built, prepare it for use. Return NULL for success, or an error message. */ -extern const char *kwsprep (kwset_t ); +const char *kwsprep (kwset_t );/* Search through the given buffer for a member of the keyword set. Return a pointer to the leftmost longest match found, or NULL if
@@ -54,8 +54,8 @@ extern const char *kwsprep(kwset_t);the matching substring in the integer it points to. Similarly, if foundindex is non-NULL, store the index of the particular keyword found therein. */ -extern size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *); +size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *);/* Deallocate the given keyword set and all its associated storage. */ -extern void kwsfree (kwset_t ); +void kwsfree (kwset_t );
line-log.h +8 -8
@@ -25,17 +25,17 @@ struct diff_ranges {struct range_set target; }; -extern void range_set_init (struct range_set *,size_t prealloc); -extern void range_set_release (struct range_set *); +void range_set_init (struct range_set *,size_t prealloc); +void range_set_release (struct range_set *);/* Range includes start; excludes end */ -extern void range_set_append_unsafe (struct range_set *,long start,long end); +void range_set_append_unsafe (struct range_set *,long start,long end);/* New range must begin at or after end of last added range */ -extern void range_set_append (struct range_set *,long start,long end); +void range_set_append (struct range_set *,long start,long end);/* * In-place pass of sorting and merging the ranges in the range set, * to sort and make the ranges disjoint. */ -extern void sort_and_merge_range_set (struct range_set *); +void sort_and_merge_range_set (struct range_set *);/* Linked list of interesting files and their associated ranges. The * list must be kept sorted by path.
@@ -54,10 +54,10 @@ struct line_log_data { struct diff_ranges diff; }; -extern void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); +void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); -extern int line_log_filter (struct rev_info *rev); +int line_log_filter (struct rev_info *rev); -extern int line_log_print (struct rev_info *rev,struct commit *commit); +int line_log_print (struct rev_info *rev,struct commit *commit);#endif /* LINE_LOG_H */
lockfile.h +5 -5
@@ -159,7 +159,7 @@ struct lock_file {* timeout_ms is -1, retry indefinitely. The flags argument and error * handling are described above. */ -extern int hold_lock_file_for_update_timeout ( +int hold_lock_file_for_update_timeout (struct lock_file *lk,const char *path,int flags,long timeout_ms);
@@ -188,7 +188,7 @@ static inline int is_lock_file_locked(struct lock_file *lk)* of `hold_lock_file_for_update()` to lock `path`. `err` should be the * `errno` set by the failing call. */ -extern void unable_to_lock_message (const char *path,int err, +void unable_to_lock_message (const char *path,int err,struct strbuf *buf);/*
@@ -197,7 +197,7 @@ extern void unable_to_lock_message(const char *path, int err,* `errno` set by the failing * call. */ -extern NORETURN void unable_to_lock_die(const char *path, int err); +NORETURN void unable_to_lock_die(const char *path, int err);/* * Associate a stdio stream with the lockfile (which must still be
@@ -234,7 +234,7 @@ static inline FILE *get_lock_file_fp(struct lock_file *lk)* Return the path of the file that is locked by the specified * lock_file object. The caller must free the memory. */ -extern char *get_locked_file_path (struct lock_file *lk); +char *get_locked_file_path (struct lock_file *lk);/* * If the lockfile is still open, close it (and the file pointer if it
@@ -282,7 +282,7 @@ static inline int reopen_lock_file(struct lock_file *lk)* call `commit_lock_file()` for a `lock_file` object that is not * currently locked. */ -extern int commit_lock_file (struct lock_file *lk); +int commit_lock_file (struct lock_file *lk);/* * Like `commit_lock_file()`, but rename the lockfile to the provided
ls-refs.h +1 -1
@@ -4,7 +4,7 @@struct repository ;struct argv_array ;struct packet_reader ; -extern int ls_refs (struct repository *r,struct argv_array *keys, +int ls_refs (struct repository *r,struct argv_array *keys,struct packet_reader *request);#endif /* LS_REFS_H */
mailinfo.h +3 -3
@@ -39,8 +39,8 @@ struct mailinfo { int input_error; }; -extern void setup_mailinfo (struct mailinfo *); -extern int mailinfo (struct mailinfo *,const char *msg,const char *patch); -extern void clear_mailinfo (struct mailinfo *); +void setup_mailinfo (struct mailinfo *); +int mailinfo (struct mailinfo *,const char *msg,const char *patch); +void clear_mailinfo (struct mailinfo *);#endif /* MAILINFO_H */
merge-blobs.h +1 -1
@@ -4,7 +4,7 @@struct blob ;struct index_state ; -extern void *merge_blobs (struct index_state *,const char *, +void *merge_blobs (struct index_state *,const char *,struct blob *,struct blob *,struct blob *,unsigned long *);
object-store.h +8 -8
@@ -162,7 +162,7 @@ const char *loose_object_path(struct repository *r, struct strbuf *buf,void *map_loose_object (struct repository *r,const struct object_id *oid,unsigned long *size); -extern void *read_object_file_extended (struct repository *r, +void *read_object_file_extended (struct repository *r,const struct object_id *oid,enum object_type *type,unsigned long *size,int lookup_replace);
@@ -180,20 +180,20 @@ static inline void *repo_read_object_file(struct repository *r,/* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info (struct repository *r,const struct object_id *,unsigned long *); -extern int hash_object_file (const void *buf,unsigned long len, +int hash_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int write_object_file (const void *buf,unsigned long len, +int write_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int hash_object_file_literally (const void *buf,unsigned long len, +int hash_object_file_literally (const void *buf,unsigned long len,const char *type,struct object_id *oid,unsigned flags); -extern int pretend_object_file (void *,unsigned long ,enum object_type , +int pretend_object_file (void *,unsigned long ,enum object_type ,struct object_id *oid); -extern int force_object_loose (const struct object_id *oid,time_t mtime); +int force_object_loose (const struct object_id *oid,time_t mtime);/* * Open the loose object at path, check its hash, and return the contents,
@@ -227,9 +227,9 @@ int repo_has_object_file_with_flags(struct repository *r,* with the specified name. This function does not respect replace * references. */ -extern int has_loose_object_nonlocal (const struct object_id *); +int has_loose_object_nonlocal (const struct object_id *); -extern void assert_oid_type (const struct object_id *oid,enum object_type expect); +void assert_oid_type (const struct object_id *oid,enum object_type expect);struct object_info {/* Request */
object.h +6 -6
@@ -90,19 +90,19 @@ struct object {struct object_id oid; }; -extern const char *type_name (unsigned int type); -extern int type_from_string_gently (const char *str,ssize_t ,int gentle); +const char *type_name (unsigned int type); +int type_from_string_gently (const char *str,ssize_t ,int gentle);#define type_from_string (str) type_from_string_gently(str, -1, 0)/* * Return the current number of buckets in the object hashmap. */ -extern unsigned int get_max_object_index (void ); +unsigned int get_max_object_index (void );/* * Return the object from the specified bucket in the object hashmap. */ -extern struct object *get_indexed_object (unsigned int ); +struct object *get_indexed_object (unsigned int );/* * This can be used to see if we have heard of the object before, but
@@ -118,7 +118,7 @@ extern struct object *get_indexed_object(unsigned int);*/ struct object *lookup_object (struct repository *r,const unsigned char *sha1); -extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj); +void *create_object (struct repository *r,const unsigned char *sha1,void *obj);void *object_as_type (struct repository *r,struct object *obj,enum object_type type,int quiet);
@@ -189,6 +189,6 @@ void clear_object_flags(unsigned flags);/* * Clear the specified object flags from all in-core commit objects. */ -extern void clear_commit_marks_all (unsigned int flags); +void clear_commit_marks_all (unsigned int flags);#endif /* OBJECT_H */
oidmap.h +5 -5
@@ -33,7 +33,7 @@ struct oidmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void oidmap_init (struct oidmap *map,size_t initial_size); +void oidmap_init (struct oidmap *map,size_t initial_size);/* * Frees an oidmap structure and allocated memory.
@@ -41,12 +41,12 @@ extern void oidmap_init(struct oidmap *map, size_t initial_size);* If `free_entries` is true, each oidmap_entry in the map is freed as well * using stdlibs free(). */ -extern void oidmap_free (struct oidmap *map,int free_entries); +void oidmap_free (struct oidmap *map,int free_entries);/* * Returns the oidmap entry for the specified oid, or NULL if not found. */ -extern void *oidmap_get (const struct oidmap *map, +void *oidmap_get (const struct oidmap *map,const struct object_id *key);/*
@@ -57,14 +57,14 @@ extern void *oidmap_get(const struct oidmap *map,* * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *oidmap_put (struct oidmap *map,void *entry); +void *oidmap_put (struct oidmap *map,void *entry);/* * Removes an oidmap entry matching the specified oid. * * Returns the removed entry, or NULL if not found. */ -extern void *oidmap_remove (struct oidmap *map,const struct object_id *key); +void *oidmap_remove (struct oidmap *map,const struct object_id *key);struct oidmap_iter {
pack.h +12 -12
@@ -55,7 +55,7 @@ struct pack_idx_option {uint32_t *anomaly; }; -extern void reset_pack_idx_option (struct pack_idx_option *); +void reset_pack_idx_option (struct pack_idx_option *);/* * Packed object index header
@@ -79,28 +79,28 @@ struct progress;/* Note, the data argument could be NULL if object type is blob */ typedef int (*verify_fn )(const struct object_id *,enum object_type ,unsigned long ,void *,int *); -extern const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); -extern int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); -extern int verify_pack_index (struct packed_git *); -extern int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); -extern off_t write_pack_header (struct hashfile *f,uint32_t ); -extern void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); -extern char *index_pack_lockfile (int fd); +const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); +int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); +int verify_pack_index (struct packed_git *); +int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); +off_t write_pack_header (struct hashfile *f,uint32_t ); +void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); +char *index_pack_lockfile (int fd);/* * The "hdr" output buffer should be at least this big, which will handle sizes * up to 2^67. */ #define MAX_PACK_OBJECT_HEADER 10 -extern int encode_in_pack_object_header (unsigned char *hdr,int hdr_len, +int encode_in_pack_object_header (unsigned char *hdr,int hdr_len,enum object_type ,uintmax_t );#define PH_ERROR_EOF (-1)#define PH_ERROR_PACK_SIGNATURE (-2)#define PH_ERROR_PROTOCOL (-3) -extern int read_pack_header (int fd,struct pack_header *); +int read_pack_header (int fd,struct pack_header *); -extern struct hashfile *create_tmp_packfile (char **pack_tmp_name); -extern void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]); +struct hashfile *create_tmp_packfile (char **pack_tmp_name); +void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]);#endif
packfile.h +37 -37
133 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.921.gb27c68c4e9
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 1/3] *.[ch]: remove extern from function declarations using spatch
On 04/15, Denton Liu wrote:
[...]
archive.h struct archiver { · line 57
Quoted 7 lines
archive.h +2
-2-extern int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); -extern void *object_file_to_archive (const struct archiver_args *args, +int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); +void *object_file_to_archive (const struct archiver_args *args,const char *path,const struct object_id *oid,unsigned int mode,enum object_type *type,unsigned long *sizep);
Just skimming this patch, I notice that this now leaves a bunch of oddly indented parameter lists behind. We might want to re-indent those as well, as part of this patch or a follow up patch (so this patch can remain purely mechanical).
Personally I dislike this inconsistent indentation more than the extern keyword, but not sure how others feel about it.
PATCH v2 2/3 *.[ch]: remove extern from function declarations using sed
In reply to Denton LiuThere 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} | xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/'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.
--- cache.h | 4 ++-- commit.h | 2 +- compat/nedmalloc/malloc.c.h | 2 +- config.h | 2 +- exec-cmd.h | 2 +- git-compat-util.h | 20 ++++++++++---------- khash.h | 14 +++++++------- path.h | 30 +++++++++++++++--------------- quote.h | 2 +- run-command.h | 2 +- trace.h | 18 +++++++++--------- worktree.h | 2 +- 12 files changed, 50 insertions(+), 50 deletions(-)
cache.h +2 -2
@@ -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)
@@ -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 );
commit.h +1 -1
@@ -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 */
compat/nedmalloc/malloc.c.h +1 -1
@@ -1899,7 +1899,7 @@ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER;/* skipped internal declaration from pthread.h */ #ifdef linux#ifndef PTHREAD_MUTEX_RECURSIVE -extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, +int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, int __kind));#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP#define pthread_mutexattr_settype (x,y) pthread_mutexattr_setkind_np(x,y)
config.h +1 -1
@@ -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) \
exec-cmd.h +1 -1
@@ -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 */
git-compat-util.h +10 -10
@@ -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
@@ -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
@@ -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);
@@ -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
khash.h +7 -7
@@ -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) { \
path.h +15 -15
@@ -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 )));/*
@@ -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 )));
@@ -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 )));
@@ -66,7 +66,7 @@ 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 )));
@@ -74,7 +74,7 @@ extern char *repo_git_path(const struct repository *repo,* 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 )));
@@ -83,13 +83,13 @@ 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 )));/*
@@ -97,14 +97,14 @@ extern char *git_pathdup(const char *fmt, ...)* 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 )));/*
@@ -112,7 +112,7 @@ extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)* * 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 )));
@@ -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 )));
@@ -131,7 +131,7 @@ 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 )));/*
@@ -139,7 +139,7 @@ extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)* 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 )));
quote.h +1 -1
@@ -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
run-command.h +1 -1
@@ -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
trace.h +9 -9
@@ -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, ...);
@@ -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) {
worktree.h +1 -1
@@ -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 )));
Signature · 1 line
2.21.0.921.gb27c68c4e9
PATCH v2 3/3 cocci: prevent extern function declarations
In reply to Denton LiuSince function declarations already implicitly imply extern, create a Coccinelle rule which removes the redundant extern.
--- contrib/coccinelle/noextern.cocci | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 contrib/coccinelle/noextern.cocci
contrib/coccinelle/noextern.cocci new file +6 -0
@@ -0,0 +1,6 @@ +@@ +type T; +identifier f; +@@ +- extern + T f(...);
Signature · 1 line
2.21.0.921.gb27c68c4e9
v3 cover remove extern from function declarations
In reply to Denton LiuHi Thomas,
Thanks for the feedback. I couldn't find a tool that could selectively fix indentation on patches so I went through and manually realigned the parameter lists wherever the tools mangled the alignment. I guess this also implies that one pair of (tired) human eyes has manually inspected the machine-generated diff.
Hopefully, patch 3/4 won't be as onerous to review as it was to write ;)
---
Changes since v1:
* Used spatch with sed instead of sed alone
* Fixed sed expression to ignore function variables
Changes since v2:
* Rebased on latest master (since last patchset hasn't been picked up yet)
* Manually aligned parameter lists that were mangled by the tools
Denton Liu (4):
*.[ch]: remove extern from function declarations using spatch *.[ch]: remove extern from function declarations using sed *.[ch]: manually align parameter lists
cocci: prevent extern function declarations
advice.h | 2 +- archive.h | 24 +- bisect.h | 26 +- blame.h | 2 +- branch.h | 14 +- builtin.h | 254 ++++++++++---------- bulk-checkin.h | 10 +- cache.h | 386 +++++++++++++++--------------- checkout.h | 6 +- column.h | 16 +- commit.h | 116 ++++----- compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 14 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 66 ++--- compat/win32/pthread.h | 8 +- config.h | 226 ++++++++--------- connect.h | 22 +- contrib/coccinelle/noextern.cocci | 6 + csum-file.h | 20 +- decorate.h | 4 +- delta.h | 14 +- dir.h | 144 +++++------ exec-cmd.h | 16 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 132 +++++----- grep.h | 22 +- hashmap.h | 30 +-- help.h | 36 +-- http.h | 62 ++--- khash.h | 16 +- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 12 +- ls-refs.h | 4 +- mailinfo.h | 6 +- merge-blobs.h | 6 +- object-store.h | 32 +-- object.h | 12 +- oidmap.h | 12 +- pack.h | 26 +- packfile.h | 82 +++---- path.h | 42 ++-- pkt-line.h | 10 +- ppc/sha1.c | 4 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 34 +-- reachable.h | 8 +- reflog-walk.h | 28 +-- refs.h | 2 +- remote.h | 24 +- replace-object.h | 4 +- resolve-undo.h | 14 +- run-command.h | 8 +- serve.h | 6 +- sha1-lookup.h | 8 +- streaming.h | 8 +- string-list.h | 4 +- sub-process.h | 8 +- submodule-config.h | 22 +- tag.h | 16 +- tempfile.h | 30 +-- trace.h | 44 ++-- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 8 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 4 +- worktree.h | 36 +-- xdiff-interface.h | 12 +- 79 files changed, 1197 insertions(+), 1191 deletions(-) create mode 100644 contrib/coccinelle/noextern.cocci
Signature · 1 line
2.21.0.832.gd5ec0d3bee
PATCH v3 1/4 *.[ch]: remove extern from function declarations using spatch
There has been a push to remove extern from function declarations. Remove some instances of "extern" for function declarations which are caught by Coccinelle. Note that Coccinelle has some difficulty with processing functions with __attribute__ or varargs so some extern declarations are left behind to be dealt with in a future patch.
This was the Coccinelle patch used:
@@ type T; identifier f; @@ - extern T f(...);
and it was run with:
$ spatch --sp-file contrib/coccinelle/noextern.cocci --dir . --include-headers --in-place
--- advice.h | 2 +- archive.h | 14 +- bisect.h | 12 +- blame.h | 2 +- branch.h | 12 +- builtin.h | 252 +++++++++++++------------- bulk-checkin.h | 6 +- cache.h | 340 ++++++++++++++++++------------------ checkout.h | 2 +- column.h | 12 +- commit.h | 70 ++++---- compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 8 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 28 +-- compat/win32/pthread.h | 6 +- config.h | 182 +++++++++---------- connect.h | 20 +-- csum-file.h | 20 +-- decorate.h | 4 +- delta.h | 10 +- dir.h | 70 ++++---- exec-cmd.h | 14 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 108 ++++++------ grep.h | 22 +-- hashmap.h | 30 ++-- help.h | 30 ++-- http.h | 52 +++--- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 10 +- ls-refs.h | 2 +- mailinfo.h | 6 +- merge-blobs.h | 2 +- object-store.h | 16 +- object.h | 12 +- oidmap.h | 10 +- pack.h | 24 +-- packfile.h | 74 ++++---- path.h | 2 +- pkt-line.h | 6 +- ppc/sha1.c | 2 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 30 ++-- reachable.h | 4 +- reflog-walk.h | 16 +- refs.h | 2 +- remote.h | 12 +- replace-object.h | 2 +- resolve-undo.h | 14 +- run-command.h | 6 +- serve.h | 4 +- sha1-lookup.h | 2 +- streaming.h | 8 +- string-list.h | 2 +- sub-process.h | 2 +- submodule-config.h | 20 +-- tag.h | 14 +- tempfile.h | 26 +-- trace.h | 16 +- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 4 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 2 +- worktree.h | 20 +-- xdiff-interface.h | 10 +- 77 files changed, 914 insertions(+), 914 deletions(-)
advice.h +1 -1
@@ -31,7 +31,7 @@ int git_default_advice_config(const char *var, const char *value); __attribute__((format (printf,1 ,2 )))void advise (const char *advice, ...);int error_resolve_conflict (const char *me); -extern void NORETURN die_resolve_conflict(const char *me); +void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void);void detach_advice (const char *new_name);
archive.h +7 -7
@@ -23,7 +23,7 @@ struct archiver_args {/* main api */ -extern int write_archive (int argc,const char **argv,const char *prefix, +int write_archive (int argc,const char **argv,const char *prefix,struct repository *repo,const char *name_hint,int remote);
@@ -39,19 +39,19 @@ struct archiver {unsigned flags;void *data; }; -extern void register_archiver (struct archiver *); +void register_archiver (struct archiver *); -extern void init_tar_archiver (void ); -extern void init_zip_archiver (void ); -extern void init_archivers (void ); +void init_tar_archiver (void ); +void init_zip_archiver (void ); +void init_archivers (void );typedef int (*write_archive_entry_fn_t )(struct archiver_args *args,const struct object_id *oid,const char *path,size_t pathlen,unsigned int mode); -extern int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); -extern void *object_file_to_archive (const struct archiver_args *args, +int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); +void *object_file_to_archive (const struct archiver_args *args,const char *path,const struct object_id *oid,unsigned int mode,enum object_type *type,unsigned long *sizep);
bisect.h +6 -6
@@ -11,10 +11,10 @@ struct repository;* Otherwise, it will be either all non-SAMETREE commits or the single * best commit, as chosen by `find_all`. */ -extern void find_bisection (struct commit_list **list,int *reaches,int *all, +void find_bisection (struct commit_list **list,int *reaches,int *all,int find_all); -extern struct commit_list *filter_skipped(struct commit_list *list, +struct commit_list *filter_skipped(struct commit_list *list, struct commit_list **tried, int show_all, int *count,
@@ -31,14 +31,14 @@ struct rev_list_info { const char *header_prefix; }; -extern int bisect_next_all (struct repository *r, +int bisect_next_all (struct repository *r,const char *prefix,int no_checkout); -extern int estimate_bisect_steps (int all); +int estimate_bisect_steps (int all); -extern void read_bisect_terms (const char **bad,const char **good); +void read_bisect_terms (const char **bad,const char **good); -extern int bisect_clean_state (void ); +int bisect_clean_state (void );#endif
blame.h +1 -1
@@ -177,6 +177,6 @@ struct blame_entry *blame_entry_prepend(struct blame_entry *head, long start, long end, struct blame_origin *o); -extern struct blame_origin *get_blame_suspects (struct commit *commit); +struct blame_origin *get_blame_suspects (struct commit *commit);#endif /* BLAME_H */
branch.h +6 -6
@@ -50,7 +50,7 @@ void create_branch(struct repository *r,* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_branchname (const char *name,struct strbuf *ref); +int validate_branchname (const char *name,struct strbuf *ref);/* * Check if a branch 'name' can be created as a new branch; die otherwise.
@@ -58,7 +58,7 @@ extern int validate_branchname(const char *name, struct strbuf *ref);* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_new_branchname (const char *name,struct strbuf *ref,int force); +int validate_new_branchname (const char *name,struct strbuf *ref,int force);/* * Remove information about the state of working on the current
@@ -72,26 +72,26 @@ void remove_branch_state(struct repository *r);* Returns 0 on success. */ #define BRANCH_CONFIG_VERBOSE 01 -extern int install_branch_config (int flag,const char *local,const char *origin,const char *remote); +int install_branch_config (int flag,const char *local,const char *origin,const char *remote);/* * Read branch description */ -extern int read_branch_desc (struct strbuf *,const char *branch_name); +int read_branch_desc (struct strbuf *,const char *branch_name);/* * Check if a branch is checked out in the main worktree or any linked * worktree and die (with a message describing its checkout location) if * it is. */ -extern void die_if_checked_out (const char *branch,int ignore_current_worktree); +void die_if_checked_out (const char *branch,int ignore_current_worktree);/* * Update all per-worktree HEADs pointing at the old ref to point the new ref. * This will be used when renaming a branch. Returns 0 if successful, non-zero * otherwise. */ -extern int replace_each_worktree_head_symref (const char *oldref,const char *newref, +int replace_each_worktree_head_symref (const char *oldref,const char *newref,const char *logmsg);#endif
builtin.h +126 -126
271 lines not on this page · raw message
bulk-checkin.h +3 -3
@@ -6,11 +6,11 @@#include "cache.h" -extern int index_bulk_checkin (struct object_id *oid, +int index_bulk_checkin (struct object_id *oid,int fd,size_t size,enum object_type type,const char *path,unsigned flags); -extern void plug_bulk_checkin (void ); -extern void unplug_bulk_checkin (void ); +void plug_bulk_checkin (void ); +void unplug_bulk_checkin (void );#endif
cache.h +170 -170
663 lines not on this page · raw message
checkout.h +1 -1
@@ -8,7 +8,7 @@* tracking branch. Return the name of the remote if such a branch * exists, NULL otherwise. */ -extern const char *unique_tracking_name (const char *name, +const char *unique_tracking_name (const char *name,struct object_id *oid,int *dwim_remotes_matched);
column.h +6 -6
@@ -27,20 +27,20 @@ struct column_options { };struct option ; -extern int parseopt_column_callback (const struct option *,const char *,int ); -extern int git_column_config (const char *var,const char *value, +int parseopt_column_callback (const struct option *,const char *,int ); +int git_column_config (const char *var,const char *value,const char *command,unsigned int *colopts); -extern int finalize_colopts (unsigned int *colopts,int stdout_is_tty); +int finalize_colopts (unsigned int *colopts,int stdout_is_tty);static inline int column_active (unsigned int colopts) {return (colopts &COL_ENABLE_MASK ) ==COL_ENABLED ; }struct string_list ; -extern void print_columns (const struct string_list *list,unsigned int colopts, +void print_columns (const struct string_list *list,unsigned int colopts,const struct column_options *opts); -extern int run_column_filter (int colopts,const struct column_options *); -extern int stop_column_filter (void ); +int run_column_filter (int colopts,const struct column_options *); +int stop_column_filter (void );#endif
commit.h +35 -35
155 lines not on this page · raw message
compat/mingw.c +1 -1
@@ -2483,7 +2483,7 @@ typedef struct {int newmode; } _startupinfo; -extern int __wgetmainargs (int *argc,wchar_t ***argv,wchar_t ***env,int glob, +int __wgetmainargs (int *argc,wchar_t ***argv,wchar_t ***env,int glob,_startupinfo *si); static NORETURN void die_startup(void)
compat/mingw.h +3 -3
@@ -11,7 +11,7 @@ typedef _sigset_t sigset_t;#undef _POSIX_THREAD_SAFE_FUNCTIONS#endif -extern int mingw_core_config (const char *var,const char *value,void *cb); +int mingw_core_config (const char *var,const char *value,void *cb);#define platform_core_config mingw_core_config/*
@@ -449,7 +449,7 @@ static inline void convert_slashes(char *path) *path ='/' ; }#define PATH_SEP ';' -extern char *mingw_query_user_email (void ); +char *mingw_query_user_email (void );#define query_user_email mingw_query_user_email#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"
@@ -586,4 +586,4 @@ static int mingw_main(c,v)/* * Used by Pthread API implementation for Windows */ -extern int err_win_to_posix (DWORD winerr); +int err_win_to_posix (DWORD winerr);
compat/nedmalloc/malloc.c.h +3 -3
@@ -1327,7 +1327,7 @@ int mspace_mallopt(int, int);#include <unistd.h> /* for sbrk, sysconf */ #else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void *sbrk (ptrdiff_t ); +void *sbrk (ptrdiff_t );#endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */
@@ -1444,7 +1444,7 @@ unsigned char _BitScanReverse(unsigned long *index, unsigned long mask);# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)# else # if defined(BSD ) || defined(DGUX ) || defined(HAVE_GETPAGESIZE ) -extern size_t getpagesize (); +size_t getpagesize ();# define malloc_getpagesize getpagesize()# else # ifdef WIN32 /* use supplied emulation of getpagesize */
@@ -1899,7 +1899,7 @@ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER;/* skipped internal declaration from pthread.h */ #ifdef linux#ifndef PTHREAD_MUTEX_RECURSIVE -extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, +int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, int __kind));#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP#define pthread_mutexattr_settype (x,y) pthread_mutexattr_setkind_np(x,y)
compat/obstack.h +4 -4
@@ -182,13 +182,13 @@ struct obstack /* control current object in current chunk *//* Declare the external functions we use; they are in obstack.c. */ -extern void _obstack_newchunk (struct obstack *,int ); -extern int _obstack_begin (struct obstack *,int ,int , +void _obstack_newchunk (struct obstack *,int ); +int _obstack_begin (struct obstack *,int ,int ,void *(*) (long ),void (*) (void *)); -extern int _obstack_begin_1 (struct obstack *,int ,int , +int _obstack_begin_1 (struct obstack *,int ,int ,void *(*) (void *,long ),void (*) (void *,void *),void *); -extern int _obstack_memory_used (struct obstack *); +int _obstack_memory_used (struct obstack *);void obstack_free (struct obstack *,void *);
compat/poll/poll.h +1 -1
@@ -57,7 +57,7 @@ struct pollfdtypedef unsigned long nfds_t ; -extern int poll (struct pollfd *pfd,nfds_t nfd,int timeout); +int poll (struct pollfd *pfd,nfds_t nfd,int timeout);/* Define INFTIM only if doing so conforms to POSIX. */ #if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
compat/regex/regex.h +14 -14
@@ -465,19 +465,19 @@ typedef struct#ifdef __USE_GNU/* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); +reg_syntax_t re_set_syntax (reg_syntax_t __syntax);/* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern (const char *__pattern,size_t __length, +const char *re_compile_pattern (const char *__pattern,size_t __length,struct re_pattern_buffer *__buffer);/* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); +int re_compile_fastmap (struct re_pattern_buffer *__buffer);/* Search in the string STRING (with length LENGTH) for the pattern
@@ -485,14 +485,14 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search (struct re_pattern_buffer *__buffer,const char *__cstring, +int re_search (struct re_pattern_buffer *__buffer,const char *__cstring,int __length,int __start,int __range,struct re_registers *__regs);/* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 (struct re_pattern_buffer *__buffer, +int re_search_2 (struct re_pattern_buffer *__buffer,const char *__string1,int __length1,const char *__string2,int __length2,int __start,int __range,struct re_registers *__regs,int __stop);
@@ -500,12 +500,12 @@ extern int re_search_2 (struct re_pattern_buffer *__buffer,/* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern int re_match (struct re_pattern_buffer *__buffer,const char *__cstring, +int re_match (struct re_pattern_buffer *__buffer,const char *__cstring,int __length,int __start,struct re_registers *__regs);/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 (struct re_pattern_buffer *__buffer, +int re_match_2 (struct re_pattern_buffer *__buffer,const char *__string1,int __length1,const char *__string2,int __length2,int __start,struct re_registers *__regs,int __stop);
@@ -523,7 +523,7 @@ extern int re_match_2 (struct re_pattern_buffer *__buffer,Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ -extern void re_set_registers (struct re_pattern_buffer *__buffer, +void re_set_registers (struct re_pattern_buffer *__buffer,struct re_registers *__regs,unsigned int __num_regs,regoff_t *__starts,regoff_t *__ends);
@@ -532,8 +532,8 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)# ifndef _CRAY/* 4.2 bsd compatibility. */ -extern char *re_comp (const char *); -extern int re_exec (const char *); +char *re_comp (const char *); +int re_exec (const char *);# endif #endif
@@ -559,19 +559,19 @@ extern int re_exec (const char *);#endif /* POSIX compatibility. */ -extern int regcomp (regex_t *__restrict __preg, +int regcomp (regex_t *__restrict __preg,const char *__restrict __pattern,int __cflags); -extern int regexec (const regex_t *__restrict __preg, +int regexec (const regex_t *__restrict __preg,const char *__restrict __cstring,size_t __nmatch,regmatch_t __pmatch[__restrict_arr],int __eflags); -extern size_t regerror (int __errcode,const regex_t *__restrict __preg, +size_t regerror (int __errcode,const regex_t *__restrict __preg,char *__restrict __errbuf,size_t __errbuf_size); -extern void regfree (regex_t *__preg); +void regfree (regex_t *__preg);#ifdef __cplusplus
compat/win32/pthread.h +3 -3
@@ -50,7 +50,7 @@ typedef struct {DWORD tid; } pthread_t; -extern int pthread_create (pthread_t *thread,const void *unused, +int pthread_create (pthread_t *thread,const void *unused,void *(*start_routine)(void *),void *arg);/*
@@ -59,10 +59,10 @@ extern int pthread_create(pthread_t *thread, const void *unused,*/ #define pthread_join (a, b) win32_pthread_join(&(a), (b)) -extern int win32_pthread_join (pthread_t *thread,void **value_ptr); +int win32_pthread_join (pthread_t *thread,void **value_ptr);#define pthread_equal (t1, t2) ((t1).tid == (t2).tid) -extern pthread_t pthread_self (void ); +pthread_t pthread_self (void ); static inline void NORETURN pthread_exit(void *ret) {
config.h +91 -91
254 lines not on this page · raw message
connect.h +10 -10
@@ -7,19 +7,19 @@#define CONNECT_DIAG_URL (1u << 1)#define CONNECT_IPV4 (1u << 2)#define CONNECT_IPV6 (1u << 3) -extern struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); -extern int finish_connect (struct child_process *conn); -extern int git_connection_is_socket (struct child_process *conn); -extern int server_supports (const char *feature); -extern int parse_feature_request (const char *features,const char *feature); -extern const char *server_feature_value (const char *feature,int *len_ret); -extern int url_is_local_not_ssh (const char *url); +struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); +int finish_connect (struct child_process *conn); +int git_connection_is_socket (struct child_process *conn); +int server_supports (const char *feature); +int parse_feature_request (const char *features,const char *feature); +const char *server_feature_value (const char *feature,int *len_ret); +int url_is_local_not_ssh (const char *url);struct packet_reader ; -extern enum protocol_version discover_version (struct packet_reader *reader); +enum protocol_version discover_version (struct packet_reader *reader); -extern int server_supports_v2 (const char *c,int die_on_error); -extern int server_supports_feature (const char *c,const char *feature, +int server_supports_v2 (const char *c,int die_on_error); +int server_supports_feature (const char *c,const char *feature,int die_on_error);#endif
csum-file.h +10 -10
@@ -25,22 +25,22 @@ struct hashfile_checkpoint {git_hash_ctx ctx; }; -extern void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); -extern int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *); +void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); +int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *);/* finalize_hashfile flags */ #define CSUM_CLOSE 1#define CSUM_FSYNC 2#define CSUM_HASH_IN_STREAM 4 -extern struct hashfile *hashfd (int fd,const char *name); -extern struct hashfile *hashfd_check (const char *name); -extern struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); -extern int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); -extern void hashwrite (struct hashfile *,const void *,unsigned int ); -extern void hashflush (struct hashfile *f); -extern void crc32_begin (struct hashfile *); -extern uint32_t crc32_end (struct hashfile *); +struct hashfile *hashfd (int fd,const char *name); +struct hashfile *hashfd_check (const char *name); +struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); +int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); +void hashwrite (struct hashfile *,const void *,unsigned int ); +void hashflush (struct hashfile *f); +void crc32_begin (struct hashfile *); +uint32_t crc32_end (struct hashfile *);static inline void hashwrite_u8 (struct hashfile *f,uint8_t data) {
decorate.h +2 -2
@@ -50,12 +50,12 @@ struct decoration {* NULL), returning the previously associated pointer. If there is no previous * association, this function returns NULL. */ -extern void *add_decoration (struct decoration *n,const struct object *obj,void *decoration); +void *add_decoration (struct decoration *n,const struct object *obj,void *decoration);/* * Return the pointer associated to the given object. If there is no * association, this function returns NULL. */ -extern void *lookup_decoration (struct decoration *n,const struct object *obj); +void *lookup_decoration (struct decoration *n,const struct object *obj);#endif
delta.h +5 -5
@@ -13,7 +13,7 @@ struct delta_index;* before free_delta_index() is called. The returned pointer must be freed * using free_delta_index(). */ -extern struct delta_index * +struct delta_index *create_delta_index (const void *buf,unsigned long bufsize);/*
@@ -21,14 +21,14 @@ create_delta_index(const void *buf, unsigned long bufsize);* * Given pointer must be what create_delta_index() returned, or NULL. */ -extern void free_delta_index (struct delta_index *index); +void free_delta_index (struct delta_index *index);/* * sizeof_delta_index: returns memory usage of delta index * * Given pointer must be what create_delta_index() returned, or NULL. */ -extern unsigned long sizeof_delta_index (struct delta_index *index); +unsigned long sizeof_delta_index (struct delta_index *index);/* * create_delta: create a delta from given index for the given buffer
@@ -40,7 +40,7 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);* returned and *delta_size is updated with its size. The returned buffer * must be freed by the caller. */ -extern void * +void *create_delta (const struct delta_index *index,const void *buf,unsigned long bufsize,unsigned long *delta_size,unsigned long max_delta_size);
@@ -75,7 +75,7 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,* *trg_bufsize is updated with its size. On failure a NULL pointer is * returned. The returned buffer must be freed by the caller. */ -extern void *patch_delta (const void *src_buf,unsigned long src_size, +void *patch_delta (const void *src_buf,unsigned long src_size,const void *delta_buf,unsigned long delta_size,unsigned long *dst_size);
dir.h +35 -35
145 lines not on this page · raw message
exec-cmd.h +7 -7
@@ -3,14 +3,14 @@struct argv_array ; -extern void git_set_exec_path (const char *exec_path); -extern void git_resolve_executable_dir (const char *path); -extern const char *git_exec_path (void ); -extern void setup_path (void ); -extern const char **prepare_git_cmd (struct argv_array *out,const char **argv); -extern int execv_git_cmd (const char **argv);/* NULL terminated */ +void git_set_exec_path (const char *exec_path); +void git_resolve_executable_dir (const char *path); +const char *git_exec_path (void ); +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, ...); -extern char *system_path (const char *path); +char *system_path (const char *path);#endif /* GIT_EXEC_CMD_H */
fmt-merge-msg.h +1 -1
@@ -2,6 +2,6 @@#define FMT_MERGE_MSG_H extern int merge_log_config; -extern int fmt_merge_msg_config (const char *key,const char *value,void *cb); +int fmt_merge_msg_config (const char *key,const char *value,void *cb);#endif /* FMT_MERGE_MSG_H */
fsmonitor.h +7 -7
@@ -10,31 +10,31 @@ extern struct trace_key trace_fsmonitor;* Read the fsmonitor index extension and (if configured) restore the * CE_FSMONITOR_VALID state. */ -extern int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz); +int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz);/* * Fill the fsmonitor_dirty ewah bits with their state from the index, * before it is split during writing. */ -extern void fill_fsmonitor_bitmap (struct index_state *istate); +void fill_fsmonitor_bitmap (struct index_state *istate);/* * Write the CE_FSMONITOR_VALID state into the fsmonitor index * extension. Reads from the fsmonitor_dirty ewah in the index. */ -extern void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate); +void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate);/* * Add/remove the fsmonitor index extension */ -extern void add_fsmonitor (struct index_state *istate); -extern void remove_fsmonitor (struct index_state *istate); +void add_fsmonitor (struct index_state *istate); +void remove_fsmonitor (struct index_state *istate);/* * Add/remove the fsmonitor index extension as necessary based on the current * core.fsmonitor setting. */ -extern void tweak_fsmonitor (struct index_state *istate); +void tweak_fsmonitor (struct index_state *istate);/* * Run the configured fsmonitor integration script and clear the
@@ -42,7 +42,7 @@ extern void tweak_fsmonitor(struct index_state *istate);* any corresponding untracked cache directory structures. Optimized to only * run the first time it is called. */ -extern void refresh_fsmonitor (struct index_state *istate); +void refresh_fsmonitor (struct index_state *istate);/* * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
gettext.h +4 -4
@@ -28,11 +28,11 @@#define FORMAT_PRESERVING (n) __attribute__((format_arg(n))) -extern int use_gettext_poison (void ); +int use_gettext_poison (void );#ifndef NO_GETTEXT -extern void git_setup_gettext (void ); -extern int gettext_width (const char *s); +void git_setup_gettext (void ); +int gettext_width (const char *s);#else static inline void git_setup_gettext (void ) {
@@ -87,6 +87,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)#endif const char *get_preferred_languages (void ); -extern int is_utf8_locale (void ); +int is_utf8_locale (void );#endif
git-compat-util.h +54 -54
242 lines not on this page · raw message
grep.h +11 -11
@@ -186,17 +186,17 @@ struct grep_opt {void *output_priv; }; -extern void init_grep_defaults (struct repository *); -extern int grep_config (const char *var,const char *value,void *); -extern void grep_init (struct grep_opt *,struct repository *repo,const char *prefix); +void init_grep_defaults (struct repository *); +int grep_config (const char *var,const char *value,void *); +void grep_init (struct grep_opt *,struct repository *repo,const char *prefix);void grep_commit_pattern_type (enum grep_pattern_type ,struct grep_opt *opt); -extern void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); -extern void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); -extern void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); -extern void compile_grep_patterns (struct grep_opt *opt); -extern void free_grep_patterns (struct grep_opt *opt); -extern int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size); +void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); +void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); +void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); +void compile_grep_patterns (struct grep_opt *opt); +void free_grep_patterns (struct grep_opt *opt); +int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size);struct grep_source {char *name;
@@ -226,8 +226,8 @@ void grep_source_load_driver(struct grep_source *gs,int grep_source (struct grep_opt *opt,struct grep_source *gs); -extern struct grep_opt *grep_opt_dup (const struct grep_opt *opt); -extern int grep_threads_ok (const struct grep_opt *opt); +struct grep_opt *grep_opt_dup (const struct grep_opt *opt); +int grep_threads_ok (const struct grep_opt *opt);/* * Mutex used around access to the attributes machinery if
hashmap.h +15 -15
@@ -104,11 +104,11 @@* `memihash_cont` is a variant of `memihash` that allows a computation to be * continued with another chunk of data. */ -extern unsigned int strhash (const char *buf); -extern unsigned int strihash (const char *buf); -extern unsigned int memhash (const void *buf,size_t len); -extern unsigned int memihash (const void *buf,size_t len); -extern unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len); +unsigned int strhash (const char *buf); +unsigned int strihash (const char *buf); +unsigned int memhash (const void *buf,size_t len); +unsigned int memihash (const void *buf,size_t len); +unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len);/* * Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code
@@ -216,7 +216,7 @@ struct hashmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void hashmap_init (struct hashmap *map, +void hashmap_init (struct hashmap *map,hashmap_cmp_fn equals_function,const void *equals_function_data,size_t initial_size);
@@ -227,7 +227,7 @@ extern void hashmap_init(struct hashmap *map,* If `free_entries` is true, each hashmap_entry in the map is freed as well * using stdlibs free(). */ -extern void hashmap_free (struct hashmap *map,int free_entries); +void hashmap_free (struct hashmap *map,int free_entries);/* hashmap_entry functions */
@@ -284,7 +284,7 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)* If an entry with matching hash code is found, `key` and `keydata` are passed * to `hashmap_cmp_fn` to decide whether the entry matches the key. */ -extern void *hashmap_get (const struct hashmap *map,const void *key, +void *hashmap_get (const struct hashmap *map,const void *key,const void *keydata);/*
@@ -316,7 +316,7 @@ static inline void *hashmap_get_from_hash(const struct hashmap *map,* `entry` is the hashmap_entry to start the search from, obtained via a previous * call to `hashmap_get` or `hashmap_get_next`. */ -extern void *hashmap_get_next (const struct hashmap *map,const void *entry); +void *hashmap_get_next (const struct hashmap *map,const void *entry);/* * Adds a hashmap entry. This allows to add duplicate entries (i.e.
@@ -325,7 +325,7 @@ extern void *hashmap_get_next(const struct hashmap *map, const void *entry);* `map` is the hashmap structure. * `entry` is the entry to add. */ -extern void hashmap_add (struct hashmap *map,void *entry); +void hashmap_add (struct hashmap *map,void *entry);/* * Adds or replaces a hashmap entry. If the hashmap contains duplicate
@@ -335,7 +335,7 @@ extern void hashmap_add(struct hashmap *map, void *entry);* `entry` is the entry to add or replace. * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *hashmap_put (struct hashmap *map,void *entry); +void *hashmap_put (struct hashmap *map,void *entry);/* * Removes a hashmap entry matching the specified key. If the hashmap contains
@@ -344,7 +344,7 @@ extern void *hashmap_put(struct hashmap *map, void *entry);* * Argument explanation is the same as in `hashmap_get`. */ -extern void *hashmap_remove (struct hashmap *map,const void *key, +void *hashmap_remove (struct hashmap *map,const void *key,const void *keydata);/*
@@ -365,10 +365,10 @@ struct hashmap_iter { };/* Initializes a `hashmap_iter` structure. */ -extern void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter); +void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter);/* Returns the next hashmap_entry, or NULL if there are no more entries. */ -extern void *hashmap_iter_next (struct hashmap_iter *iter); +void *hashmap_iter_next (struct hashmap_iter *iter);/* Initializes the iterator and returns the first entry, if any. */ static inline void *hashmap_iter_first(struct hashmap *map,
@@ -429,7 +429,7 @@ static inline void hashmap_enable_item_counting(struct hashmap *map)* * Uses a hashmap to store the pool of interned strings. */ -extern const void *memintern (const void *data,size_t len); +const void *memintern (const void *data,size_t len);static inline const char *strintern (const char *string) {return memintern (string,strlen (string));
help.h +15 -15
@@ -19,31 +19,31 @@ static inline void mput_char(char c, unsigned int num)putchar (c); } -extern void list_common_cmds_help (void ); -extern void list_all_cmds_help (void ); -extern void list_common_guides_help (void ); -extern void list_config_help (int for_human); +void list_common_cmds_help (void ); +void list_all_cmds_help (void ); +void list_common_guides_help (void ); +void list_config_help (int for_human); -extern void list_all_main_cmds (struct string_list *list); -extern void list_all_other_cmds (struct string_list *list); -extern void list_cmds_by_category (struct string_list *list, +void list_all_main_cmds (struct string_list *list); +void list_all_other_cmds (struct string_list *list); +void list_cmds_by_category (struct string_list *list,const char *category); -extern void list_cmds_by_config (struct string_list *list); -extern const char *help_unknown_cmd (const char *cmd); -extern void load_command_list (const char *prefix, +void list_cmds_by_config (struct string_list *list); +const char *help_unknown_cmd (const char *cmd); +void load_command_list (const char *prefix,struct cmdnames *main_cmds,struct cmdnames *other_cmds); -extern void add_cmdname (struct cmdnames *cmds,const char *name,int len); +void add_cmdname (struct cmdnames *cmds,const char *name,int len);/* Here we require that excludes is a sorted list. */ -extern void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); -extern int is_in_cmdlist (struct cmdnames *cmds,const char *name); -extern void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds); +void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); +int is_in_cmdlist (struct cmdnames *cmds,const char *name); +void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds);/* * call this to die(), when it is suspected that the user mistyped a * ref to the command, to give suggested "correct" refs. */ -extern void help_unknown_ref (const char *ref,const char *cmd,const char *error); +void help_unknown_ref (const char *ref,const char *cmd,const char *error); static inline void list_config_item(struct string_list *list, const char *prefix,
http.h +26 -26
101 lines not on this page · raw message
kwset.h +5 -5
@@ -37,16 +37,16 @@ typedef struct kwset_t* kwset_t;if enough memory cannot be obtained. The argument if non-NULL specifies a table of character translations to be applied to all pattern and search text. */ -extern kwset_t kwsalloc (unsigned char const *); +kwset_t kwsalloc (unsigned char const *);/* Incrementally extend the keyword set to include the given string. Return NULL for success, or an error message. Remember an index number for each keyword included in the set. */ -extern const char *kwsincr (kwset_t ,char const *,size_t ); +const char *kwsincr (kwset_t ,char const *,size_t );/* When the keyword set has been completely built, prepare it for use. Return NULL for success, or an error message. */ -extern const char *kwsprep (kwset_t ); +const char *kwsprep (kwset_t );/* Search through the given buffer for a member of the keyword set. Return a pointer to the leftmost longest match found, or NULL if
@@ -54,8 +54,8 @@ extern const char *kwsprep(kwset_t);the matching substring in the integer it points to. Similarly, if foundindex is non-NULL, store the index of the particular keyword found therein. */ -extern size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *); +size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *);/* Deallocate the given keyword set and all its associated storage. */ -extern void kwsfree (kwset_t ); +void kwsfree (kwset_t );
line-log.h +8 -8
@@ -25,17 +25,17 @@ struct diff_ranges {struct range_set target; }; -extern void range_set_init (struct range_set *,size_t prealloc); -extern void range_set_release (struct range_set *); +void range_set_init (struct range_set *,size_t prealloc); +void range_set_release (struct range_set *);/* Range includes start; excludes end */ -extern void range_set_append_unsafe (struct range_set *,long start,long end); +void range_set_append_unsafe (struct range_set *,long start,long end);/* New range must begin at or after end of last added range */ -extern void range_set_append (struct range_set *,long start,long end); +void range_set_append (struct range_set *,long start,long end);/* * In-place pass of sorting and merging the ranges in the range set, * to sort and make the ranges disjoint. */ -extern void sort_and_merge_range_set (struct range_set *); +void sort_and_merge_range_set (struct range_set *);/* Linked list of interesting files and their associated ranges. The * list must be kept sorted by path.
@@ -54,10 +54,10 @@ struct line_log_data { struct diff_ranges diff; }; -extern void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); +void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); -extern int line_log_filter (struct rev_info *rev); +int line_log_filter (struct rev_info *rev); -extern int line_log_print (struct rev_info *rev,struct commit *commit); +int line_log_print (struct rev_info *rev,struct commit *commit);#endif /* LINE_LOG_H */
lockfile.h +5 -5
@@ -159,7 +159,7 @@ struct lock_file {* timeout_ms is -1, retry indefinitely. The flags argument and error * handling are described above. */ -extern int hold_lock_file_for_update_timeout ( +int hold_lock_file_for_update_timeout (struct lock_file *lk,const char *path,int flags,long timeout_ms);
@@ -188,7 +188,7 @@ static inline int is_lock_file_locked(struct lock_file *lk)* of `hold_lock_file_for_update()` to lock `path`. `err` should be the * `errno` set by the failing call. */ -extern void unable_to_lock_message (const char *path,int err, +void unable_to_lock_message (const char *path,int err,struct strbuf *buf);/*
@@ -197,7 +197,7 @@ extern void unable_to_lock_message(const char *path, int err,* `errno` set by the failing * call. */ -extern NORETURN void unable_to_lock_die(const char *path, int err); +NORETURN void unable_to_lock_die(const char *path, int err);/* * Associate a stdio stream with the lockfile (which must still be
@@ -234,7 +234,7 @@ static inline FILE *get_lock_file_fp(struct lock_file *lk)* Return the path of the file that is locked by the specified * lock_file object. The caller must free the memory. */ -extern char *get_locked_file_path (struct lock_file *lk); +char *get_locked_file_path (struct lock_file *lk);/* * If the lockfile is still open, close it (and the file pointer if it
@@ -282,7 +282,7 @@ static inline int reopen_lock_file(struct lock_file *lk)* call `commit_lock_file()` for a `lock_file` object that is not * currently locked. */ -extern int commit_lock_file (struct lock_file *lk); +int commit_lock_file (struct lock_file *lk);/* * Like `commit_lock_file()`, but rename the lockfile to the provided
ls-refs.h +1 -1
@@ -4,7 +4,7 @@struct repository ;struct argv_array ;struct packet_reader ; -extern int ls_refs (struct repository *r,struct argv_array *keys, +int ls_refs (struct repository *r,struct argv_array *keys,struct packet_reader *request);#endif /* LS_REFS_H */
mailinfo.h +3 -3
@@ -39,8 +39,8 @@ struct mailinfo { int input_error; }; -extern void setup_mailinfo (struct mailinfo *); -extern int mailinfo (struct mailinfo *,const char *msg,const char *patch); -extern void clear_mailinfo (struct mailinfo *); +void setup_mailinfo (struct mailinfo *); +int mailinfo (struct mailinfo *,const char *msg,const char *patch); +void clear_mailinfo (struct mailinfo *);#endif /* MAILINFO_H */
merge-blobs.h +1 -1
@@ -4,7 +4,7 @@struct blob ;struct index_state ; -extern void *merge_blobs (struct index_state *,const char *, +void *merge_blobs (struct index_state *,const char *,struct blob *,struct blob *,struct blob *,unsigned long *);
object-store.h +8 -8
@@ -162,7 +162,7 @@ const char *loose_object_path(struct repository *r, struct strbuf *buf,void *map_loose_object (struct repository *r,const struct object_id *oid,unsigned long *size); -extern void *read_object_file_extended (struct repository *r, +void *read_object_file_extended (struct repository *r,const struct object_id *oid,enum object_type *type,unsigned long *size,int lookup_replace);
@@ -180,20 +180,20 @@ static inline void *repo_read_object_file(struct repository *r,/* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info (struct repository *r,const struct object_id *,unsigned long *); -extern int hash_object_file (const void *buf,unsigned long len, +int hash_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int write_object_file (const void *buf,unsigned long len, +int write_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int hash_object_file_literally (const void *buf,unsigned long len, +int hash_object_file_literally (const void *buf,unsigned long len,const char *type,struct object_id *oid,unsigned flags); -extern int pretend_object_file (void *,unsigned long ,enum object_type , +int pretend_object_file (void *,unsigned long ,enum object_type ,struct object_id *oid); -extern int force_object_loose (const struct object_id *oid,time_t mtime); +int force_object_loose (const struct object_id *oid,time_t mtime);/* * Open the loose object at path, check its hash, and return the contents,
@@ -227,9 +227,9 @@ int repo_has_object_file_with_flags(struct repository *r,* with the specified name. This function does not respect replace * references. */ -extern int has_loose_object_nonlocal (const struct object_id *); +int has_loose_object_nonlocal (const struct object_id *); -extern void assert_oid_type (const struct object_id *oid,enum object_type expect); +void assert_oid_type (const struct object_id *oid,enum object_type expect);struct object_info {/* Request */
object.h +6 -6
@@ -90,19 +90,19 @@ struct object {struct object_id oid; }; -extern const char *type_name (unsigned int type); -extern int type_from_string_gently (const char *str,ssize_t ,int gentle); +const char *type_name (unsigned int type); +int type_from_string_gently (const char *str,ssize_t ,int gentle);#define type_from_string (str) type_from_string_gently(str, -1, 0)/* * Return the current number of buckets in the object hashmap. */ -extern unsigned int get_max_object_index (void ); +unsigned int get_max_object_index (void );/* * Return the object from the specified bucket in the object hashmap. */ -extern struct object *get_indexed_object (unsigned int ); +struct object *get_indexed_object (unsigned int );/* * This can be used to see if we have heard of the object before, but
@@ -118,7 +118,7 @@ extern struct object *get_indexed_object(unsigned int);*/ struct object *lookup_object (struct repository *r,const unsigned char *sha1); -extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj); +void *create_object (struct repository *r,const unsigned char *sha1,void *obj);void *object_as_type (struct repository *r,struct object *obj,enum object_type type,int quiet);
@@ -189,6 +189,6 @@ void clear_object_flags(unsigned flags);/* * Clear the specified object flags from all in-core commit objects. */ -extern void clear_commit_marks_all (unsigned int flags); +void clear_commit_marks_all (unsigned int flags);#endif /* OBJECT_H */
oidmap.h +5 -5
@@ -33,7 +33,7 @@ struct oidmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void oidmap_init (struct oidmap *map,size_t initial_size); +void oidmap_init (struct oidmap *map,size_t initial_size);/* * Frees an oidmap structure and allocated memory.
@@ -41,12 +41,12 @@ extern void oidmap_init(struct oidmap *map, size_t initial_size);* If `free_entries` is true, each oidmap_entry in the map is freed as well * using stdlibs free(). */ -extern void oidmap_free (struct oidmap *map,int free_entries); +void oidmap_free (struct oidmap *map,int free_entries);/* * Returns the oidmap entry for the specified oid, or NULL if not found. */ -extern void *oidmap_get (const struct oidmap *map, +void *oidmap_get (const struct oidmap *map,const struct object_id *key);/*
@@ -57,14 +57,14 @@ extern void *oidmap_get(const struct oidmap *map,* * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *oidmap_put (struct oidmap *map,void *entry); +void *oidmap_put (struct oidmap *map,void *entry);/* * Removes an oidmap entry matching the specified oid. * * Returns the removed entry, or NULL if not found. */ -extern void *oidmap_remove (struct oidmap *map,const struct object_id *key); +void *oidmap_remove (struct oidmap *map,const struct object_id *key);struct oidmap_iter {
pack.h +12 -12
@@ -55,7 +55,7 @@ struct pack_idx_option {uint32_t *anomaly; }; -extern void reset_pack_idx_option (struct pack_idx_option *); +void reset_pack_idx_option (struct pack_idx_option *);/* * Packed object index header
@@ -79,28 +79,28 @@ struct progress;/* Note, the data argument could be NULL if object type is blob */ typedef int (*verify_fn )(const struct object_id *,enum object_type ,unsigned long ,void *,int *); -extern const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); -extern int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); -extern int verify_pack_index (struct packed_git *); -extern int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); -extern off_t write_pack_header (struct hashfile *f,uint32_t ); -extern void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); -extern char *index_pack_lockfile (int fd); +const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); +int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); +int verify_pack_index (struct packed_git *); +int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); +off_t write_pack_header (struct hashfile *f,uint32_t ); +void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); +char *index_pack_lockfile (int fd);/* * The "hdr" output buffer should be at least this big, which will handle sizes * up to 2^67. */ #define MAX_PACK_OBJECT_HEADER 10 -extern int encode_in_pack_object_header (unsigned char *hdr,int hdr_len, +int encode_in_pack_object_header (unsigned char *hdr,int hdr_len,enum object_type ,uintmax_t );#define PH_ERROR_EOF (-1)#define PH_ERROR_PACK_SIGNATURE (-2)#define PH_ERROR_PROTOCOL (-3) -extern int read_pack_header (int fd,struct pack_header *); +int read_pack_header (int fd,struct pack_header *); -extern struct hashfile *create_tmp_packfile (char **pack_tmp_name); -extern void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]); +struct hashfile *create_tmp_packfile (char **pack_tmp_name); +void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]);#endif
packfile.h +37 -37
125 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.832.gd5ec0d3bee
Part of the diff is not shown here. View the raw message.
PATCH v3 2/4 *.[ch]: remove extern from function declarations using sed
In reply to Denton LiuThere 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} | xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/'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.
--- cache.h | 4 ++-- commit.h | 2 +- config.h | 2 +- exec-cmd.h | 2 +- git-compat-util.h | 20 ++++++++++---------- khash.h | 14 +++++++------- path.h | 30 +++++++++++++++--------------- quote.h | 2 +- run-command.h | 2 +- trace.h | 18 +++++++++--------- worktree.h | 2 +- 11 files changed, 49 insertions(+), 49 deletions(-)
cache.h +2 -2
@@ -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)
@@ -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 );
commit.h +1 -1
@@ -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 */
config.h +1 -1
@@ -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) \
exec-cmd.h +1 -1
@@ -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 */
git-compat-util.h +10 -10
@@ -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
@@ -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
@@ -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);
@@ -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
khash.h +7 -7
@@ -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) { \
path.h +15 -15
@@ -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 )));/*
@@ -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 )));
@@ -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 )));
@@ -66,7 +66,7 @@ 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 )));
@@ -74,7 +74,7 @@ extern char *repo_git_path(const struct repository *repo,* 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 )));
@@ -83,13 +83,13 @@ 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 )));/*
@@ -97,14 +97,14 @@ extern char *git_pathdup(const char *fmt, ...)* 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 )));/*
@@ -112,7 +112,7 @@ extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)* * 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 )));
@@ -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 )));
@@ -131,7 +131,7 @@ 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 )));/*
@@ -139,7 +139,7 @@ extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)* 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 )));
quote.h +1 -1
@@ -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
run-command.h +1 -1
@@ -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
trace.h +9 -9
@@ -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, ...);
@@ -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) {
worktree.h +1 -1
@@ -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 )));
Signature · 1 line
2.21.0.832.gd5ec0d3bee
PATCH v3 3/4 *.[ch]: manually align parameter lists
In reply to Denton LiuIn previous patches, extern was mechanically removed from function declarations without care to formatting, causing parameter lists to be misaligned. Manually format changed sections such that the parameter lists should be realigned.
Viewing this patch with 'git diff -w' should produce no output.
--- archive.h | 10 +++---- bisect.h | 14 +++++----- branch.h | 2 +- builtin.h | 2 +- bulk-checkin.h | 4 +-- cache.h | 42 ++++++++++++++-------------- checkout.h | 4 +-- column.h | 4 +-- commit.h | 44 +++++++++++++++--------------- compat/obstack.h | 6 ++-- compat/regex/regex.h | 38 +++++++++++++------------- compat/win32/pthread.h | 2 +- config.h | 44 +++++++++++++++--------------- connect.h | 2 +- delta.h | 4 +-- dir.h | 62 +++++++++++++++++++++--------------------- git-compat-util.h | 4 +-- help.h | 6 ++-- http.h | 10 +++---- khash.h | 6 ++-- lockfile.h | 2 +- ls-refs.h | 2 +- merge-blobs.h | 4 +-- object-store.h | 16 +++++------ oidmap.h | 2 +- pack.h | 2 +- packfile.h | 8 +++--- path.h | 10 +++---- pkt-line.h | 4 +-- ppc/sha1.c | 2 +- quote.h | 2 +- reachable.h | 4 +-- reflog-walk.h | 12 ++++---- remote.h | 12 ++++---- replace-object.h | 2 +- serve.h | 2 +- sha1-lookup.h | 6 ++-- string-list.h | 2 +- sub-process.h | 6 ++-- submodule-config.h | 2 +- tag.h | 2 +- tempfile.h | 4 +-- trace.h | 10 +++---- upload-pack.h | 4 +-- vcs-svn/svndiff.h | 2 +- worktree.h | 14 +++++----- xdiff-interface.h | 2 +- 47 files changed, 225 insertions(+), 225 deletions(-)
archive.h +5 -5
@@ -24,8 +24,8 @@ struct archiver_args {/* main api */ int write_archive (int argc,const char **argv,const char *prefix, -struct repository *repo, -const char *name_hint,int remote); +struct repository *repo, +const char *name_hint,int remote);const char *archive_format_from_filename (const char *filename);
@@ -52,8 +52,8 @@ typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry);void *object_file_to_archive (const struct archiver_args *args, -const char *path,const struct object_id *oid, -unsigned int mode,enum object_type *type, -unsigned long *sizep); +const char *path,const struct object_id *oid, +unsigned int mode,enum object_type *type, +unsigned long *sizep);#endif /* ARCHIVE_H */
bisect.h +7 -7
@@ -12,13 +12,13 @@ struct repository;* best commit, as chosen by `find_all`. */ void find_bisection (struct commit_list **list,int *reaches,int *all, -int find_all); +int find_all);struct commit_list *filter_skipped (struct commit_list *list, -struct commit_list **tried, -int show_all, -int *count, -int *skipped_first); +struct commit_list **tried, +int show_all, +int *count, +int *skipped_first);#define BISECT_SHOW_ALL (1<<0)#define REV_LIST_QUIET (1<<1)
@@ -32,8 +32,8 @@ struct rev_list_info { };int bisect_next_all (struct repository *r, -const char *prefix, -int no_checkout); +const char *prefix, +int no_checkout);int estimate_bisect_steps (int all);
branch.h +1 -1
@@ -92,6 +92,6 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree);* otherwise. */ int replace_each_worktree_head_symref (const char *oldref,const char *newref, -const char *logmsg); +const char *logmsg);#endif
builtin.h +1 -1
@@ -111,7 +111,7 @@ struct fmt_merge_msg_opts { };int fmt_merge_msg (struct strbuf *in,struct strbuf *out, -struct fmt_merge_msg_opts *); +struct fmt_merge_msg_opts *);/** * If a built-in has DELAY_PAGER_CONFIG set, the built-in should call this early
bulk-checkin.h +2 -2
@@ -7,8 +7,8 @@#include "cache.h" int index_bulk_checkin (struct object_id *oid, -int fd,size_t size,enum object_type type, -const char *path,unsigned flags); +int fd,size_t size,enum object_type type, +const char *path,unsigned flags);void plug_bulk_checkin (void );void unplug_bulk_checkin (void );
cache.h +21 -21
112 lines not on this page · raw message
checkout.h +2 -2
@@ -9,7 +9,7 @@* exists, NULL otherwise. */ const char *unique_tracking_name (const char *name, -struct object_id *oid, -int *dwim_remotes_matched); +struct object_id *oid, +int *dwim_remotes_matched);#endif /* CHECKOUT_H */
column.h +2 -2
@@ -29,7 +29,7 @@ struct column_options {struct option ;int parseopt_column_callback (const struct option *,const char *,int );int git_column_config (const char *var,const char *value, -const char *command,unsigned int *colopts); +const char *command,unsigned int *colopts);int finalize_colopts (unsigned int *colopts,int stdout_is_tty);static inline int column_active (unsigned int colopts) {
@@ -38,7 +38,7 @@ static inline int column_active(unsigned int colopts)struct string_list ;void print_columns (const struct string_list *list,unsigned int colopts, -const struct column_options *opts); +const struct column_options *opts);int run_column_filter (int colopts,const struct column_options *);int stop_column_filter (void );
commit.h +22 -22
106 lines not on this page · raw message
compat/obstack.h +3 -3
@@ -184,10 +184,10 @@ struct obstack /* control current object in current chunk */void _obstack_newchunk (struct obstack *,int );int _obstack_begin (struct obstack *,int ,int , -void *(*) (long ),void (*) (void *)); +void *(*) (long ),void (*) (void *));int _obstack_begin_1 (struct obstack *,int ,int , -void *(*) (void *,long ), -void (*) (void *,void *),void *); +void *(*) (void *,long ), +void (*) (void *,void *),void *);int _obstack_memory_used (struct obstack *);void obstack_free (struct obstack *,void *);
compat/regex/regex.h +19 -19
@@ -471,7 +471,7 @@ reg_syntax_t re_set_syntax (reg_syntax_t __syntax);and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ const char *re_compile_pattern (const char *__pattern,size_t __length, -struct re_pattern_buffer *__buffer); +struct re_pattern_buffer *__buffer);/* Compile a fastmap for the compiled pattern in BUFFER; used to
@@ -486,29 +486,29 @@ int re_compile_fastmap (struct re_pattern_buffer *__buffer);match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ int re_search (struct re_pattern_buffer *__buffer,const char *__cstring, -int __length,int __start,int __range, -struct re_registers *__regs); +int __length,int __start,int __range, +struct re_registers *__regs);/* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ int re_search_2 (struct re_pattern_buffer *__buffer, -const char *__string1,int __length1, -const char *__string2,int __length2,int __start, -int __range,struct re_registers *__regs,int __stop); +const char *__string1,int __length1, +const char *__string2,int __length2,int __start, +int __range,struct re_registers *__regs,int __stop);/* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ int re_match (struct re_pattern_buffer *__buffer,const char *__cstring, -int __length,int __start,struct re_registers *__regs); +int __length,int __start,struct re_registers *__regs);/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ int re_match_2 (struct re_pattern_buffer *__buffer, -const char *__string1,int __length1, -const char *__string2,int __length2,int __start, -struct re_registers *__regs,int __stop); +const char *__string1,int __length1, +const char *__string2,int __length2,int __start, +struct re_registers *__regs,int __stop);/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -524,9 +524,9 @@ int re_match_2 (struct re_pattern_buffer *__buffer,PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ void re_set_registers (struct re_pattern_buffer *__buffer, -struct re_registers *__regs, -unsigned int __num_regs, -regoff_t *__starts,regoff_t *__ends); +struct re_registers *__regs, +unsigned int __num_regs, +regoff_t *__starts,regoff_t *__ends);#endif /* Use GNU */ #if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
@@ -560,16 +560,16 @@ int re_exec (const char *);/* POSIX compatibility. */ int regcomp (regex_t *__restrict __preg, -const char *__restrict __pattern, -int __cflags); +const char *__restrict __pattern, +int __cflags);int regexec (const regex_t *__restrict __preg, -const char *__restrict __cstring,size_t __nmatch, -regmatch_t __pmatch[__restrict_arr], -int __eflags); +const char *__restrict __cstring,size_t __nmatch, +regmatch_t __pmatch[__restrict_arr], +int __eflags);size_t regerror (int __errcode,const regex_t *__restrict __preg, -char *__restrict __errbuf,size_t __errbuf_size); +char *__restrict __errbuf,size_t __errbuf_size);void regfree (regex_t *__preg);
compat/win32/pthread.h +1 -1
@@ -51,7 +51,7 @@ typedef struct { } pthread_t;int pthread_create (pthread_t *thread,const void *unused, -void *(*start_routine)(void *),void *arg); +void *(*start_routine)(void *),void *arg);/* * To avoid the need of copying a struct, we use small macro wrapper to pass
config.h +22 -22
78 lines not on this page · raw message
connect.h +1 -1
@@ -20,6 +20,6 @@ enum protocol_version discover_version(struct packet_reader *reader);int server_supports_v2 (const char *c,int die_on_error);int server_supports_feature (const char *c,const char *feature, -int die_on_error); +int die_on_error);#endif
delta.h +2 -2
@@ -76,8 +76,8 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,* returned. The returned buffer must be freed by the caller. */ void *patch_delta (const void *src_buf,unsigned long src_size, -const void *delta_buf,unsigned long delta_size, -unsigned long *dst_size); +const void *delta_buf,unsigned long delta_size, +unsigned long *dst_size);/* the smallest possible delta size is 4 bytes */ #define DELTA_SIZE_MIN 4
dir.h +31 -31
106 lines not on this page · raw message
git-compat-util.h +2 -2
@@ -770,13 +770,13 @@ FILE *git_fopen(const char*, const char*);#endif #define snprintf git_snprintfint git_snprintf (char *str,size_t maxsize, -const char *format, ...); +const char *format, ...);#ifdef vsnprintf#undef vsnprintf#endif #define vsnprintf git_vsnprintfint git_vsnprintf (char *str,size_t maxsize, -const char *format,va_list ap); +const char *format,va_list ap);#endif #ifdef __GLIBC_PREREQ
help.h +3 -3
@@ -27,12 +27,12 @@ void list_config_help(int for_human);void list_all_main_cmds (struct string_list *list);void list_all_other_cmds (struct string_list *list);void list_cmds_by_category (struct string_list *list, -const char *category); +const char *category);void list_cmds_by_config (struct string_list *list);const char *help_unknown_cmd (const char *cmd);void load_command_list (const char *prefix, -struct cmdnames *main_cmds, -struct cmdnames *other_cmds); +struct cmdnames *main_cmds, +struct cmdnames *other_cmds);void add_cmdname (struct cmdnames *cmds,const char *name,int len);/* Here we require that excludes is a sorted list. */ void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes);
http.h +5 -5
@@ -104,7 +104,7 @@ void step_active_slots(void);#endif void http_init (struct remote *remote,const char *url, -int proactive_auth); +int proactive_auth);void http_cleanup (void );struct curl_slist *http_copy_default_headers (void );
@@ -147,10 +147,10 @@ void normalize_curl_result(CURLcode *result, long http_code, char *errorstr,/* Helpers for modifying and creating URLs */ void append_remote_object_url (struct strbuf *buf,const char *url, -const char *hex, -int only_two_digit_prefix); +const char *hex, +int only_two_digit_prefix);char *get_remote_object_url (const char *url,const char *hex, -int only_two_digit_prefix); +int only_two_digit_prefix);/* Options for http_get_*() */ struct http_get_options {
@@ -208,7 +208,7 @@ int http_fetch_ref(const char *base, struct ref *ref);/* Helpers for fetching packs */ int http_get_info_packs (const char *base_url, -struct packed_git **packs_head); +struct packed_git **packs_head);struct http_pack_request {char *url;
khash.h +3 -3
@@ -69,11 +69,11 @@ static const double __ac_HASH_UPPER = 0.77;khval_t *vals; \ } kh_##name##_t; -#define __KHASH_PROTOTYPES (name, khkey_t, khval_t) \ - kh_##name##_t *kh_init_##name(void); \ +#define __KHASH_PROTOTYPES (name, khkey_t, khval_t) \ + 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); \ + 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);
lockfile.h +1 -1
@@ -189,7 +189,7 @@ static inline int is_lock_file_locked(struct lock_file *lk)* `errno` set by the failing call. */ void unable_to_lock_message (const char *path,int err, -struct strbuf *buf); +struct strbuf *buf);/* * Emit an appropriate error message and `die()` following the failure
ls-refs.h +1 -1
@@ -5,6 +5,6 @@ struct repository;struct argv_array ;struct packet_reader ;int ls_refs (struct repository *r,struct argv_array *keys, -struct packet_reader *request); +struct packet_reader *request);#endif /* LS_REFS_H */
merge-blobs.h +2 -2
@@ -5,7 +5,7 @@ struct blob;struct index_state ;void *merge_blobs (struct index_state *,const char *, -struct blob *,struct blob *, -struct blob *,unsigned long *); +struct blob *,struct blob *, +struct blob *,unsigned long *);#endif /* MERGE_BLOBS_H */
object-store.h +8 -8
@@ -163,9 +163,9 @@ void *map_loose_object(struct repository *r, const struct object_id *oid, unsigned long *size);void *read_object_file_extended (struct repository *r, -const struct object_id *oid, -enum object_type *type, -unsigned long *size,int lookup_replace); +const struct object_id *oid, +enum object_type *type, +unsigned long *size,int lookup_replace); static inline void *repo_read_object_file(struct repository *r, const struct object_id *oid, enum object_type *type,
@@ -181,17 +181,17 @@ static inline void *repo_read_object_file(struct repository *r,int oid_object_info (struct repository *r,const struct object_id *,unsigned long *);int hash_object_file (const void *buf,unsigned long len, -const char *type,struct object_id *oid); +const char *type,struct object_id *oid);int write_object_file (const void *buf,unsigned long len, -const char *type,struct object_id *oid); +const char *type,struct object_id *oid);int hash_object_file_literally (const void *buf,unsigned long len, -const char *type,struct object_id *oid, -unsigned flags); +const char *type,struct object_id *oid, +unsigned flags);int pretend_object_file (void *,unsigned long ,enum object_type , -struct object_id *oid); +struct object_id *oid);int force_object_loose (const struct object_id *oid,time_t mtime);
oidmap.h +1 -1
@@ -47,7 +47,7 @@ void oidmap_free(struct oidmap *map, int free_entries);* Returns the oidmap entry for the specified oid, or NULL if not found. */ void *oidmap_get (const struct oidmap *map, -const struct object_id *key); +const struct object_id *key);/* * Adds or replaces an oidmap entry.
pack.h +1 -1
@@ -93,7 +93,7 @@ char *index_pack_lockfile(int fd);*/ #define MAX_PACK_OBJECT_HEADER 10int encode_in_pack_object_header (unsigned char *hdr,int hdr_len, -enum object_type ,uintmax_t ); +enum object_type ,uintmax_t );#define PH_ERROR_EOF (-1)#define PH_ERROR_PACK_SIGNATURE (-2)
packfile.h +4 -4
@@ -60,7 +60,7 @@ struct packed_git *get_all_packs(struct repository *r);unsigned long approximate_object_count (void );struct packed_git *find_sha1_pack (const unsigned char *sha1, -struct packed_git *packs); +struct packed_git *packs);void pack_report (void );
@@ -144,8 +144,8 @@ void release_pack_memory(size_t);extern int do_check_packed_object_crc;int packed_object_info (struct repository *r, -struct packed_git *pack, -off_t offset,struct object_info *); +struct packed_git *pack, +off_t offset,struct object_info *);void mark_bad_packed_object (struct packed_git *p,const unsigned char *sha1);const struct packed_git *has_packed_and_bad (struct repository *r,const unsigned char *sha1);
@@ -177,6 +177,6 @@ int is_promisor_object(const struct object_id *oid);* probably use open_pack_index() or parse_pack_index() instead. */ int load_idx (const char *path,const unsigned int hashsz,void *idx_map, -size_t idx_size,struct packed_git *p); +size_t idx_size,struct packed_git *p);#endif
path.h +5 -5
@@ -38,8 +38,8 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...)* append it in the provided buffer `sb`. */ void strbuf_git_common_path (struct strbuf *sb, -const struct repository *repo, -const char *fmt, ...) +const struct repository *repo, +const char *fmt, ...) __attribute__((format (printf,3 ,4 )));/*
@@ -67,7 +67,7 @@ const char *git_common_path(const char *fmt, ...)* Return a path into the git directory of repository `repo`. */ char *repo_git_path (const struct repository *repo, -const char *fmt, ...) +const char *fmt, ...) __attribute__((format (printf,2 ,3 )));/*
@@ -75,8 +75,8 @@ char *repo_git_path(const struct repository *repo,* to the provided buffer `sb`. */ void strbuf_repo_git_path (struct strbuf *sb, -const struct repository *repo, -const char *fmt, ...) +const struct repository *repo, +const char *fmt, ...) __attribute__((format (printf,3 ,4 )));/*
pkt-line.h +2 -2
@@ -173,8 +173,8 @@ struct packet_reader {* abstraction around the 'packet_read_with_status()' function. */ void packet_reader_init (struct packet_reader *reader,int fd, -char *src_buffer,size_t src_len, -int options); +char *src_buffer,size_t src_len, +int options);/* * Perform a packet read and return the status of the read.
ppc/sha1.c +1 -1
@@ -11,7 +11,7 @@#include "sha1.h" void ppc_sha1_core (uint32_t *hash,const unsigned char *p, -unsigned int nblocks); +unsigned int nblocks);int ppc_SHA1_Init (ppc_SHA_CTX *c) {
quote.h +1 -1
@@ -68,7 +68,7 @@ void quote_two_c_style(struct strbuf *, const char *, const char *, int);void write_name_quoted (const char *name,FILE *,int terminator);void write_name_quoted_relative (const char *name,const char *prefix, -FILE *fp,int terminator); +FILE *fp,int terminator);/* quote path as relative to the given prefix */ char *quote_path_relative(const char *in, const char *prefix,
reachable.h +2 -2
@@ -5,8 +5,8 @@ struct progress;struct rev_info ;int add_unseen_recent_objects_to_traversal (struct rev_info *revs, -timestamp_t timestamp); +timestamp_t timestamp);void mark_reachable_objects (struct rev_info *revs,int mark_reflog, -timestamp_t mark_recent,struct progress *); +timestamp_t mark_recent,struct progress *);#endif
reflog-walk.h +6 -6
@@ -8,17 +8,17 @@ struct reflog_walk_info;void init_reflog_walk (struct reflog_walk_info **info);int add_reflog_for_walk (struct reflog_walk_info *info, -struct commit *commit,const char *name); +struct commit *commit,const char *name);void show_reflog_message (struct reflog_walk_info *info,int , -const struct date_mode *,int force_date); +const struct date_mode *,int force_date);void get_reflog_message (struct strbuf *sb, -struct reflog_walk_info *reflog_info); +struct reflog_walk_info *reflog_info);const char *get_reflog_ident (struct reflog_walk_info *reflog_info);timestamp_t get_reflog_timestamp (struct reflog_walk_info *reflog_info);void get_reflog_selector (struct strbuf *sb, -struct reflog_walk_info *reflog_info, -const struct date_mode *dmode,int force_date, -int shorten); +struct reflog_walk_info *reflog_info, +const struct date_mode *dmode,int force_date, +int shorten);int reflog_walk_empty (struct reflog_walk_info *walk);
remote.h +6 -6
@@ -140,15 +140,15 @@ struct packet_reader;struct argv_array ;struct string_list ;struct ref **get_remote_heads (struct packet_reader *reader, -struct ref **list,unsigned int flags, -struct oid_array *extra_have, -struct oid_array *shallow_points); +struct ref **list,unsigned int flags, +struct oid_array *extra_have, +struct oid_array *shallow_points);/* Used for protocol v2 in order to retrieve refs from a remote */ struct ref **get_remote_refs (int fd_out,struct packet_reader *reader, -struct ref **list,int for_push, -const struct argv_array *ref_prefixes, -const struct string_list *server_options); +struct ref **list,int for_push, +const struct argv_array *ref_prefixes, +const struct string_list *server_options);int resolve_remote_symref (struct ref *ref,struct ref *list);
replace-object.h +1 -1
@@ -17,7 +17,7 @@ void prepare_replace_object(struct repository *r);* lookup_replace_object(). Please do not call it directly. */ const struct object_id *do_lookup_replace_object (struct repository *r, -const struct object_id *oid); +const struct object_id *oid);/* * If object sha1 should be replaced, return the replacement object's
serve.h +1 -1
@@ -3,7 +3,7 @@struct argv_array ;int has_capability (const struct argv_array *keys,const char *capability, -const char **value); +const char **value);struct serve_options {unsigned advertise_capabilities;
sha1-lookup.h +3 -3
@@ -4,9 +4,9 @@typedef const unsigned char *sha1_access_fn (size_t index,void *table);int sha1_pos (const unsigned char *sha1, -void *table, -size_t nr, -sha1_access_fn fn); +void *table, +size_t nr, +sha1_access_fn fn);/* * Searches for sha1 in table, using the given fanout table to determine the
string-list.h +1 -1
@@ -175,7 +175,7 @@ struct string_list_item *string_list_insert(struct string_list *list, const char* doesn't exist, the list is not altered. */ void string_list_remove (struct string_list *list,const char *string, -int free_util); +int free_util);/** * Check if the given string is part of a sorted list. If it is part of the list,
sub-process.h +3 -3
@@ -43,9 +43,9 @@ struct subprocess_capability {/* Function to test two subprocess hashmap entries for equality. */ int cmd2process_cmp (const void *unused_cmp_data, -const void *e1, -const void *e2, -const void *unused_keydata); +const void *e1, +const void *e2, +const void *unused_keydata);/* * User-supplied function to initialize the sub-process. This is
submodule-config.h +1 -1
@@ -36,7 +36,7 @@ int parse_submodule_fetchjobs(const char *var, const char *value);int parse_fetch_recurse_submodules_arg (const char *opt,const char *arg);struct option ;int option_fetch_parse_recurse_submodules (const struct option *opt, -const char *arg,int unset); +const char *arg,int unset);int parse_update_recurse_submodules_arg (const char *opt,const char *arg);int parse_push_recurse_submodules_arg (const char *opt,const char *arg);void repo_read_gitmodules (struct repository *repo);
tag.h +1 -1
@@ -18,6 +18,6 @@ void release_tag_memory(struct tag *t);struct object *deref_tag (struct repository *r,struct object *,const char *,int );struct object *deref_tag_noverify (struct object *);int gpg_verify_tag (const struct object_id *oid, -const char *name_to_report,unsigned flags); +const char *name_to_report,unsigned flags);#endif /* TAG_H */
tempfile.h +2 -2
@@ -137,7 +137,7 @@ struct tempfile *register_tempfile(const char *path);/* See "mks_tempfile functions" above. */ struct tempfile *mks_tempfile_sm (const char *filename_template, -int suffixlen,int mode); +int suffixlen,int mode);/* See "mks_tempfile functions" above. */ static inline struct tempfile *mks_tempfile_s(const char *filename_template,
@@ -160,7 +160,7 @@ static inline struct tempfile *mks_tempfile(const char *filename_template)/* See "mks_tempfile functions" above. */ struct tempfile *mks_tempfile_tsm (const char *filename_template, -int suffixlen,int mode); +int suffixlen,int mode);/* See "mks_tempfile functions" above. */ static inline struct tempfile *mks_tempfile_ts(const char *filename_template,
trace.h +5 -5
@@ -133,18 +133,18 @@ void trace_performance_leave(const char *format, ...);/* backend functions, use non-*fl macros instead */ __attribute__((format (printf,4 ,5 )))void trace_printf_key_fl (const char *file,int line,struct trace_key *key, -const char *format, ...); +const char *format, ...); __attribute__((format (printf,4 ,5 )))void trace_argv_printf_fl (const char *file,int line,const char **argv, -const char *format, ...); +const char *format, ...);void trace_strbuf_fl (const char *file,int line,struct trace_key *key, -const struct strbuf *data); +const struct strbuf *data); __attribute__((format (printf,4 ,5 )))void trace_performance_fl (const char *file,int line, -uint64_t nanos,const char *fmt, ...); +uint64_t nanos,const char *fmt, ...); __attribute__((format (printf,4 ,5 )))void trace_performance_leave_fl (const char *file,int line, -uint64_t nanos,const char *fmt, ...); +uint64_t nanos,const char *fmt, ...);static inline int trace_pass_fl (struct trace_key *key) {return key->fd || !key->initialized;
upload-pack.h +2 -2
@@ -14,10 +14,10 @@ struct repository;struct argv_array ;struct packet_reader ;int upload_pack_v2 (struct repository *r,struct argv_array *keys, -struct packet_reader *request); +struct packet_reader *request);struct strbuf ;int upload_pack_advertise (struct repository *r, -struct strbuf *value); +struct strbuf *value);#endif /* UPLOAD_PACK_H */
vcs-svn/svndiff.h +1 -1
@@ -5,6 +5,6 @@ struct line_buffer;struct sliding_view ;int svndiff0_apply (struct line_buffer *delta,off_t delta_len, -struct sliding_view *preimage,FILE *postimage); +struct sliding_view *preimage,FILE *postimage);#endif
worktree.h +7 -7
@@ -48,8 +48,8 @@ const char *get_worktree_git_dir(const struct worktree *wt);* "arg". "prefix" must not be NULL. */ struct worktree *find_worktree (struct worktree **list, -const char *prefix, -const char *arg); +const char *prefix, +const char *arg);/* * Return true if the given worktree is the main one.
@@ -69,14 +69,14 @@ const char *worktree_lock_reason(struct worktree *wt);* returned if "errmsg" is not NULL. */ int validate_worktree (const struct worktree *wt, -struct strbuf *errmsg, -unsigned flags); +struct strbuf *errmsg, +unsigned flags);/* * Update worktrees/xxx/gitdir with the new path. */ void update_worktree_location (struct worktree *wt, -const char *path_); +const char *path_);/* * Free up the memory for worktree(s)
@@ -89,7 +89,7 @@ void free_worktrees(struct worktree **);* or NULL otherwise. The result may be destroyed by the next call. */ const struct worktree *find_shared_symref (const char *symref, -const char *target); +const char *target);/* * Similar to head_ref() for all HEADs _except_ one from the current
@@ -105,7 +105,7 @@ int is_worktree_being_bisected(const struct worktree *wt, const char *target);* worktree instead of current one */ const char *worktree_git_path (const struct worktree *wt, -const char *fmt, ...) +const char *fmt, ...) __attribute__((format (printf,2 ,3 )));/*
xdiff-interface.h +1 -1
@@ -47,7 +47,7 @@ void discard_hunk_line(void *priv,* are treated for the comparision. */ int xdiff_compare_lines (const char *l1,long s1, -const char *l2,long s2,long flags); +const char *l2,long s2,long flags);/* * Returns a hash of the string s of length len.
Signature · 1 line
2.21.0.832.gd5ec0d3bee
PATCH v3 4/4 cocci: prevent extern function declarations
In reply to Denton LiuSince function declarations already implicitly imply extern, create a Coccinelle rule which removes the redundant extern.
--- contrib/coccinelle/noextern.cocci | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 contrib/coccinelle/noextern.cocci
contrib/coccinelle/noextern.cocci new file +6 -0
@@ -0,0 +1,6 @@ +@@ +type T; +identifier f; +@@ +- extern + T f(...);
Signature · 1 line
2.21.0.832.gd5ec0d3bee
PATCH 1/1 cache.h: fix mismerge of 'dl/no-extern-in-func-decl'
In reply to Denton LiuAfter merging 'dl/no-extern-in-func-decl' into 'pu', it seems like the conflict resolution mostly went well except for one spot, which this patch should fix. Although this is only currently only a problem in 'pu', we should fix the entry rerere cache for if this branch ends up merged in 'next' in the future.
---
I guess while we're at it, I noticed that these commits are all missing signoffs from you. We should probably attach those while we're fixing this up.
Thanks,
Denton
cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cache.h +1 -1
@@ -1393,7 +1393,7 @@ int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oidvoid maybe_die_on_misspelt_object_name (struct repository *repo,const char *name,const char *prefix); -extern enum get_oid_result get_oid_with_context (struct repository *repo,const char *str, +enum get_oid_result get_oid_with_context (struct repository *repo,const char *str,unsigned flags,struct object_id *oid,struct object_context *oc);
Signature · 1 line
2.21.0.1000.g11cd861522
Re: [PATCH] cache.h: fix mismerge of 'dl/no-extern-in-func-decl'
Quoted 3 lines · Denton Liu
After merging 'dl/no-extern-in-func-decl' into 'pu', it seems like the conflict resolution mostly went well except for one spot, which this patch should fix.
I do not think this is a mismerge per-se.
That line is not touched since this February at 7589e636 ("Merge branch 'nd/the-index-final'", 2019-02-06).
It is just that large scale churning on a common and busy file like cache.h is bound to cause painful conflicts with other topics, both textual and non-textual. As these "extern" in *.h that explicitly marks that they are merely decls and not defunitions do not hurt anybody, I think it is better to leave it to a cleanup pass at the end of the tunnel after things gradulate to 'master' and start to calm down.
Thanks.
Re: [PATCH] cache.h: fix mismerge of 'dl/no-extern-in-func-decl'
Quoted 7 lines · Junio C Hamano
Quoted 3 lines · Denton Liu
After merging 'dl/no-extern-in-func-decl' into 'pu', it seems like the conflict resolution mostly went well except for one spot, which this patch should fix.
I do not think this is a mismerge per-se.
I looked at the merge again, and I agree that it was a simple mismerge. THe function was already there in the common ancestor, and was not changed on the mainline until the "remove extern" topic was merged, so the result should have been a clean 3-way "the mainline did not touch and kept extern, the side branch removed the extern, so the result is to remove it" merge.
It was just the change was dwarfed by nearby noise conflicting the "remove extern" which pretty much touches the entire file, with different topics touching different part of the same file.
The merge (and more importantly, the rerere database) has been fixed up. Thanks for helping.
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to Denton LiuQuoted 7 lines · Denton Liu
Thanks for the feedback. I couldn't find a tool that could selectively fix indentation on patches so I went through and manually realigned the parameter lists wherever the tools mangled the alignment. I guess this also implies that one pair of (tired) human eyes has manually inspected the machine-generated diff.
Hopefully, patch 3/4 won't be as onerous to review as it was to write ;)
Thanks. I looked over these manually and didn't find any problems (which isn't to say there aren't any, but now at least two sets of tired eyes looked at them :) ).
This kind of cleanup is painful, but at least it should be done with after this, so I'm in favor of moving it forward. Two minor notes, though:
Quoted 7 lines
compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 14 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 66 ++--- compat/win32/pthread.h | 8 +-
We sometimes avoid touching compat/ code for style issues because it's copied from elsewhere. And diverging from upstream is more evil than a pure style issue. So potentially we could drop these hunks (though I think maybe mingw is our own thing?).
Quoted 1 line
contrib/coccinelle/noextern.cocci | 6 +
I have mixed feelings on this cocci script. I'm happy to _see_ it, as it's important to show how the transformation was done. But for most of the other scripts, we expect programmers to introduce new cases that need converting, and we'd like to catch those automatically. Here I find it reasonably unlikely for a lot of "extern" to slip in, with the exception of some topics in flight.
And these coccinelle scripts are kind of expensive to run. So I wonder if the tradeoff is worth it here (perhaps it is now, as we catch those topics in flight, it might be worth dropping this one in a few months).
At any rate, thanks for doing all of this tedious work. :)
-Peff
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 10 lines · Jeff King
Quoted 7 lines · Denton Liu
compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 14 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 66 ++--- compat/win32/pthread.h | 8 +-
Quoted 8 lines
We sometimes avoid touching compat/ code for style issues because it's copied from elsewhere. And diverging from upstream is more evil than a pure style issue. So potentially we could drop these hunks (though I think maybe mingw is our own thing?).
Quoted 1 line
contrib/coccinelle/noextern.cocci | 6 +I have mixed feelings on this cocci script.
I have actual bad experience with this :)
v4 of this patch series excluded 'compat/' from the conversion, but the semantic patch is applied to 'compat/' all the same, resulting in failed CI builds because of the four 'extern's in 'compat/obstack.h', and will continue to do so.
(Coccinelle has no issues with those other header files; I guess those are not included in the '.c' source files we analyze with Coccinelle in a stock Linux build environment).
Quoted 14 lines
I'm happy to _see_ it, as
it's important to show how the transformation was done. But for most of the other scripts, we expect programmers to introduce new cases that need converting, and we'd like to catch those automatically. Here I find it reasonably unlikely for a lot of "extern" to slip in, with the exception of some topics in flight.And these coccinelle scripts are kind of expensive to run. So I wonder if the tradeoff is worth it here (perhaps it is now, as we catch those topics in flight, it might be worth dropping this one in a few months).
At any rate, thanks for doing all of this tedious work. :)
-Peff
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 22 lines · SZEDER Gábor
Quoted 10 lines · Jeff King
Quoted 7 lines · Denton Liu
compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 14 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 66 ++--- compat/win32/pthread.h | 8 +-Quoted 8 lines
We sometimes avoid touching compat/ code for style issues because it's copied from elsewhere. And diverging from upstream is more evil than a pure style issue. So potentially we could drop these hunks (though I think maybe mingw is our own thing?).
Quoted 1 line
contrib/coccinelle/noextern.cocci | 6 +I have mixed feelings on this cocci script.
I have actual bad experience with this :)
Quoted 8 lines
v4 of this patch series excluded 'compat/' from the conversion, but the semantic patch is applied to 'compat/' all the same, resulting in failed CI builds because of the four 'extern's in '
compat/obstack.h', and will continue to do so.(Coccinelle has no issues with those other header files; I guess those are not included in the '.c' source files we analyze with Coccinelle in a stock Linux build environment).
Since this is the case, we should drop 4/4 because it is not only unhelpful, because it doesn't scan header files, but actively harmful. The cocci script used is in the log for 1/4 anyway.
Thanks for checking on this,
Denton
Quoted 16 lines
Quoted 16 lines
I'm happy to _see_ it, as
it's important to show how the transformation was done. But for most of the other scripts, we expect programmers to introduce new cases that need converting, and we'd like to catch those automatically. Here I find it reasonably unlikely for a lot of "extern" to slip in, with the exception of some topics in flight.And these coccinelle scripts are kind of expensive to run. So I wonder if the tradeoff is worth it here (perhaps it is now, as we catch those topics in flight, it might be worth dropping this one in a few months).
At any rate, thanks for doing all of this tedious work. :)
-Peff
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to SZEDER GáborHi,
Quoted 18 lines · SZEDER Gábor
Quoted 17 lines · Jeff King
Quoted 7 lines · Denton Liu
compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 14 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 66 ++--- compat/win32/pthread.h | 8 +-We sometimes avoid touching compat/ code for style issues because it's copied from elsewhere. And diverging from upstream is more evil than a pure style issue. So potentially we could drop these hunks (though I think maybe mingw is our own thing?).
Quoted 1 line
contrib/coccinelle/noextern.cocci | 6 +
Quoted 8 lines
Quoted 1 line
I have mixed feelings on this cocci script.
I have actual bad experience with this :)
v4 of this patch series excluded 'compat/' from the conversion, but the semantic patch is applied to 'compat/' all the same, resulting in failed CI builds because of the four 'extern's in '
compat/obstack.h', and will continue to do so.
Is it not possible to exclude certain directories for certain semantic patches?
I guess we could also simply declare that *all* Coccinelle patches should leave compat/ alone, on the basis that those files are likely coming from some sort of upstream. But then, compat/mingw.c and compat/win32/ seem not to fall into that category...
Ciao,
Dscho
Re: [PATCH v3 0/4] remove extern from function declarations
Hi Johannes,
Quoted 34 lines · Johannes Schindelin
Hi,
Quoted 18 lines · SZEDER Gábor
Quoted 17 lines · Jeff King
Quoted 7 lines · Denton Liu
compat/mingw.c | 2 +- compat/mingw.h | 6 +- compat/nedmalloc/malloc.c.h | 6 +- compat/obstack.h | 14 +- compat/poll/poll.h | 2 +- compat/regex/regex.h | 66 ++--- compat/win32/pthread.h | 8 +-We sometimes avoid touching compat/ code for style issues because it's copied from elsewhere. And diverging from upstream is more evil than a pure style issue. So potentially we could drop these hunks (though I think maybe mingw is our own thing?).
Quoted 1 line
contrib/coccinelle/noextern.cocci | 6 +Quoted 8 lines
Quoted 1 line
I have mixed feelings on this cocci script.
I have actual bad experience with this :)
v4 of this patch series excluded 'compat/' from the conversion, but the semantic patch is applied to 'compat/' all the same, resulting in failed CI builds because of the four 'extern's in '
compat/obstack.h', and will continue to do so.Is it not possible to exclude certain directories for certain semantic patches?
Quoted 7 lines
I guess we could also simply declare that *all* Coccinelle patches should leave
compat/alone, on the basis that those files are likely coming from some sort of upstream. But then,compat/mingw.candcompat/win32/seem not to fall into that category...Ciao,
Dscho
Deciding whether this is a good idea is above my paygrade ;)
However, if this is a good idea, we could use this patch to make it happen:
-- >8 --
Subject: [PATCH] Makefile: filter out compat/ from coccicheck
Since most files in compat/ are pulled from external sources, ensure that they do not get modified when we run coccicheck because we do not want them to differ from upstream as much as possible.
Make exceptions for mingw.c and win32/*.c as these are files that we have created and not pulled from upstream.
--- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Makefile +5 -2
@@ -2782,11 +2782,14 @@ check: command-list.h fi C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ)) +COCCI_COMPAT_SOURCES = $(addprefix compat/,mingw.c win32/%) ifdef DC_SHA1_SUBMODULE -COCCI_SOURCES = $(filter-out sha1collisiondetection/%,$(C_SOURCES)) +COCCI_SOURCES := $(filter-out sha1collisiondetection/%,$(C_SOURCES)) else -COCCI_SOURCES = $(filter-out sha1dc/%,$(C_SOURCES)) +COCCI_SOURCES := $(filter-out sha1dc/%,$(C_SOURCES)) endif +COCCI_SOURCES := $(filter-out compat/%,$(COCCI_SOURCES)) +COCCI_SOURCES += $(filter $(COCCI_COMPAT_SOURCES),$(C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \
Signature · 1 line
2.21.0.1033.g0e8cc1100c
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 6 lines · Denton Liu
Quoted 4 lines
I guess we could also simply declare that *all* Coccinelle patches should leave
compat/alone, on the basis that those files are likely coming from some sort of upstream. But then,compat/mingw.candcompat/win32/seem not to fall into that category...Deciding whether this is a good idea is above my paygrade ;)
FWIW, this seems like a good idea to me.
It's _possible_ there may be some cocci changes that we want to apply even to compat/ (e.g., if we're mechanically fixing up a construct with security implications). But whoever is doing that conversion should probably apply that manually (and we don't typically change imported stuff in the first place, so there's little need to subsequently run the cocci patches).
Quoted 3 lines
-- >8 --
Subject: [PATCH]Makefile: filter out compat/ from coccicheck [...]
The patch itself looks OK to me.
-Peff
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to Denton LiuQuoted 19 lines · Denton Liu
Quoted 10 lines
Is it not possible to exclude certain directories for certain semantic patches?
I guess we could also simply declare that *all* Coccinelle patches should leave
compat/alone, on the basis that those files are likely coming from some sort of upstream. But then,compat/mingw.candcompat/win32/seem not to fall into that category...Ciao,
DschoDeciding whether this is a good idea is above my paygrade ;)
However, if this is a good idea, we could use this patch to make it happen:
-- >8 --
Subject: [PATCH]Makefile: filter out compat/ from coccicheck
Quoted 6 lines
Since most files in compat/ are pulled from external sources, ensure that they do not get modified when we run coccicheck because we do not want them to differ from upstream as much as possible.
Make exceptions for
mingw.cand win32/*.c as these are files that we have created and not pulled from upstream.
I'm not sure that we really need these exceptions.
C_SOURCES comes from C_OBJ, i.e. it is basically all '*.c' source files that we compile, taking the platform and Makefile knobs into account. On Linux we don't compile 'compat/mingw.c' and 'compat/win32/*.c', so when running 'make coccicheck' on Linux it won't look into these source files anyway, so we don't need these exceptions. On Windows, however... well, is it even possible to build and run Coccinelle on Windows in the first place, with all its OCaml dependencies?! If not, then these exceptions won't do any good.
Anyway, if we do want these exceptions, then what about 'compat/win32mmap.c' and 'compat/winansi.c'? They look like "ours" as well.
FWIW, out of curiosity I've run 'make coccicheck' on Linux with 'compat/mingw.c' and its friends explicitly added to C_SOURCES, and it seems to work... it even found two places in 'mingw.c' where COPY_ARRAY could replace memcpy() :)
Quoted 31 lines
Signed-off-by Denton Liu <[email protected]>--- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Makefile +5
-2@@ -2782,11 +2782,14 @@ check: command-list.h fi C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ)) +COCCI_COMPAT_SOURCES = $(addprefix compat/,mingw.c win32/%) ifdef DC_SHA1_SUBMODULE -COCCI_SOURCES = $(filter-out sha1collisiondetection/%,$(C_SOURCES)) +COCCI_SOURCES := $(filter-out sha1collisiondetection/%,$(C_SOURCES)) else -COCCI_SOURCES = $(filter-out sha1dc/%,$(C_SOURCES)) +COCCI_SOURCES := $(filter-out sha1dc/%,$(C_SOURCES)) endif +COCCI_SOURCES := $(filter-out compat/%,$(COCCI_SOURCES)) +COCCI_SOURCES += $(filter $(COCCI_COMPAT_SOURCES),$(C_SOURCES))%.cocci.patch: %.cocci $(COCCI_SOURCES)
@echo ' ' SPATCH $<; \Signature · 1 line
2.21.0.1033.g0e8cc1100c
Re: [PATCH v3 0/4] remove extern from function declarations
Hi,
Quoted 9 lines · SZEDER Gábor
Quoted 8 lines · Denton Liu
Quoted 8 lines
Is it not possible to exclude certain directories for certain semantic patches?
I guess we could also simply declare that *all* Coccinelle patches should leave
compat/alone, on the basis that those files are likely coming from some sort of upstream. But then,compat/mingw.candcompat/win32/seem not to fall into that category...
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Ciao,
DschoDeciding whether this is a good idea is above my paygrade ;)
:-)
As a software developer, you surely have an opinion, though :-D
Thank you for the patch, it is a good conversation starter in the least, and I hope that some variation of it will even make it to master.
Quoted 2 lines
[...] what about '
compat/win32mmap.c' and 'compat/winansi.c'? They look like "ours" as well.
Indeed, this is probably a good indicator that we'd want this to be an opt-out, rather than an opt-in list.
For example, we know that we want to exclude compat/regex/ and compat/poll/ from the coccicheck target.
Quoted 4 lines
FWIW, out of curiosity I've run 'make coccicheck' on Linux with '
compat/mingw.c' and its friends explicitly added toC_SOURCES, and it seems to work... it even found two places in 'mingw.c' whereCOPY_ARRAYcould replacememcpy():)
TBH I had not even known that those files were excluded from coccicheck by default. I had assumed that all of Git's sources (and not just the Linux-specific ones) were included in the target.
Since you *could* include it, I now assume that Coccinelle does not need to follow the #includes (otherwise, it would have complained about not finding the windows.h header in your setup).
If this new assumption is true, I wonder why we cannot make my former assumption true as well: why not include *all* of Git's .c files in coccicheck?
Ciao,
Dscho
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 13 lines · Johannes Schindelin
Hi,
Quoted 9 lines · SZEDER Gábor
Quoted 8 lines · Denton Liu
Quoted 8 lines
Is it not possible to exclude certain directories for certain semantic patches?
I guess we could also simply declare that *all* Coccinelle patches should leave
compat/alone, on the basis that those files are likely coming from some sort of upstream. But then,compat/mingw.candcompat/win32/seem not to fall into that category...
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Ciao,
DschoDeciding whether this is a good idea is above my paygrade ;)
:-)
As a software developer, you surely have an opinion, though :-D
I don't even have an opinion yet. :)
Quoted 7 lines
Quoted 4 lines
FWIW, out of curiosity I've run 'make coccicheck' on Linux with '
compat/mingw.c' and its friends explicitly added toC_SOURCES, and it seems to work... it even found two places in 'mingw.c' whereCOPY_ARRAYcould replacememcpy():)TBH I had not even known that those files were excluded from coccicheck by default.
Well, there was this line in the patch context:
C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
Quoted 6 lines
I had assumed that all of Git's sources (and not just the Linux-specific ones) were included in the target.
Since you *could* include it, I now assume that Coccinelle does not need to follow the
#includes (otherwise, it would have complained about not finding thewindows.hheader in your setup).
We invoke Coccinelle/spatch with the '--all-includes' option, see the SPATCH_FLAGS make variable. And it does indeed include header files:
I've seen it find something to transform in 'cache.h', and then the resulting 'contrib/coccinelle/<whatever>.cocci.patch' included the exact same transformation as many times as the number of files including 'cache.h'... which is a lot :)
I don't really know what can cause 'spatch' to error out (besides unknown command line option or non-existing file specified on the command line), and this is all that 'man spatch' has to say:
--all-includes
causes all available include files to be used
Since it explicitly mentions _available_ include files, I would venture to guess that non-available include files are not used, and since it doesn't explicitly mention that such a file causes an error, it doesn't.
Quoted 6 lines
If this new assumption is true, I wonder why we cannot make my former assumption true as well: why not include *all* of Git's
.cfiles incoccicheck?Ciao,
Dscho
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 8 lines · SZEDER Gábor
Quoted 3 lines
Since you *could* include it, I now assume that Coccinelle does not need to follow the
#includes (otherwise, it would have complained about not finding thewindows.hheader in your setup).I don't really know what can cause 'spatch' to error out (besides unknown command line option or non-existing file specified on the command line), and this is all that 'man spatch' has to say:
Quoted 7 lines
--all-includes
causes all available include files to be usedSince it explicitly mentions _available_ include files, I would venture to guess that non-available include files are not used, and since it doesn't explicitly mention that such a file causes an error, it doesn't.
Actually, we record Coccinelle's output to stderr in a logfile, and with the Windows-specific source files included it contains thing like:
HANDLING: compat/mingw.c
(ONCE) TYPE: header conio.h not found (ONCE) TYPE: header wchar.h not found
diff =
init_defs_builtins: /usr/lib/coccinelle/standard.h
HANDLING: compat/winansi.c
(ONCE) TYPE: header wingdi.h not found (ONCE) TYPE: header winreg.h not found (ONCE) TYPE: header winternl.h not found (ONCE) TYPE: header ntstatus.h not found
So it seems that these missing headers are just ignored, only their absence is noted on stderr.
(And just for the record, that log also contained these:
HANDLING: http-push.c
(ONCE) TYPE: header xmlparse.h not found
(ONCE) TYPE: header expat.h not found
HANDLING: xdiff/xutils.c
(ONCE) TYPE: header limits.h not found
(ONCE) TYPE: header assert.h not found
which means that even on an avarage Linux box there might be missing include files. This also raises the question whether Coccinelle looks for things to transform in system headers as well (and what if it finds something there)).
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to SZEDER GáborQuoted 10 lines · SZEDER Gábor
Quoted 3 lines
Since you *could* include it, I now assume that Coccinelle does not need to follow the
#includes (otherwise, it would have complained about not finding thewindows.hheader in your setup).We invoke Coccinelle/spatch with the '--all-includes' option, see the
SPATCH_FLAGSmake variable. And it does indeed include header files:
I've seen it find something to transform in 'cache.h', and then the resulting 'contrib/coccinelle/<whatever>.cocci.patch' included the exact same transformation as many times as the number of files including 'cache.h'... which is a lot :)
I think spatch is smart enough not to hit the same header multiple times. But the problem is that we invoke it once per file, so it actually processes cache.h many times. That's slow, but also produces bogus patches.
Jacob Keller's patches to collapse this to a single invocation do fix it (and I've used them selectively in the past rather than cleaning up the resulting patch manually ;) ).
Sort of tangential to your point, I guess, but it might be a topic to revisit.
-Peff
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 18 lines · Jeff King
Quoted 10 lines · SZEDER Gábor
Quoted 3 lines
Since you *could* include it, I now assume that Coccinelle does not need to follow the
#includes (otherwise, it would have complained about not finding thewindows.hheader in your setup).We invoke Coccinelle/spatch with the '--all-includes' option, see the
SPATCH_FLAGSmake variable. And it does indeed include header files:
I've seen it find something to transform in 'cache.h', and then the resulting 'contrib/coccinelle/<whatever>.cocci.patch' included the exact same transformation as many times as the number of files including 'cache.h'... which is a lot :)I think spatch is smart enough not to hit the same header multiple times. But the problem is that we invoke it once per file, so it actually processes
cache.hmany times. That's slow, but also produces bogus patches.
Quoted 6 lines
Jacob Keller's patches to collapse this to a single invocation do fix it (and I've used them selectively in the past rather than cleaning up the resulting patch manually ;) ).
Sort of tangential to your point, I guess, but it might be a topic to revisit.
I simply applied the changes manually to 'cache.h', and rerun 'make contrib/coccinelle/<...>.cocci.patch'. This approach is reliable and has less undesirable side-effects :) and it doesn't happen that often to be a considerable burden.
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to Jeff KingQuoted 4 lines · Jeff King
I think spatch is smart enough not to hit the same header multiple times. But the problem is that we invoke it once per file, so it actually processes
cache.hmany times. That's slow, but also produces bogus patches.
Yes, I've seen this and was a bit irritated myself, but not enough to do something about it myself, yet.
Quoted 4 lines
Jacob Keller's patches to collapse this to a single invocation do fix it (and I've used them selectively in the past rather than cleaning up the resulting patch manually ;) ).
Ah, that is nice to know. Do we want to resurrect it?
Re: [PATCH v3 0/4] remove extern from function declarations
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Jeff King
I think spatch is smart enough not to hit the same header multiple times. But the problem is that we invoke it once per file, so it actually processes
cache.hmany times. That's slow, but also produces bogus patches.
Quoted 8 lines
Yes, I've seen this and was a bit irritated myself, but not enough to do something about it myself, yet.
Quoted 4 lines
Jacob Keller's patches to collapse this to a single invocation do fix it (and I've used them selectively in the past rather than cleaning up the resulting patch manually ;) ).
Ah, that is nice to know. Do we want to resurrect it?
I remember deciding that the memory cost trade off was too high back then.
Thanks,
Jake
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to Jeff KingQuoted 19 lines · Jeff King
Quoted 10 lines · SZEDER Gábor
Quoted 3 lines
Since you *could* include it, I now assume that Coccinelle does not need to follow the
#includes (otherwise, it would have complained about not finding thewindows.hheader in your setup).We invoke Coccinelle/spatch with the '--all-includes' option, see the
SPATCH_FLAGSmake variable. And it does indeed include header files:
I've seen it find something to transform in 'cache.h', and then the resulting 'contrib/coccinelle/<whatever>.cocci.patch' included the exact same transformation as many times as the number of files including 'cache.h'... which is a lot :)I think spatch is smart enough not to hit the same header multiple times. But the problem is that we invoke it once per file, so it actually processes
cache.hmany times. That's slow, but also produces bogus patches.
Quoted 8 lines
Jacob Keller's patches to collapse this to a single invocation do fix it (and I've used them selectively in the past rather than cleaning up the resulting patch manually ;) ).
Sort of tangential to your point, I guess, but it might be a topic to revisit.
-Peff
Yea, my patches are much faster. However, they trade off a huge increase in memory consumption, and from what I remember, the failure if you don't have enough RAM was not a good experience.
Thanks,
Jake
PATCH 1/1 coccicheck: optionally process every source file at once
Quoted 10 lines · Jacob Keller
Quoted 6 lines
Jacob Keller's patches to collapse this to a single invocation do fix it (and I've used them selectively in the past rather than cleaning up the resulting patch manually ;) ).
Sort of tangential to your point, I guess, but it might be a topic to revisit.
Yea, my patches are much faster. However, they trade off a huge increase in memory consumption, and from what I remember, the failure if you don't have enough RAM was not a good experience.
I think there was a suggestion to make it conditional. So maybe something like this?
-- >8 --
From: Jacob Keller <[email protected]>
Subject: [PATCH] coccicheck: optionally process every source file at once
make coccicheck is used in order to apply coccinelle semantic patches, and see if any of the transformations found within contrib/coccinelle/ can be applied to the current code base.
Provide an option to pass every file to a single invocation of spatch, instead of running spatch once per source file.
This reduces the time required to run make coccicheck by a significant amount of time:
Prior timing of make coccicheck
real 6m14.090s user 25m2.606s sys 1m22.919s
New timing of make coccicheck
real 1m36.580s user 7m55.933s sys 0m18.219s
This is nearly a 4x decrease in the time required to run make coccicheck. This is due to the overhead of restarting spatch for every file. By processing all files at once, we can amortize this startup cost across the total number of files, rather than paying it once per file.
However, it comes at a cost. The RSS of each spatch process goes from ~50MB to ~1500MB (and peak memory usage may be even higher if make runs multiple rule files in parallel due to "-j"). That's enough to make some systems (like our Travis build!) fail the whole process, or could make things slower due to swapping. So let's make the new behavior optional, and people with a lot of memory can choose to use it.
[peff: modified Jacob's patch to make the behavior optional, since
people reported complications due to the memory use]
---
The conditional here is implemented as shell. I couldn't find a way to do it readably with a make ifdef, since we're in the middle of a backslash-connected shell command in the recipe. And trying to use $(if) just turned into a mess.
But maybe some gnu make hotshot wants to show me how it's done. ;)
Makefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
Makefile +14 -6
@@ -1174,8 +1174,11 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -# For the 'coccicheck' target +# For the 'coccicheck' target; set USE_SINGLE_SPATCH to invoke a single spatch +# for all sources, rather than one per source file. That generally runs faster, +# at the cost of using much more peak memory (on the order of 1-2GB). SPATCH_FLAGS = --all-includes --patch . +USE_SINGLE_SPATCH = include config.mak.uname -include config.mak.autogen
@@ -2790,11 +2793,16 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - ret=0; \ - for f in $(COCCI_SOURCES); do \ - $(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \ - { ret=$$?; break; }; \ - done >$@+ 2>[email protected]; \ + if test -z "$(USE_SINGLE_SPATCH)"; then \ + ret=0; \ + for f in $(COCCI_SOURCES); do \ + $(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \ + { ret=$$?; break; }; \ + done >$@+ 2>[email protected]; \ + else \ + $(SPATCH) --sp-file $< $(COCCI_SOURCES) $(SPATCH_FLAGS) >$@+ 2>[email protected]; \ + ret=$$?; \ + fi; \ if test $$ret != 0; \ then \ cat [email protected]; \
Signature · 1 line
2.21.0.1314.g224b191707
Re: [PATCH] coccicheck: optionally process every source file at once
Quoted 8 lines · Jeff King
This reduces the time required to run make coccicheck by a significant amount of time:
Prior timing of make coccicheck
real 6m14.090s user 25m2.606s sys 1m22.919s
Quoted 6 lines
New timing of make coccicheck
real 1m36.580s user 7m55.933s sys 0m18.219sThis is nearly a 4x decrease in the time required to run make
Whoa.
Quoted 6 lines
coccicheck. This is due to the overhead of restarting spatch for every file. By processing all files at once, we can amortize this startup cost across the total number of files, rather than paying it once per file.
However, it comes at a cost. The RSS of each spatch process goes from ~50MB to ~1500MB (and peak memory usage may be even higher if make runs
1.5G should be fine. Trying...
Even with no -j, my htop's RES column goes up 6GB and put my laptop in "swap every bit of memory out, including the bits handling the screen" mode :( I don't think it was even the peak.
It's probably a bit too much to ask, but is it possible to handle N files at a time (instead of all files), which consumes less memory and runs a bit slower, but still better than the default mode? I can see it already gets tricky doing complicated stuff in Makefile so "no" is perfectly ok.
Quoted 10 lines
multiple rule files in parallel due to "-j"). That's enough to make some systems (like our Travis build!) fail the whole process, or could make things slower due to swapping. So let's make the new behavior optional, and people with a lot of memory can choose to use it.
[peff: modified Jacob's patch to make the behavior optional, since
people reported complications due to the memory use]Signed-off-by Jacob Keller <[email protected]>Signed-off-by Jeff King <[email protected]>
Signature · 1 line
Duy
PATCH 1/1 coccicheck: optionally batch spatch invocations
Quoted 8 lines · Duy Nguyen
Quoted 2 lines
However, it comes at a cost. The RSS of each spatch process goes from ~50MB to ~1500MB (and peak memory usage may be even higher if make runs
1.5G should be fine. Trying...
Even with no -j, my htop's RES column goes up 6GB and put my laptop in "swap every bit of memory out, including the bits handling the screen" mode :( I don't think it was even the peak.
Interesting if you have a different version of spatch. I'm using 1.0.4 from Debian unstable.
I had just been eyeballing the values in "top" before, but I actually measured more carefully. My peak was actually ~1900MB.
Quoted 5 lines
It's probably a bit too much to ask, but is it possible to handle N files at a time (instead of all files), which consumes less memory and runs a bit slower, but still better than the default mode? I can see it already gets tricky doing complicated stuff in
Makefileso "no" is perfectly ok.
I almost did this initially but I feared that nobody would actually use it. :) So given at least one person who wants it, I took a look. If we rely on xargs, then it is really not too bad (and is in fact shorter than the current code). I also wrote up a pure-shell version, but it's rather verbose even after taking some shortcuts with whitespace splitting.
So here's what I think we should apply:
-- >8 --
Subject: [PATCH] coccicheck: optionally batch spatch invocations
In our "make coccicheck" rule, we currently feed each source file to its own individual invocation of spatch. This has a few downsides:
- it repeats any overhead spatch has for starting up and reading the patch file
- any included header files may get processed from multiple invocations. This is slow (we see the same header files multiple times) and may produce a resulting patch with repeated hunks (which cannot be applied without further cleanup)
Ideally we'd just invoke a single instance of spatch per rule-file and feed it all source files. But spatch can be rather memory hungry when run in this way. I measured the peak RSS going from ~90MB for a single file to ~1900MB for all files. Multiplied by multiple rule files being processed at the same time (for "make -j"), this can make things slower or even cause them to fail (e.g., this is reported to happen on our Travis builds).
Instead, let's provide a tunable knob. We'll leave the default at "1", but it can be cranked up to "999" for maximum CPU/memory tradeoff, or people can find points in between that serve their particular machines.
Here are a few numbers running a single rule via:
SIZES='1 4 16 999'
RULE=contrib/coccinelle/object_id.cocci
for i in $SIZES; do
make clean
/usr/bin/time -o $i.out --format='%e | %U | %S | %M' \
make $RULE.patch SPATCH_BATCH_SIZE=$i
done
for i in $SIZES; do
printf '%4d | %s\n' $i "$(cat $i.out)"
donewhich yields:
1 | 97.73 | 93.38 | 4.33 | 100128
4 | 52.80 | 51.14 | 1.69 | 135204
16 | 35.82 | 35.09 | 0.76 | 284124
999 | 23.30 | 23.13 | 0.20 | 1903852The implementation is done with xargs, which should be widely available; it's in POSIX, we rely on it already in the test suite. And "coccicheck" is really a developer-only tool anyway, so it's not a big deal if obscure systems can't run it.
---
I left the default at 1 for safety. Probably 4 or 16 would be an OK default, but I don't have any interest in figuring out exactly what Travis or some hypothetical average machine can handle. I'll be setting mine to 999. ;)
Making "0" work as "unlimited" might be nice, but xargs doesn't support that and I didn't want to make the recipe any more unreadable than it already is.
Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Makefile +6 -7
@@ -1174,8 +1174,10 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -# For the 'coccicheck' target +# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will +# usually result in less CPU usage at the cost of higher peak memory. SPATCH_FLAGS = --all-includes --patch . +SPATCH_BATCH_SIZE = 1 include config.mak.uname -include config.mak.autogen
@@ -2790,12 +2792,9 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - ret=0; \ - for f in $(COCCI_SOURCES); do \ - $(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \ - { ret=$$?; break; }; \ - done >$@+ 2>[email protected]; \ - if test $$ret != 0; \ + if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ + >$@+ 2>[email protected]; \ then \ cat [email protected]; \ exit 1; \
Signature · 1 line
2.21.0.1314.g224b191707
Re: [PATCH] coccicheck: optionally batch spatch invocations
Quoted 131 lines · Jeff King
Quoted 8 lines · Duy Nguyen
Quoted 2 lines
However, it comes at a cost. The RSS of each spatch process goes from ~50MB to ~1500MB (and peak memory usage may be even higher if make runs
1.5G should be fine. Trying...
Even with no -j, my htop's RES column goes up 6GB and put my laptop in "swap every bit of memory out, including the bits handling the screen" mode :( I don't think it was even the peak.
Interesting if you have a different version of spatch. I'm using 1.0.4 from Debian unstable.
I had just been eyeballing the values in "top" before, but I actually measured more carefully. My peak was actually ~1900MB.
Quoted 5 lines
It's probably a bit too much to ask, but is it possible to handle N files at a time (instead of all files), which consumes less memory and runs a bit slower, but still better than the default mode? I can see it already gets tricky doing complicated stuff in
Makefileso "no" is perfectly ok.I almost did this initially but I feared that nobody would actually use it. :) So given at least one person who wants it, I took a look. If we rely on xargs, then it is really not too bad (and is in fact shorter than the current code). I also wrote up a pure-shell version, but it's rather verbose even after taking some shortcuts with whitespace splitting.
So here's what I think we should apply:
-- >8 --
Subject: [PATCH] coccicheck: optionally batch spatch invocationsIn our "make coccicheck" rule, we currently feed each source file to its own individual invocation of spatch. This has a few downsides:
- it repeats any overhead spatch has for starting up and reading the patch file
- any included header files may get processed from multiple invocations. This is slow (we see the same header files multiple times) and may produce a resulting patch with repeated hunks (which cannot be applied without further cleanup)
Ideally we'd just invoke a single instance of spatch per rule-file and feed it all source files. But spatch can be rather memory hungry when run in this way. I measured the peak RSS going from ~90MB for a single file to ~1900MB for all files. Multiplied by multiple rule files being processed at the same time (for "make -j"), this can make things slower or even cause them to fail (e.g., this is reported to happen on our Travis builds).
Instead, let's provide a tunable knob. We'll leave the default at "1", but it can be cranked up to "999" for maximum CPU/memory tradeoff, or people can find points in between that serve their particular machines.
Here are a few numbers running a single rule via:
SIZES='1 4 16 999' RULE=contrib/coccinelle/object_id.cocci for i in $SIZES; do make clean /usr/bin/time -o $i.out --format='%e | %U | %S | %M' \ make $RULE.patch SPATCH_BATCH_SIZE=$i done for i in $SIZES; do printf '%4d | %s\n' $i "$(cat $i.out)" donewhich yields:
1 | 97.73 | 93.38 | 4.33 | 100128 4 | 52.80 | 51.14 | 1.69 | 135204 16 | 35.82 | 35.09 | 0.76 | 284124 999 | 23.30 | 23.13 | 0.20 | 1903852The implementation is done with xargs, which should be widely available; it's in POSIX, we rely on it already in the test suite. And "coccicheck" is really a developer-only tool anyway, so it's not a big deal if obscure systems can't run it.
Signed-off-by Jeff King <[email protected]>---
I left the default at 1 for safety. Probably 4 or 16 would be an OK default, but I don't have any interest in figuring out exactly what Travis or some hypothetical average machine can handle. I'll be setting mine to 999. ;)Making "0" work as "unlimited" might be nice, but xargs doesn't support that and I didn't want to make the recipe any more unreadable than it already is.
Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)Makefile +6
-8@@ -1174,8 +1174,10 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -# For the 'coccicheck' target +# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will +# usually result in less CPU usage at the cost of higher peak memory. SPATCH_FLAGS = --all-includes --patch . +SPATCH_BATCH_SIZE = 1 include config.mak.uname -include config.mak.autogen@@ -2790,12 +2792,9 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - ret=0; \ - for f in $(COCCI_SOURCES); do \ - $(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \ - { ret=$$?; break; }; \ - done >$@+ 2>[email protected]; \ - if test $$ret != 0; \ + if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ + >$@+ 2>[email protected]; \ then \ cat [email protected]; \ exit 1; \ --
Quoted 2 lines
2.21.0.1314.g224b191707
This looks reasonable to me :)
Thanks,
Jake
Re: [PATCH] coccicheck: optionally batch spatch invocations
Quoted 7 lines · Jacob Keller
Quoted 4 lines
So here's what I think we should apply:
-- >8 --
Subject: [PATCH] coccicheck: optionally batch spatch invocations[...]
This looks reasonable to me :)
Thanks. I should have added a:
trailer.
-Peff
Re: [PATCH] coccicheck: optionally batch spatch invocations
In reply to Jeff KingQuoted 4 lines · Jeff King
The implementation is done with xargs, which should be widely available; it's in POSIX, we rely on it already in the test suite. And "coccicheck" is really a developer-only tool anyway, so it's not a big deal if obscure systems can't run it.
OK.
Quoted 8 lines
I left the default at 1 for safety. Probably 4 or 16 would be an OK default, but I don't have any interest in figuring out exactly what Travis or some hypothetical average machine can handle. I'll be setting mine to 999. ;)
Making "0" work as "unlimited" might be nice, but xargs doesn't support that and I didn't want to make the recipe any more unreadable than it already is.
Sounds good. After reading the log message, I was curious if there is a mechanism that makes 999 special (like 0 in your hypothetical "0 means unlimited"), but I guess it is just "any number that is greater than the number of source files we have will do".
Thanks.
Re: [PATCH] coccicheck: optionally batch spatch invocations
Quoted 8 lines · Junio C Hamano
Quoted 3 lines
Making "0" work as "unlimited" might be nice, but xargs doesn't support that and I didn't want to make the recipe any more unreadable than it already is.
Sounds good. After reading the log message, I was curious if there is a mechanism that makes 999 special (like 0 in your hypothetical "0 means unlimited"), but I guess it is just "any number that is greater than the number of source files we have will do".
Yes, 2^31-1 is probably a better number, but it's harder to write out. :)
Here's what a patch might look like to implement "0". By still using xargs in the unlimited code path, it's not too bad. I dunno.
---
Makefile +6 -1
@@ -2792,7 +2792,12 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + if test $(SPATCH_BATCH_SIZE) = 0; then \ + limit=; \ + else \ + limit='-n $(SPATCH_BATCH_SIZE)'; \ + fi; \ + if ! echo $(COCCI_SOURCES) | xargs $$limit \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \
-Peff
Re: [PATCH] coccicheck: optionally batch spatch invocations
Quoted 14 lines · Jeff King
Here's what a patch might look like to implement "0". By still using xargs in the unlimited code path, it's not too bad. I dunno.
---
Makefile +1
-1@@ -2792,7 +2792,12 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + if test $(SPATCH_BATCH_SIZE) = 0; then \
Makefile endif
Quoted 10 lines
Makefile +5
-1+ limit=; \ + else \ + limit='-n $(SPATCH_BATCH_SIZE)'; \ + fi; \ + if ! echo $(COCCI_SOURCES) | xargs $$limit \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \ -Peff
This doesn't seem too complicated to me..
Re: [PATCH] coccicheck: optionally batch spatch invocations
In reply to Jeff KingQuoted 4 lines · Jeff King
Yes, 2^31-1 is probably a better number, but it's harder to write out. :)
Here's what a patch might look like to implement "0". By still using xargs in the unlimited code path, it's not too bad. I dunno.
As somebody who is too used to run "diff -U999" and be happy, I cannot claim that I care enough, but the result does not look too bad.
Quoted 22 lines
---
Makefile +6
-2@@ -2792,7 +2792,12 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + if test $(SPATCH_BATCH_SIZE) = 0; then \ + limit=; \ + else \ + limit='-n $(SPATCH_BATCH_SIZE)'; \ + fi; \ + if ! echo $(COCCI_SOURCES) | xargs $$limit \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \ -Peff
Re: [PATCH] coccicheck: optionally batch spatch invocations
Quoted 10 lines · Junio C Hamano
Quoted 4 lines · Jeff King
Yes, 2^31-1 is probably a better number, but it's harder to write out. :)
Here's what a patch might look like to implement "0". By still using xargs in the unlimited code path, it's not too bad. I dunno.
As somebody who is too used to run "diff -U999" and be happy, I cannot claim that I care enough, but the result does not look too bad.
OK. With two "not too bad" comments (plus my own similar feeling), let's just do it. Here it is as a patch on top. It can also be squashed into the tip of jk/cocci-batch, but then we should probably s/999/0/ in the commit message. :)
-- >8 --
Subject: [PATCH] coccicheck: make batch size of 0 mean "unlimited"
If you have the memory to handle it, the ideal case is to run a single spatch invocation with all of the source files. But the only way to do so now is to pick an arbitrarily large batch size. Let's make "0" do this, which is a little friendlier (and doesn't otherwise have a useful meaning).
--- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Makefile +7 -1
@@ -1176,6 +1176,7 @@ SP_EXTRA_FLAGS = # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. +# Setting it to 0 will feed all files in a single spatch invocation. SPATCH_FLAGS = --all-includes --patch . SPATCH_BATCH_SIZE = 1
@@ -2792,7 +2793,12 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + if test $(SPATCH_BATCH_SIZE) = 0; then \ + limit=; \ + else \ + limit='-n $(SPATCH_BATCH_SIZE)'; \ + fi; \ + if ! echo $(COCCI_SOURCES) | xargs $$limit \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \
Signature · 1 line
2.21.0.1314.g224b191707
Re: [PATCH] coccicheck: optionally batch spatch invocations
Hi Jeff,
Quoted 45 lines · Jeff King
Quoted 10 lines · Junio C Hamano
Quoted 4 lines · Jeff King
Yes, 2^31-1 is probably a better number, but it's harder to write out. :)
Here's what a patch might look like to implement "0". By still using xargs in the unlimited code path, it's not too bad. I dunno.
As somebody who is too used to run "diff -U999" and be happy, I cannot claim that I care enough, but the result does not look too bad.
OK. With two "not too bad" comments (plus my own similar feeling), let's just do it. Here it is as a patch on top. It can also be squashed into the tip of jk/cocci-batch, but then we should probably s/999/0/ in the commit message. :)
-- >8 --
Subject: [PATCH] coccicheck: make batch size of 0 mean "unlimited"If you have the memory to handle it, the ideal case is to run a single spatch invocation with all of the source files. But the only way to do so now is to pick an arbitrarily large batch size. Let's make "0" do this, which is a little friendlier (and doesn't otherwise have a useful meaning).
Signed-off-by Jeff King <[email protected]>--- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)Makefile +1
-0@@ -1176,6 +1176,7 @@ SP_EXTRA_FLAGS = # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. +# Setting it to 0 will feed all files in a single spatch invocation. SPATCH_FLAGS = --all-includes --patch . SPATCH_BATCH_SIZE = 1
Makefile endif · line 2800
Quoted 9 lines
Makefile +5
-1@@ -2792,7 +2793,12 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + if test $(SPATCH_BATCH_SIZE) = 0; then \ + limit=; \ + else \ + limit='-n $(SPATCH_BATCH_SIZE)'; \ + fi; \
Could we pull limit out of the recipe and into a make variable? You mentioned earlier that you wanted to do this but it was too complicated but now that it's written like this, it seem like it'd be pretty easy to do.
Quoted 7 lines
Makefile +1
-0+ if ! echo $(COCCI_SOURCES) | xargs $$limit \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \Signature · 1 line
2.21.0.1314.g224b191707
Re: [PATCH] coccicheck: optionally batch spatch invocations
Quoted 5 lines · Denton Liu
Quoted 5 lines
%.cocci.patch: %.cocci $(COCCI_SOURCES)
(quoted diff) +2
-1@echo ' ' SPATCH $<; \ - if ! echo $(COCCI_SOURCES) | xargs -n $(SPATCH_BATCH_SIZE) \ + if test $(SPATCH_BATCH_SIZE) = 0; then \ + limit=; \
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ else \ + limit='-n $(SPATCH_BATCH_SIZE)'; \ + fi; \Could we pull
limitout of the recipe and into a make variable? You mentioned earlier that you wanted to do this but it was too complicated but now that it's written like this, it seem like it'd be pretty easy to do.
Yes, we could, because this part of it is a straight text substitution in the recipe, and not a conditional. I don't know that it's any more readable, though. Either that same conditional gets split out like:
ifeq ($(SPATCH_BATCH_SIZE),0) SPATCH_LIMIT = else SPATCH_LIMIT = -n $(SPATCH_BATCH_SIZE) endif
or we do it inline, but IMHO it's still pretty cluttered:
Makefile +2 -6
@@ -2793,12 +2793,8 @@ endif %.cocci.patch: %.cocci $(COCCI_SOURCES) @echo ' ' SPATCH $<; \ - if test $(SPATCH_BATCH_SIZE) = 0; then \ - limit=; \ - else \ - limit='-n $(SPATCH_BATCH_SIZE)'; \ - fi; \ - if ! echo $(COCCI_SOURCES) | xargs $$limit \ + if ! echo $(COCCI_SOURCES) | \ + xargs $(if $(filter 0,$(SPATCH_BATCH_SIZE)),,-n $(SPATCH_BATCH_SIZE)) \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \
It gets a little better if we make the sentinel value the empty string instead of "0" (you can drop the filter).
-Peff
Re: [PATCH] coccicheck: optionally batch spatch invocations
In reply to Jeff KingQuoted 6 lines · Jeff King
Quoted 3 lines · Duy Nguyen
Quoted 2 lines
However, it comes at a cost. The RSS of each spatch process goes from ~50MB to ~1500MB (and peak memory usage may be even higher if make runs
Quoted 8 lines
Quoted 5 lines
1.5G should be fine. Trying...
Even with no -j, my htop's RES column goes up 6GB and put my laptop in "swap every bit of memory out, including the bits handling the screen" mode :( I don't think it was even the peak.
Interesting if you have a different version of spatch. I'm using 1.0.4 from Debian unstable.
I'm using 1.0.6
Quoted 25 lines
Ideally we'd just invoke a single instance of spatch per rule-file and feed it all source files. But spatch can be rather memory hungry when run in this way. I measured the peak RSS going from ~90MB for a single file to ~1900MB for all files. Multiplied by multiple rule files being processed at the same time (for "make -j"), this can make things slower or even cause them to fail (e.g., this is reported to happen on our Travis builds).
Instead, let's provide a tunable knob. We'll leave the default at "1", but it can be cranked up to "999" for maximum CPU/memory tradeoff, or people can find points in between that serve their particular machines.
Here are a few numbers running a single rule via:
SIZES='1 4 16 999' RULE=contrib/coccinelle/object_id.cocci for i in $SIZES; do make clean /usr/bin/time -o $i.out --format='%e | %U | %S | %M' \ make $RULE.patch SPATCH_BATCH_SIZE=$i done for i in $SIZES; do printf '%4d | %s\n' $i "$(cat $i.out)" done
Quoted 6 lines
which yields:
1 | 97.73 | 93.38 | 4.33 | 100128 4 | 52.80 | 51.14 | 1.69 | 135204 16 | 35.82 | 35.09 | 0.76 | 284124 999 | 23.30 | 23.13 | 0.20 | 1903852
I think I'm going to settle around 32 which has peak at 2GB for me and I can still make use of 4 hyperthread cores.
It's weird for me though that no SIZES=1 is actually the fastest. The larger SPATCH_BATCH_SIZE is, the slower:
Quoted 2 lines
~/w/git/temp $ rm
contrib/coccinelle/commit.cocci.patch~/w/git/temp $ time makecontrib/coccinelle/commit.cocci.patch
SPATCH contrib/coccinelle/commit.cocci
real 1m20,242s user 1m15,863s sys 0m4,376s
Quoted 2 lines
~/w/git/temp $ rm
contrib/coccinelle/commit.cocci.patch
~/w/git/temp $ time makecontrib/coccinelle/commit.cocci.patchSPATCH_BATCH_SIZE=16
SPATCH contrib/coccinelle/commit.cocci
real 3m3,131s user 2m59,345s sys 0m3,819s
Quoted 2 lines
~/w/git/temp $ rm
contrib/coccinelle/commit.cocci.patch
~/w/git/temp $ time makecontrib/coccinelle/commit.cocci.patchSPATCH_BATCH_SIZE=32
SPATCH contrib/coccinelle/commit.cocci
real 5m10,966s user 5m5,434s sys 0m5,500s
But that might be just cocci or environmental problem. Since you and Jacob both see good speedup, this patch is good.
Signature · 1 line
Duy
Re: [PATCH] coccicheck: optionally batch spatch invocations
In reply to Jeff KingQuoted 5 lines · Jeff King
Subject: [PATCH] coccicheck: optionally batch spatch invocations
In our "make coccicheck" rule, we currently feed each source file to its own individual invocation of spatch. This has a few downsides:
Quoted 7 lines
- it repeats any overhead spatch has for starting up and reading the patch file
- any included header files may get processed from multiple invocations. This is slow (we see the same header files multiple times) and may produce a resulting patch with repeated hunks (which cannot be applied without further cleanup)
I wonder what would happen (and how it would perform) if we told spatch to ignore all include files from our C sources, but then run it on each of our header files as well. It still would have to parse the semantic patches over and over again, but those are rather small (compared to, say, 'git-compar-util.h' and 'cache.h' that are included in most of our source files). But I don't know how the lack of information about preprocessor macros would affect Coccinelle's analyzis.
Quoted 2 lines
Ideally we'd just invoke a single instance of spatch per rule-file and feed it all source files.
Well, ideally we would invoke spatch with '--dir .' to "process all files in directory recursively", and exclude those that we are not interested in (parts of 'compat/', 'sha1dc')... but alas, such an exclude mechanism doesn't seem to exist.
PATCH 1/1 Makefile: fix bugs in coccicheck and speed it up
In reply to Jeff KingI've often wondered why "make coccicheck" takes so long. This change speeds it up by ~2x and makes it use much less memory. Or a reduction of a max of around ~2GB per-process (under the old SPATCH_BATCH_SIZE=0) to around ~200MB.
Running the full "make coccicheck" now takes ~50 seconds with -j8 on my machine, v.s. ~2x of that before. I've got 64GB of memory on that machine, or it would be much slower.
Why has it been so slow? Because I think we've always been running it in entirely the wrong mode for what we wanted, and much of the previous fixing of this target has involved re-arranging the deck chairs on that particular Titanic.
What we really want to do with coccicheck is to do search/replacements in all our *.c and *.h files. This is now what we do, and we'll process a default of 64 files at a time.
What we were doing before was processing all our *.c files, and for each of those *.c files we'd recursively look around for includes and see if we needed to search/replace in those too.
That we did that dates back to [1] when we were only processing *.c files, and it was always very redundant. We'd e.g. visit the likes of strbuf.h lots of times since it's widely used as an include.
Then in the most recent attempt to optimize coccicheck in [2] this anti-pattern finally turned into a bug.
Namely: before this change, if your coccicheck rule applied to e.g. making a change in strbuf.h itself we'd get *lots* of duplicate hunks applying the exact same change, as concurrent spatch processes invoked by xargs raced one another. In one instance I ended up with 27 copies of the same hunk in a strbuf.patch.
Setting SPATCH_BATCH_SIZE=0 and processing all the files in one giant batch mitigated this. I suspect the author of [2] either mostly ran in that mode, or didn't test on changes that impacted widely used header files.
So since we're going to want to process all our *.c and *.h let's just do that, and drop --all-includes for --no-includes. It's not spatch's job to find our sources, we're doing that. If someone is manually tweaking COCCI_SOURCES they can just tweak SPATCH_FLAGS too.
I'm entirely removing SPATCH_BATCH_SIZE. If you want to tweak it you can tweak SPATCH_XARGS_FLAGS to e.g. "-n 256", or "-P 4 -n 128". But in my testing it isn't worth it to tweak SPATCH_XARGS_FLAGS for a full "make coccicheck".
I'm also the whole "cat [email protected]" introduced in [3]. Since we don't call this in a loop anymore (and xargs will early-exit) we can just rely on standard V=1 for debugging issues.
1. a9a884aea5 (coccicheck: use --all-includes by default, 2016-09-30)
2. 960154b9c1 (coccicheck: optionally batch spatch invocations, 2019-05-06)
3. f5c2bc2b96 (Makefile: detect errors in running spatch, 2017-03-10)
--- Makefile | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-)
Makefile +22 -19
@@ -1195,11 +1195,20 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer -# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will -# usually result in less CPU usage at the cost of higher peak memory. -# Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_FLAGS = --all-includes --patch . -SPATCH_BATCH_SIZE = 1 +SPATCH_FLAGS = --no-includes --patch . +# For the 'coccicheck' target; Tweaking SPATCH_XARGS_FLAGS is +# generally not neccesary with a top-level -jN. +# +# To get concurrency when targeting a single +# contrib/coccinelle/%.patch use e.g. "-P" if your xargs(1) supports +# it: +# +# make contrib/coccinelle/strbuf.cocci.patch SPATCH_XARGS_FLAGS="-P 8 -n 64" +# +# Or a combination of the two: +# +# make -j4 coccicheck SPATCH_XARGS_FLAGS="-P 2 -n 64" +SPATCH_XARGS_FLAGS = include config.mak.uname -include config.mak.autogen
@@ -2852,24 +2861,18 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES) $(QUIET_SPATCH) \ - if test $(SPATCH_BATCH_SIZE) = 0; then \ - limit=; \ - else \ - limit='-n $(SPATCH_BATCH_SIZE)'; \ - fi; \ - if ! echo $(COCCI_SOURCES) | xargs $$limit \ - $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ - >$@+ 2>[email protected]; \ - then \ - cat [email protected]; \ - exit 1; \ - fi; \ - mv $@+ $@; \ + $(RM) $@+ [email protected] && \ + echo $(COCCI_SOURCES) | \ + xargs \ + -n 32 $(SPATCH_XARGS_FLAGS) \ + $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ + >>$@+ 2>>[email protected] && \ + mv $@+ $@ && \ if test -s $@; \ then \ echo ' ' SPATCH result: $@; \
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
On Tue, Mar 02 2021, Ævar Arnfjörð Bjarmason wrote:
A few notes, for a probable re-roll sometime later:
Quoted 4 lines
I've often wondered why "make coccicheck" takes so long. This change speeds it up by ~2x and makes it use much less memory. Or a reduction of a max of around ~2GB per-process (under the old SPATCH_BATCH_SIZE=0) to around ~200MB.
I've also tested this with e.g. "strace -c -f -e trace=openat ", before/after with just contrib/coccinelle/swap.cocci.patch:
192612
13106Grepping e.g. for strbuf.h shows that when running "make coccicheck" we open it 12 times as expected (we have 12 rules)
strace -f -e trace=openat make -j8 coccicheck 2>&1|grep 'openat.*"strbuf\.h"' | wc -l 12
(Is there a more direct way to filter this type of thing with strace?)
Before:
$ strace -f -e trace=openat make -j8 coccicheck 2>&1|grep 'openat.*"strbuf\.h"' | wc -l
137Quoted 4 lines
[...]
I'm also the whole "cat [email protected]" introduced in [3]. Since we don't call this in a loop anymore (and xargs will early-exit) we can just rely on standard V=1 for debugging issues.
Noticed by Denton in the side-thread, should be:
I'm also removing the whole "cat [email protected]" feature introduced in...
Makefile check: config-list.h command-list.h · line 2872
Quoted 2 lines
Makefile +2
-0+ xargs \ + -n 32 $(SPATCH_XARGS_FLAGS) \
As an aside this relies on xargs not barfing on "xargs -n 1 -n 2", i.e. taking 2 over 1. I tested it on Linux/AIX/OpenBSD/Solaris, works consistently on all of them.
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
In reply to Ævar Arnfjörð BjarmasonHi Ævar,
Quoted 40 lines · Ævar Arnfjörð Bjarmason
I've often wondered why "make coccicheck" takes so long. This change speeds it up by ~2x and makes it use much less memory. Or a reduction of a max of around ~2GB per-process (under the old SPATCH_BATCH_SIZE=0) to around ~200MB.
Running the full "make coccicheck" now takes ~50 seconds with -j8 on my machine, v.s. ~2x of that before. I've got 64GB of memory on that machine, or it would be much slower.
Why has it been so slow? Because I think we've always been running it in entirely the wrong mode for what we wanted, and much of the previous fixing of this target has involved re-arranging the deck chairs on that particular Titanic.
What we really want to do with coccicheck is to do search/replacements in all our *.c and *.h files. This is now what we do, and we'll process a default of 64 files at a time.
What we were doing before was processing all our *.c files, and for each of those *.c files we'd recursively look around for includes and see if we needed to search/replace in those too.
That we did that dates back to [1] when we were only processing *.c files, and it was always very redundant. We'd e.g. visit the likes of
strbuf.hlots of times since it's widely used as an include.Then in the most recent attempt to optimize coccicheck in [2] this anti-pattern finally turned into a bug.
Namely: before this change, if your coccicheck rule applied to e.g. making a change in
strbuf.hitself we'd get *lots* of duplicate hunks applying the exact same change, as concurrent spatch processes invoked by xargs raced one another. In one instance I ended up with 27 copies of the same hunk in a strbuf.patch.Setting SPATCH_BATCH_SIZE=0 and processing all the files in one giant batch mitigated this. I suspect the author of [2] either mostly ran in that mode, or didn't test on changes that impacted widely used header files.
Quoted 4 lines
So since we're going to want to process all our *.c and *.h let's just do that, and drop --all-includes for --no-includes. It's not spatch's job to find our sources, we're doing that. If someone is manually tweaking
COCCI_SOURCESthey can just tweakSPATCH_FLAGStoo.
This is a very clean and well-done analysis.
I've also timed my runs and the effects are really obvious:
Before:
$ time make -j7 coccicheck SPATCH contrib/coccinelle/array.cocci SPATCH contrib/coccinelle/commit.cocci SPATCH contrib/coccinelle/free.cocci SPATCH contrib/coccinelle/hashmap.cocci SPATCH contrib/coccinelle/object_id.cocci SPATCH contrib/coccinelle/preincr.cocci SPATCH contrib/coccinelle/strbuf.cocci SPATCH contrib/coccinelle/swap.cocci SPATCH contrib/coccinelle/xstrdup_or_null.cocci
real 3m15.215s user 17m36.779s sys 1m4.262s
After:
$ time make -j7 coccicheck GIT_VERSION = 2.31.0.rc1.1.gd8c3638591 SPATCH contrib/coccinelle/array.cocci SPATCH contrib/coccinelle/commit.cocci SPATCH contrib/coccinelle/flex_alloc.cocci SPATCH contrib/coccinelle/free.cocci SPATCH contrib/coccinelle/hashmap.cocci SPATCH contrib/coccinelle/object_id.cocci SPATCH contrib/coccinelle/preincr.cocci SPATCH contrib/coccinelle/qsort.cocci SPATCH contrib/coccinelle/strbuf.cocci SPATCH contrib/coccinelle/swap.cocci SPATCH contrib/coccinelle/xstrdup_or_null.cocci
real 1m14.070s user 7m40.644s sys 0m13.689s
so this gets my
Quoted 6 lines
I'm entirely removing
SPATCH_BATCH_SIZE. If you want to tweak it you can tweakSPATCH_XARGS_FLAGSto e.g. "-n 256", or "-P 4 -n 128". But in my testing it isn't worth it to tweakSPATCH_XARGS_FLAGSfor a full "make coccicheck".I'm also the whole "cat [email protected]" introduced in [3]. Since we don't call
I'm also... what? :)
Quoted 9 lines
this in a loop anymore (and xargs will early-exit) we can just rely on standard V=1 for debugging issues.
1.
a9a884aea5(coccicheck: use --all-includes by default, 2016-09-30)
2.960154b9c1(coccicheck: optionally batch spatch invocations, 2019-05-06)
3.f5c2bc2b96(Makefile: detect errors in running spatch, 2017-03-10)Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
In reply to Ævar Arnfjörð BjarmasonQuoted 55 lines · Ævar Arnfjörð Bjarmason
I've often wondered why "make coccicheck" takes so long. This change speeds it up by ~2x and makes it use much less memory. Or a reduction of a max of around ~2GB per-process (under the old SPATCH_BATCH_SIZE=0) to around ~200MB.
Running the full "make coccicheck" now takes ~50 seconds with -j8 on my machine, v.s. ~2x of that before. I've got 64GB of memory on that machine, or it would be much slower.
Why has it been so slow? Because I think we've always been running it in entirely the wrong mode for what we wanted, and much of the previous fixing of this target has involved re-arranging the deck chairs on that particular Titanic.
What we really want to do with coccicheck is to do search/replacements in all our *.c and *.h files. This is now what we do, and we'll process a default of 64 files at a time.
What we were doing before was processing all our *.c files, and for each of those *.c files we'd recursively look around for includes and see if we needed to search/replace in those too.
That we did that dates back to [1] when we were only processing *.c files, and it was always very redundant. We'd e.g. visit the likes of
strbuf.hlots of times since it's widely used as an include.Then in the most recent attempt to optimize coccicheck in [2] this anti-pattern finally turned into a bug.
Namely: before this change, if your coccicheck rule applied to e.g. making a change in
strbuf.hitself we'd get *lots* of duplicate hunks applying the exact same change, as concurrent spatch processes invoked by xargs raced one another. In one instance I ended up with 27 copies of the same hunk in a strbuf.patch.Setting SPATCH_BATCH_SIZE=0 and processing all the files in one giant batch mitigated this. I suspect the author of [2] either mostly ran in that mode, or didn't test on changes that impacted widely used header files.
So since we're going to want to process all our *.c and *.h let's just do that, and drop --all-includes for --no-includes. It's not spatch's job to find our sources, we're doing that. If someone is manually tweaking
COCCI_SOURCESthey can just tweakSPATCH_FLAGStoo.I'm entirely removing
SPATCH_BATCH_SIZE. If you want to tweak it you can tweakSPATCH_XARGS_FLAGSto e.g. "-n 256", or "-P 4 -n 128". But in my testing it isn't worth it to tweakSPATCH_XARGS_FLAGSfor a full "make coccicheck".I'm also the whole "cat [email protected]" introduced in [3]. Since we don't call this in a loop anymore (and xargs will early-exit) we can just rely on standard V=1 for debugging issues.
Quoted 7 lines
1.
a9a884aea5(coccicheck: use --all-includes by default, 2016-09-30)
2.960154b9c1(coccicheck: optionally batch spatch invocations, 2019-05-06)
3.f5c2bc2b96(Makefile: detect errors in running spatch, 2017-03-10)Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>---
Nice, so in short, we've been redundantly running the checker code over and over on the same header files wasting cycles.
Even though I saw you mentioned something about preparing for a reroll, I'll tentatively queue this version to 'seen' for now.
THanks.
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
Quoted 7 lines · Junio C Hamano
Quoted 1 line · Ævar Arnfjörð Bjarmason
[...]
Nice, so in short, we've been redundantly running the checker code over and over on the same header files wasting cycles.
Even though I saw you mentioned something about preparing for a reroll, I'll tentatively queue this version to 'seen' for now.
Hopefully soon, was waiting to see if there were more comments & what Jeff King thought of it, he's replied now. Will address that (haven't read it yet) and re-roll as needed...
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
In reply to Ævar Arnfjörð BjarmasonQuoted 7 lines · Ævar Arnfjörð Bjarmason
What we were doing before was processing all our *.c files, and for each of those *.c files we'd recursively look around for includes and see if we needed to search/replace in those too.
That we did that dates back to [1] when we were only processing *.c files, and it was always very redundant. We'd e.g. visit the likes of
strbuf.hlots of times since it's widely used as an include.
OK. I don't offhand know if processing the includes along with the C files buys us anything else. Coccinelle's behavior is often quite a mystery, but if we think this produces the same results with less time, I'm for it.
BTW, this "dates back to when we were only processing *.c files" statement confused me a bit. Doesn't that include the current state before this patch? I.e., this hunk:
Review
Quoted 2 lines
(quoted diff) +1
-1-FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES)))
seems to be an important part of the change, without which moving away from --all-includes would be wrong.
Quoted 9 lines
Then in the most recent attempt to optimize coccicheck in [2] this anti-pattern finally turned into a bug.
Namely: before this change, if your coccicheck rule applied to e.g. making a change in
strbuf.hitself we'd get *lots* of duplicate hunks applying the exact same change, as concurrent spatch processes invoked by xargs raced one another. In one instance I ended up with 27 copies of the same hunk in a strbuf.patch.
Quoted 4 lines
Setting SPATCH_BATCH_SIZE=0 and processing all the files in one giant batch mitigated this. I suspect the author of [2] either mostly ran in that mode, or didn't test on changes that impacted widely used header files.
This "turned into a bug" I didn't understand, though. That commit [2] just switched from always feeding files one at a time to letting you feed more than one. So yes, feeding all at once (with SPATCH_BATCH_SIZE=0) mitigated the bug. But wouldn't any bug that shows up with SPATCH_BATCH_SIZE=1 have already existed previously?
IOW, I don't think the batch-size stuff made anything worse. It made one specific case better, but that was not even its purpose.
That is maybe splitting hairs, but I want to make sure I understand all of what you're claiming here. But also...
Quoted 4 lines
I'm entirely removing
SPATCH_BATCH_SIZE. If you want to tweak it you can tweakSPATCH_XARGS_FLAGSto e.g. "-n 256", or "-P 4 -n 128". But in my testing it isn't worth it to tweakSPATCH_XARGS_FLAGSfor a full "make coccicheck".
You hard-code this to 32 now. But I'm not sure if that's going to be the universal best value.
Applying just part of your patch, but leaving SPATCH_BATCH_SIZE in place, like so:
Makefile +2 -2
@@ -1201,7 +1201,7 @@ SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_FLAGS = --all-includes --patch . +SPATCH_FLAGS = --no-includes --patch . SPATCH_BATCH_SIZE = 1 include config.mak.uname
@@ -2859,7 +2859,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES)
Then I get this with various batch sizes (using "make -j16" on an 8-core machine, so all of the patches are being run at the same time):
size | real | user | sys
-------------------------------
1 | 1m28s | 10m00s | 0m56s
2 | 1m03s | 7m49s | 0m33s
4 | 0m51s | 6m28s | 0m20s
8 | 0m45s | 6m02s | 0m14s
16 | 0m45s | 6m17s | 0m10s
32 | 0m44s | 6m33s | 0m07s
64 | 0m45s | 6m48s | 0m06s
0 | 1m08s | 10m08s | 0m03sSo there's a sweet spot at 8. Doing "32" isn't that much worse (runtime is about the same, but we use more CPU), but it gets progressively worse as the batch size increases.
That's the same sweet spot before your patch, too, btw. I know because I happened to be timing it the other day, as coccinelle 1.1.0 hit debian unstable. When I originally wrote the SPATCH_BATCH_SIZE feature, I think I was using 1.0.4 or 1.0.7. Back then SPATCH_BATCH_SIZE=0 was a clear win, assuming you had the memory. But in 1.0.8 it ran for many minutes without finishing. I found back then that "2" was the sweet spot. But now it's "8".
All of which is to say: the timing difference between my "8" and "32" cases isn't that exciting. But the performance of spatch has been sufficiently baffling to me that I think it's worth keeping the knob.
Your XARGS_FLAGS does accomplish something similar (and is in fact more flexible, though at the cost of being less abstract). I'm OK to replace one with the other, but shouldn't it happen in a separate patch? It's completely orthogonal to the --no-includes behavior.
Quoted 3 lines
I'm also the whole "cat [email protected]" introduced in [3]. Since we don't call this in a loop anymore (and xargs will early-exit) we can just rely on standard V=1 for debugging issues.
I think this is missing the point of the cat. We've redirected spatch's stderr to the logfile. So if there's an error, you have no idea what it was without manually figuring out which file to cat. And V=1 doesn't help that.
We could stop doing that redirection, but the problem is that spatch is very verbose. So the point was to store the output but only dump it when we see an error.
So this part of the patch seems like a pure regression to me. E.g., introduce a syntax error like:
contrib/coccinelle/free.cocci +1 -1
@@ -11,7 +11,7 @@ expression E; free(E); @@ -expression E; +expression E @@ - free(E); + FREE_AND_NULL(E);
and run "make coccicheck" before and after your patch:
[before]
$ make coccicheck
GIT_VERSION = 2.31.0.rc1.8.gbe7935ed8b.dirty
SPATCH contrib/coccinelle/free.cocci
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h
meta: parse error:
File "contrib/coccinelle/free.cocci", line 15, column 0, charpos = 99
around = '@@',
whole content = @@ xargs: spatch: exited with status 255; aborting
make: *** [Makefile:2866: contrib/coccinelle/free.cocci.patch] Error 1
[after]
$ make coccicheck
SPATCH contrib/coccinelle/free.cocci
make: *** [Makefile:2875: contrib/coccinelle/free.cocci.patch] Error 124-Peff
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
On Fri, Mar 05 2021, Jeff King wrote:
I sent out a v2 that should address your feedback in :
https://lore.kernel.org/git/[email protected]/
Just brief notes:
Quoted 19 lines · Ævar Arnfjörð Bjarmason
Quoted 8 lines
What we were doing before was processing all our *.c files, and for each of those *.c files we'd recursively look around for includes and see if we needed to search/replace in those too.
That we did that dates back to [1] when we were only processing *.c files, and it was always very redundant. We'd e.g. visit the likes of
strbuf.hlots of times since it's widely used as an include.OK. I don't offhand know if processing the includes along with the C files buys us anything else. Coccinelle's behavior is often quite a mystery, but if we think this produces the same results with less time, I'm for it.
BTW, this "dates back to when we were only processing *.c files" statement confused me a bit. Doesn't that include the current state before this patch? I.e., this hunk:
Quoted 5 lines
Makefile check: config-list.h command-list.h · line 2862
Quoted 2 lines
Makefile +1
-1-FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES)))seems to be an important part of the change, without which moving away from --all-includes would be wrong.
Updated in the new 2/4 commit message.
Quoted 20 lines
Quoted 9 lines
Then in the most recent attempt to optimize coccicheck in [2] this anti-pattern finally turned into a bug.
Namely: before this change, if your coccicheck rule applied to e.g. making a change in
strbuf.hitself we'd get *lots* of duplicate hunks applying the exact same change, as concurrent spatch processes invoked by xargs raced one another. In one instance I ended up with 27 copies of the same hunk in a strbuf.patch.Quoted 4 lines
Setting SPATCH_BATCH_SIZE=0 and processing all the files in one giant batch mitigated this. I suspect the author of [2] either mostly ran in that mode, or didn't test on changes that impacted widely used header files.
This "turned into a bug" I didn't understand, though. That commit [2] just switched from always feeding files one at a time to letting you feed more than one. So yes, feeding all at once (with SPATCH_BATCH_SIZE=0) mitigated the bug. But wouldn't any bug that shows up with SPATCH_BATCH_SIZE=1 have already existed previously?
Quoted 5 lines
IOW, I don't think the batch-size stuff made anything worse. It made one specific case better, but that was not even its purpose.
That is maybe splitting hairs, but I want to make sure I understand all of what you're claiming here. But also...
Explained in the new 2/4. Your commit introduced a regression, because spatch does racy magic background locking, running N of them at a time applying the same rule tripped it up.
I suspect it was racy before, but we didn't have overlapping rules in multiple *.cocci files.
Quoted 60 lines
Quoted 4 lines
I'm entirely removing
SPATCH_BATCH_SIZE. If you want to tweak it you can tweakSPATCH_XARGS_FLAGSto e.g. "-n 256", or "-P 4 -n 128". But in my testing it isn't worth it to tweakSPATCH_XARGS_FLAGSfor a full "make coccicheck".You hard-code this to 32 now. But I'm not sure if that's going to be the universal best value.
Applying just part of your patch, but leaving
SPATCH_BATCH_SIZEin place, like so:Makefile +2
-2@@ -1201,7 +1201,7 @@ SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_FLAGS = --all-includes --patch . +SPATCH_FLAGS = --no-includes --patch . SPATCH_BATCH_SIZE = 1 include config.mak.uname@@ -2859,7 +2859,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES)Then I get this with various batch sizes (using "make -j16" on an 8-core machine, so all of the patches are being run at the same time):
size | real | user | sys
-------------------------------1 | 1m28s | 10m00s | 0m56s 2 | 1m03s | 7m49s | 0m33s 4 | 0m51s | 6m28s | 0m20s 8 | 0m45s | 6m02s | 0m14s 16 | 0m45s | 6m17s | 0m10s 32 | 0m44s | 6m33s | 0m07s 64 | 0m45s | 6m48s | 0m06s 0 | 1m08s | 10m08s | 0m03sSo there's a sweet spot at 8. Doing "32" isn't that much worse (runtime is about the same, but we use more CPU), but it gets progressively worse as the batch size increases.
That's the same sweet spot before your patch, too, btw. I know because I happened to be timing it the other day, as coccinelle 1.1.0 hit debian unstable. When I originally wrote the
SPATCH_BATCH_SIZEfeature, I think I was using 1.0.4 or 1.0.7. Back then SPATCH_BATCH_SIZE=0 was a clear win, assuming you had the memory. But in 1.0.8 it ran for many minutes without finishing. I found back then that "2" was the sweet spot. But now it's "8".
Quoted 8 lines
All of which is to say: the timing difference between my "8" and "32" cases isn't that exciting. But the performance of spatch has been sufficiently baffling to me that I think it's worth keeping the knob.
Your
XARGS_FLAGSdoes accomplish something similar (and is in fact more flexible, though at the cost of being less abstract). I'm OK to replace one with the other, but shouldn't it happen in a separate patch? It's completely orthogonal to the --no-includes behavior.
*nod*, set to a default of 8 in the new 4/4.
Quoted 42 lines
Quoted 3 lines
I'm also the whole "cat [email protected]" introduced in [3]. Since we don't call this in a loop anymore (and xargs will early-exit) we can just rely on standard V=1 for debugging issues.
I think this is missing the point of the cat. We've redirected spatch's stderr to the logfile. So if there's an error, you have no idea what it was without manually figuring out which file to cat. And V=1 doesn't help that.
We could stop doing that redirection, but the problem is that spatch is very verbose. So the point was to store the output but only dump it when we see an error.
So this part of the patch seems like a pure regression to me. E.g., introduce a syntax error like:
contrib/coccinelle/free.cocci +1
-1@@ -11,7 +11,7 @@ expression E; free(E); @@ -expression E; +expression E @@ - free(E); + FREE_AND_NULL(E);and run "make coccicheck" before and after your patch:
[before]
$ make coccicheck GIT_VERSION = 2.31.0.rc1.8.gbe7935ed8b.dirty SPATCH contrib/coccinelle/free.cocci init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h meta: parse error: File "contrib/coccinelle/free.cocci", line 15, column 0, charpos = 99 around = '@@', whole content = @@
Quoted 7 lines
xargs: spatch: exited with status 255; aborting
make: *** [Makefile:2866:contrib/coccinelle/free.cocci.patch] Error 1[after]
$ make coccicheck SPATCH contrib/coccinelle/free.cocci make: *** [Makefile:2875: contrib/coccinelle/free.cocci.patch] Error 124
The "cat [email protected]" is back, but there's still some issues with it on master now (I didn't change this) it'll spew a lot at you with xargs since we emit the whole error output for every file, seemingly, before cat-ing the file:
make -j1 coccicheck SPATCH_FLAGS=--blahblah V=1 2>&1|grep -i example.*use|wc -l 464
Well, it's a bit better now on my series with a default batch size of 8:
$ make -j1 coccicheck SPATCH_FLAGS=--blahblah V=1 2>&1|grep -i example.*use|wc -l
88I got tired of dealing with the combination of shellscritp and make for the day. But maybe something to do as a follow-up if anyone's interested.
Re: [PATCH] Makefile: fix bugs in coccicheck and speed it up
Quoted 13 lines · Ævar Arnfjörð Bjarmason
Quoted 4 lines
[after]
$ make coccicheck SPATCH contrib/coccinelle/free.cocci make: *** [Makefile:2875: contrib/coccinelle/free.cocci.patch] Error 124The "cat [email protected]" is back, but there's still some issues with it on master now (I didn't change this) it'll spew a lot at you with xargs since we emit the whole error output for every file, seemingly, before cat-ing the file:
make -j1 coccicheck SPATCH_FLAGS=--blahblah V=1 2>&1|grep -i example.*use|wc -l 464
Quoted 8 lines
Well, it's a bit better now on my series with a default batch size of 8:
$ make -j1 coccicheck SPATCH_FLAGS=--blahblah V=1 2>&1|grep -i example.*use|wc -l 88I got tired of dealing with the combination of shellscritp and make for the day. But maybe something to do as a follow-up if anyone's interested.
Hmm, yeah. xargs will keep going unless the command actually returns
255. I never noticed with syntax errors in the cocci files, because those cause spatch to exit with 255!
IMHO that's likely to be the most common error, though probably "oops, you don't have spatch installed" is a close second. But that one also works well, because xargs (at least GNU xargs) will stop if it can't run the program.
So it might be nice to have it bail on the first failure, but I don't know that it's worth spending a lot of time on it.
-Peff
v2 cover Makefile/coccicheck: fix bugs and speed it up
In reply to Ævar Arnfjörð BjarmasonAddresses feedback on v1:
- The removal of the "cat [email protected]" is gone.
- Split up into N changes.
- Explained why 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) broke things and produced duplicate hunks in 2/4: tl;dr: spatch does its own locking etc., xargs -n trips it up.
- Set number of batch processes to 8, as suggested by Jeff King.
Ævar Arnfjörð Bjarmason (4):
Makefile/coccicheck: add comment heading for all SPATCH flags Makefile/coccicheck: speed up and fix bug with duplicate hunks Makefile/coccicheck: allow for setting xargs concurrency Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
Range-diff:
1: 3dfadacc255 < -: ----------- Makefile: fix bugs in coccicheck and speed it up -: ----------- > 1: b556c747afd Makefile/coccicheck: add comment heading for all SPATCH flags -: ----------- > 2: 031e3418491 Makefile/coccicheck: speed up and fix bug with duplicate hunks -: ----------- > 3: 88eab1af9a0 Makefile/coccicheck: allow for setting xargs concurrency -: ----------- > 4: 4b9679fcaba Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Am 05.03.21 um 18:07 schrieb Ævar Arnfjörð Bjarmason:
Quoted 10 lines
Addresses feedback on v1:
- The removal of the "cat [email protected]" is gone.
- Split up into N changes.
- Explained why960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) broke things and produced duplicate hunks in 2/4: tl;dr: spatch does its own locking etc., xargs -n trips it up.
- Set number of batch processes to 8, as suggested by Jeff King.
Quoted 8 lines
Ævar Arnfjörð Bjarmason (4):
Makefile/coccicheck: add comment heading for all SPATCH flags Makefile/coccicheck: speed up and fix bug with duplicate hunks Makefile/coccicheck: allow for setting xargs concurrency Makefile/coccicheck: setSPATCH_BATCH_SIZEto 8Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
This speeds up "make coccicheck" after "make clean" as advertized for me:
before: 572.64s user 33.08s system 622% cpu 1:37.30 total
after: 195.40s user 9.97s system 629% cpu 32.612 total
However, it also misses several conversions that coccicheck generated without this series for the example added by the patch at the bottom. Here's the difference of diffstats (< before, > after):
$ diff <(diffstat b | sort) <(diffstat a | sort) | grep '^[<>]' | sort -k2 -k1
Quoted 1 line
27 files changed, 55 insertions(+), 57 deletions(-)
< 36 files changed, 70 insertions(+), 71 deletions(-) < attr.c | 2 +- > blame.c | 15 +++++++-------- < blame.c | 17 ++++++++--------- < bloom.c | 2 +- < cache-tree.c | 2 +- > combine-diff.c | 18 +++++++++--------- < combine-diff.c | 20 ++++++++++---------- < decorate.c | 2 +- < diffcore-rename.c | 2 +- > diffcore-rename.c | 3 +-- < ewah/bitmap.c | 2 +- < hashmap.c | 2 +- > midx.c | 4 ++-- < midx.c | 8 ++++---- < pack-objects.c | 2 +- < pathspec.c | 2 +- > read-cache.c | 2 +- < read-cache.c | 4 ++-- > ref-filter.c | 2 +- < ref-filter.c | 4 ++-- < remote.c | 2 +-
That's with the current spatch version 1.1.0-00072-g3dc5d027.
contrib/coccinelle/array.cocci +13 -0
@@ -88,3 +88,16 @@ expression n; @@ - ptr = xmalloc((n) * sizeof(T)); + ALLOC_ARRAY(ptr, n); + +@@ +type T; +T *ptr; +expression n != 1; +@@ +( +- ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \)); ++ CALLOC_ARRAY(ptr, n); +| +- ptr = xcalloc(\( sizeof(*ptr) \| sizeof(T) \), n); ++ CALLOC_ARRAY(ptr, n); +)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Am 05.03.21 um 22:18 schrieb Junio C Hamano:
Quoted 20 lines
Quoted 18 lines · René Scharfe.
contrib/coccinelle/array.cocci +10
-0@@ -88,3 +88,16 @@ expression n; @@ - ptr = xmalloc((n) * sizeof(T)); + ALLOC_ARRAY(ptr, n); + +@@ +type T; +T *ptr; +expression n != 1; +@@ +( +- ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \)); ++ CALLOC_ARRAY(ptr, n); +|
Quoted 8 lines
contrib/coccinelle/array.cocci expression n; · line 103
Quoted 3 lines
contrib/coccinelle/array.cocci +3
-0+- ptr = xcalloc(\( sizeof(*ptr) \| sizeof(T) \), n); ++ CALLOC_ARRAY(ptr, n); +)Not about correctness of Ævar's changes to the
Makefile, but the latter half of the above conversion may be a bugfix, no? The first parameter to calloc is the number of elements, and the second one is the size of each element.
Not if both calloc parameters are sizeof(T) or sizeof(*ptr). ;)
Quoted 2 lines
Why should we refrain from doing the conversion when dealing with an array with a single element, by the way?
I find single-element arrays somehow awkward, and there are enough of these cases to have a separate CALLOC macro with just the size parameter. But adding yet another one when the existing similar one is underutilized is a hard sell.
Anyway, what about this more targeted approach:
-- >8 --
Subject: [PATCH] fix xcalloc() argument order
Pass the number of elements first and ther size second, as expected by xcalloc(). Provide a semantic patch, which was actually used to generate the rest of this patch.
The semantic patch would generate flip-flop diffs if both arguments are equivalent sizeofs. We don't have such a case, and it's hard to imagine the usefulness of such an allocation. If it ever occurs then we could deal with it by duplicating the rule in the semantic patch to make it cancel itself out, or we could change the code to use CALLOC_ARRAY.
--- add-interactive.c | 6 +++--- blame.c | 14 +++++++------- contrib/coccinelle/xcalloc.cocci | 10 ++++++++++ range-diff.c | 2 +- ref-filter.c | 5 +++-- trailer.c | 8 ++++---- 6 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 contrib/coccinelle/xcalloc.cocci
add-interactive.c +3 -3
@@ -413,7 +413,7 @@ struct file_item {static void add_file_item (struct string_list *files,const char *name) { -struct file_item *item =xcalloc (sizeof (*item),1 ); +struct file_item *item =xcalloc (1 ,sizeof (*item));string_list_append (files, name)->util = item; }
@@ -476,7 +476,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,add_file_item (s->files, name); - entry =xcalloc (sizeof (*entry),1 ); + entry =xcalloc (1 ,sizeof (*entry));hashmap_entry_init (&entry->ent, hash); entry->name = s->files->items[s->files->nr -1 ].string; entry->item = s->files->items[s->files->nr -1 ].util;
@@ -1120,7 +1120,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps)int res =0 ;for (i =0 ; i <ARRAY_SIZE (command_list); i++) { -struct command_item *util =xcalloc (sizeof (*util),1 ); +struct command_item *util =xcalloc (1 ,sizeof (*util)); util->command = command_list[i].command;string_list_append (&commands.items, command_list[i].string) ->util = util;
blame.c +7 -7
@@ -951,13 +951,13 @@ static int *fuzzy_find_matching_lines(struct blame_origin *parent, max_search_distance_b = ((2 * max_search_distance_a +1 ) * length_b -1 ) / length_a; - result =xcalloc (sizeof (int ), length_b); - second_best_result =xcalloc (sizeof (int ), length_b); - certainties =xcalloc (sizeof (int ), length_b); + result =xcalloc (length_b,sizeof (int )); + second_best_result =xcalloc (length_b,sizeof (int )); + certainties =xcalloc (length_b,sizeof (int ));/* See get_similarity() for details of similarities. */ similarity_count = length_b * (max_search_distance_a *2 +1 ); - similarities =xcalloc (sizeof (int ), similarity_count); + similarities =xcalloc (similarity_count,sizeof (int ));for (i =0 ; i < length_b; ++i) { result[i] =-1 ;
@@ -995,7 +995,7 @@ static void fill_origin_fingerprints(struct blame_origin *o)return ; o->num_lines =find_line_starts (&line_starts, o->file.ptr, o->file.size); - o->fingerprints =xcalloc (sizeof (struct fingerprint ), o->num_lines); + o->fingerprints =xcalloc (o->num_lines,sizeof (struct fingerprint ));get_line_fingerprints (o->fingerprints, o->file.ptr, line_starts,0 , o->num_lines);free (line_starts);
@@ -1853,8 +1853,8 @@ static void blame_chunk(struct blame_entry ***dstq, struct blame_entry ***srcq, diffp =NULL ;if (ignore_diffs && same - tlno >0 ) { - line_blames =xcalloc (sizeof (struct blame_line_tracker ), - same - tlno); + line_blames =xcalloc (same - tlno, +sizeof (struct blame_line_tracker ));guess_line_blames (parent, target, tlno, offset, same, parent_len, line_blames); }
contrib/coccinelle/xcalloc.cocci new file +10 -0
@@ -0,0 +1,10 @@ +@@ +type T; +T *ptr; +expression n; +@@ + xcalloc( ++ n, + \( sizeof(T) \| sizeof(*ptr) \) +- , n + )
range-diff.c +1 -1
@@ -96,7 +96,7 @@ static int read_patches(const char *range, struct string_list *list,string_list_append (list, buf.buf)->util = util;strbuf_reset (&buf); } - util =xcalloc (sizeof (*util),1 ); + util =xcalloc (1 ,sizeof (*util));if (get_oid (p, &util->oid)) {error (_ ("could not parse commit '%s'" ), p);free (util);
ref-filter.c +3 -2
@@ -772,7 +772,8 @@ static int if_atom_handler(struct atom_value *atomv, struct ref_formatting_state struct strbuf *unused_err) {struct ref_formatting_stack *new_stack; -struct if_then_else *if_then_else =xcalloc (sizeof (struct if_then_else ),1 ); +struct if_then_else *if_then_else =xcalloc (1 , +sizeof (struct if_then_else )); if_then_else->str = atomv->atom->u.if_then_else.str; if_then_else->cmp_status = atomv->atom->u.if_then_else.cmp_status;
@@ -2185,7 +2186,7 @@ static void reach_filter(struct ref_array *array,if (!check_reachable)return ; - to_clear =xcalloc (sizeof (struct commit *), array->nr); + to_clear =xcalloc (array->nr,sizeof (struct commit *));repo_init_revisions (the_repository, &revs,NULL );
trailer.c +4 -4
@@ -174,7 +174,7 @@ static void print_all(FILE *outfile, struct list_head *head,static struct trailer_item *trailer_from_arg (struct arg_item *arg_tok) { -struct trailer_item *new_item =xcalloc (sizeof (*new_item),1 ); +struct trailer_item *new_item =xcalloc (1 ,sizeof (*new_item)); new_item->token = arg_tok->token; new_item->value = arg_tok->value; arg_tok->token = arg_tok->value =NULL ;
@@ -445,7 +445,7 @@ static struct arg_item *get_conf_item(const char *name) }/* Item does not already exists, create it */ - item =xcalloc (sizeof (*item),1 ); + item =xcalloc (1 ,sizeof (*item));duplicate_conf (&item->conf, &default_conf_info); item->conf.name =xstrdup (name);
@@ -664,7 +664,7 @@ static void parse_trailer(struct strbuf *tok, struct strbuf *val,static struct trailer_item *add_trailer_item (struct list_head *head,char *tok,char *val) { -struct trailer_item *new_item =xcalloc (sizeof (*new_item),1 ); +struct trailer_item *new_item =xcalloc (1 ,sizeof (*new_item)); new_item->token = tok; new_item->value = val;list_add_tail (&new_item->list, head);
@@ -675,7 +675,7 @@ static void add_arg_item(struct list_head *arg_head, char *tok, char *val,const struct conf_info *conf, const struct new_trailer_item *new_trailer_item) { - struct arg_item *new_item = xcalloc(sizeof(*new_item), 1); + struct arg_item *new_item = xcalloc(1, sizeof(*new_item)); new_item->token = tok; new_item->value = val;duplicate_conf (&new_item->conf, conf);
--
2.30.1
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Am 06.03.21 um 12:26 schrieb René Scharfe.:
Quoted 8 lines
Subject: [PATCH] fix
xcalloc()argument orderPass the number of elements first and ther size second, as expected by
xcalloc(). Provide a semantic patch, which was actually used to generate the rest of this patch.The semantic patch would generate flip-flop diffs if both arguments are equivalent sizeofs.
^^^^^^^^^^
Actually the sizeofs don't have to be equivalent for the flip-flop to occur, so that word should be removed.
Quoted 21 lines
We don't have such a case, and it's hard to imagine
the usefulness of such an allocation. If it ever occurs then we could deal with it by duplicating the rule in the semantic patch to make it cancel itself out, or we could change the code to useCALLOC_ARRAY.contrib/coccinelle/xcalloc.cocci new file +10
-0@@ -0,0 +1,10 @@ +@@ +type T; +T *ptr; +expression n; +@@ + xcalloc( ++ n, + \( sizeof(T) \| sizeof(*ptr) \) +- , n + )
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Am 07.03.21 um 21:09 schrieb Junio C Hamano:
Quoted 6 lines
Quoted 1 line · René Scharfe.
Anyway, what about this more targeted approach:
It is a targetted approach to solve a different problem from the original one. I like the solution and the resulting code, but I also like the solution to the original problem, too ;-)
We can have both. :) The semantic patch for correcting the argument order of xcalloc calls allows the one for using CALLOC_ARRAY to be simplified, as it doesn't have to do that normalization itself.
I can't bring myself to introduce special macros for allocating a single object. Let's first make use what we already have.
René
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
In reply to René Scharfe.Quoted 69 lines · René Scharfe.
Am 05.03.21 um 18:07 schrieb Ævar Arnfjörð Bjarmason:
Quoted 10 lines
Addresses feedback on v1:
- The removal of the "cat [email protected]" is gone.
- Split up into N changes.
- Explained why960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) broke things and produced duplicate hunks in 2/4: tl;dr: spatch does its own locking etc., xargs -n trips it up.
- Set number of batch processes to 8, as suggested by Jeff King.Quoted 8 lines
Ævar Arnfjörð Bjarmason (4):
Makefile/coccicheck: add comment heading for all SPATCH flags Makefile/coccicheck: speed up and fix bug with duplicate hunks Makefile/coccicheck: allow for setting xargs concurrency Makefile/coccicheck: setSPATCH_BATCH_SIZEto 8Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)This speeds up "make coccicheck" after "make clean" as advertized for me:
before: 572.64s user 33.08s system 622% cpu 1:37.30 total after: 195.40s user 9.97s system 629% cpu 32.612 totalHowever, it also misses several conversions that coccicheck generated without this series for the example added by the patch at the bottom. Here's the difference of diffstats (< before, > after):
$ diff <(diffstat b | sort) <(diffstat a | sort) | grep '^[<>]' | sort -k2 -k1Quoted 1 line
27 files changed, 55 insertions(+), 57 deletions(-)< 36 files changed, 70 insertions(+), 71 deletions(-) < attr.c | 2 +- > blame.c | 15 +++++++-------- < blame.c | 17 ++++++++--------- < bloom.c | 2 +- < cache-tree.c | 2 +- > combine-diff.c | 18 +++++++++--------- < combine-diff.c | 20 ++++++++++---------- < decorate.c | 2 +- < diffcore-rename.c | 2 +- > diffcore-rename.c | 3 +-- < ewah/bitmap.c | 2 +- < hashmap.c | 2 +- > midx.c | 4 ++-- < midx.c | 8 ++++---- < pack-objects.c | 2 +- < pathspec.c | 2 +- > read-cache.c | 2 +- < read-cache.c | 4 ++-- > ref-filter.c | 2 +- < ref-filter.c | 4 ++-- < remote.c | 2 +-That's with the current spatch version 1.1.0-00072-g3dc5d027.
contrib/coccinelle/array.cocci +3
-0@@ -88,3 +88,16 @@ expression n; @@ - ptr = xmalloc((n) * sizeof(T)); + ALLOC_ARRAY(ptr, n); + +@@ +type T;
contrib/coccinelle/array.cocci expression n; · line 103
Quoted 10 lines
contrib/coccinelle/array.cocci +10
-0+T *ptr; +expression n != 1; +@@ +( +- ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \)); ++ CALLOC_ARRAY(ptr, n); +| +- ptr = xcalloc(\( sizeof(*ptr) \| sizeof(T) \), n); ++ CALLOC_ARRAY(ptr, n); +)
Well spotted, the issue is that you're using a "type" in the rule, or well, rather that I don't know much about *.cocci and didn't think to test that.
So because of s/--all-includes/--no-includes/ we don't include any includes, and thus don't know about the type, and thus can't match on this.
So obviously a bad bug, and I'll need to re-roll this, but any fix I've been able to come up with (playing with other cocci options) takes away most of the speed gains.
Well, there's the option of e.g. injecting options if "grep -q ^type <cocci-file>" is true, which would work for the current input.
Do these sorts of rules really benefit that much from the type v.s. expression? If yes we'll obviously need to support it, but if (and I haven't looked closely) we can equally rewrite them with "expression" (or it would be good enough) we could be quite a bit faster by default...
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Am 06.03.21 um 18:27 schrieb Ævar Arnfjörð Bjarmason:
Quoted 5 lines
Do these sorts of rules really benefit that much from the type v.s. expression? If yes we'll obviously need to support it, but if (and I haven't looked closely) we can equally rewrite them with "expression" (or it would be good enough) we could be quite a bit faster by default...
Type information is essential for many (most?) semantic patches. Untyped replacements could be done more easily using sed or similar.
René
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Quoted 9 lines · René Scharfe.
Am 06.03.21 um 18:27 schrieb Ævar Arnfjörð Bjarmason:
Quoted 5 lines
Do these sorts of rules really benefit that much from the type v.s. expression? If yes we'll obviously need to support it, but if (and I haven't looked closely) we can equally rewrite them with "expression" (or it would be good enough) we could be quite a bit faster by default...
Type information is essential for many (most?) semantic patches. Untyped replacements could be done more easily using sed or similar.
We have 65 individual hunks in *.cocci by my count $((/ (cat *.cocci | grep -c ^@@) 2)), but only 9 of those use the "type T" construct, which AFAICT is the only thing affected.
There's still plenty of reason to use spatch without headers being included, it's still doing a full parse and knows that something's a function, and otherwise cares about C syntax etc.
Anyway, I'm not saying you don't need it, just that AFAICT it's a small minority of the rules that require the includes.
Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up
Am 06.03.21 um 18:52 schrieb Ævar Arnfjörð Bjarmason:
Quoted 10 lines · René Scharfe.
Quoted 8 lines
Am 06.03.21 um 18:27 schrieb Ævar Arnfjörð Bjarmason:
Quoted 5 lines
Do these sorts of rules really benefit that much from the type v.s. expression? If yes we'll obviously need to support it, but if (and I haven't looked closely) we can equally rewrite them with "expression" (or it would be good enough) we could be quite a bit faster by default...
Quoted 6 lines
Quoted 2 lines
Type information is essential for many (most?) semantic patches. Untyped replacements could be done more easily using sed or similar.
We have 65 individual hunks in *.cocci by my count $((/ (cat *.cocci | grep -c ^@@) 2)), but only 9 of those use the "type T" construct, which AFAICT is the only thing affected.
I don't understand why using type variables would be the only feature that needs headers. Accessing struct members like in commit.cocci surely needs their definition, no?
Quoted 6 lines
There's still plenty of reason to use spatch without headers being included, it's still doing a full parse and knows that something's a function, and otherwise cares about C syntax etc.
Anyway, I'm not saying you don't need it, just that AFAICT it's a small minority of the rules that require the includes.
https://coccinelle.gitlabpages.inria.fr/website/docs/options.pdf says "If the semantic patch contains type specifications on expression metavariables, then the default is --local-includes. Otherwise the
default is --no-includes." So spatch by default already avoids loading
includes unless needed, but we override that.
René
PATCH v2 1/4 Makefile/coccicheck: add comment heading for all SPATCH flags
In reply to Ævar Arnfjörð BjarmasonIn 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) the comment being re-added here was amended and reworded to apply to the SPATCH_BATCH_SIZE variable.
If we'd like a separate comment on SPATCH_FLAGS now the diff to introduce it will need to also move the comment. So add this heading back to make subsequent diffs smaller.
--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
@@ -1195,10 +1195,11 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer +# For the 'coccicheck' target +SPATCH_FLAGS = --all-includes --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_FLAGS = --all-includes --patch . SPATCH_BATCH_SIZE = 1 include config.mak.uname
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
PATCH v2 2/4 Makefile/coccicheck: speed up and fix bug with duplicate hunks
In reply to Ævar Arnfjörð BjarmasonChange the coccicheck target to run on all of our *.c and *.h files with --no-includes, instead of only on the *.c files with --all-includes.
This speeds it up significantly and reduces its memory usage, since it doesn't need to parse N includes for every file it visits.
See [1] for a discussion thread about this commit with some timings for details, but briefly: This change speeds it up by ~2x and makes it use much less memory. Or a reduction of a max of around ~2GB per-process (under the old SPATCH_BATCH_SIZE=0) to around ~200MB.
Looking at the history of the coccicheck target I think we've always been running it in the wrong mode for what we wanted to achieve:
- When it was added in 63f0a758a06 (add coccicheck make target, 2016-09-15) it explicitly processed only the %.c files.
- Then in a9a884aea57 (coccicheck: use --all-includes by default, 2016-09-30) it started processing the %.h files by looking around for its own includes.
Let's instead just point it to both our *.c and *.h files, then there's no need to have it recursively look around for included files to change.
Setting --no-includes would not work if we expected to set COCCI_SOURCES to a subset of our source files, but that's not what we're doing here. If anyone manually tweaks COCCI_SOURCES they'll now need to tweak SPATCH_FLAGS too. The speed and correctness we gain is worth that small trade-off.
Using --no-includes also fixes a subtle bug introduced in 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) with duplicate hunks being written to the generated *.patch files.
This is because that change altered a file-at-a-time for-loop to an invocation of "xargs -n X". This would not matter for most other programs, but it matters for spatch.
This is because each spatch invocation will maintain shared lock files in /tmp, check if files being parsed were changed etc. I haven't dug into why exactly, but it's easy to reproduce the issue[2]. The issue goes away entirely if we just use --no-includes, which as noted above would have made sense even without that issue.
1. https://lore.kernel.org/git/[email protected]/
2. A session showing racy spatch under xargs -n X:
$ cat test.cocci
@@
expression E1;
@@
- strbuf_avail(E1)
+ strbuf_has(E1)
$ for i in 1 2 4 16 64 128 512
do
echo with xargs -n $i: &&
echo *.c | xargs -n $i spatch --sp-file \
test.cocci --all-includes --patch . 2>/dev/null | \
grep -F +++ | sort | uniq -c
done
with xargs -n 1:
1 +++ b/convert.c
1 +++ b/strbuf.c
with xargs -n 2:
1 +++ b/convert.c
1 +++ b/strbuf.c
with xargs -n 4:
1 +++ b/convert.c
1 +++ b/strbuf.c
with xargs -n 16:
1 +++ b/convert.c
1 +++ b/strbuf.c
2 +++ b/strbuf.h
with xargs -n 64:
1 +++ b/convert.c
1 +++ b/strbuf.c
2 +++ b/strbuf.h
with xargs -n 128:
1 +++ b/convert.c
1 +++ b/strbuf.c
2 +++ b/strbuf.h
with xargs -n 512:
1 +++ b/convert.c
1 +++ b/strbuf.c
1 +++ b/strbuf.h--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -1196,7 +1196,8 @@ SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target -SPATCH_FLAGS = --all-includes --patch . +SPATCH_FLAGS = --no-includes --patch . + # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation.
@@ -2853,7 +2854,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES)
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
Re: [PATCH v2 2/4] Makefile/coccicheck: speed up and fix bug with duplicate hunks
Quoted 9 lines · Ævar Arnfjörð Bjarmason
Using --no-includes also fixes a subtle bug introduced in
960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) with duplicate hunks being written to the generated *.patch files.This is because that change altered a file-at-a-time for-loop to an invocation of "xargs -n X". This would not matter for most other programs, but it matters for spatch.
Quoted 5 lines
This is because each spatch invocation will maintain shared lock files in /tmp, check if files being parsed were changed etc. I haven't dug into why exactly, but it's easy to reproduce the issue[2]. The issue goes away entirely if we just use --no-includes, which as noted above would have made sense even without that issue.
This part still doesn't make any sense to me. If we are running with SPATCH_BATCH_SIZE=1, which is the default, then "xargs -n" is still going to run it in file-at-a-time mode. From spatch's perspective, there's no difference between a for-loop and "xargs -n 1" (unless it somehow cares about stdin, but it shouldn't).
Using strace, I do see it creating files in /tmp, but they are all named after the process id, and cleaned up before exit. So I don't see how they could interfere with each other (certainly not in a sequential run, but even if you were to use "xargs -P" to get parallel runs, they seem distinct).
If we increase the batch size, I'd expect _fewer_ duplicates. Because in file-at-a-time mode with --all-includes, wouldn't every file that mentions an include possibly end up emitting a patch for it?
The results you show here (which do replicate for me) imply something much weirder is going on:
Quoted 9 lines
with xargs -n 1:
1 +++ b/convert.c
1 +++ b/strbuf.c
with xargs -n 2:
1 +++ b/convert.c
1 +++ b/strbuf.c
with xargs -n 4:
1 +++ b/convert.c
1 +++ b/strbuf.cThese results are wrong! They are not finding the entry in strbuf.h that should be changed.
Quoted 4 lines
with xargs -n 16:
1 +++ b/convert.c
1 +++ b/strbuf.c
2 +++ b/strbuf.hQuoted 8 lines
with xargs -n 64:
1 +++ b/convert.c
1 +++ b/strbuf.c
2 +++ b/strbuf.h
with xargs -n 128:
1 +++ b/convert.c
1 +++ b/strbuf.c
2 +++ b/strbuf.hThese ones are also wrong. Now we find the strbuf.h mention, but we are finding it twice.
Quoted 4 lines
with xargs -n 512:
1 +++ b/convert.c
1 +++ b/strbuf.c
1 +++ b/strbuf.hAnd this one, which is given all of the paths in one invocation gets it right. I'd expect that over the "128" version, which is running two independent spatch invocations. But the fact that "64" and "16" produce exactly two duplicates makes little sense. And even less that 1, 2, and 4 don't find the header change at all.
Running the same test with a for loop produces the same (wrong) results as "-n 1", as expected:
$ for i in *.c; do
spatch --sp-file test.cocci --all-includes --patch . $i 2>/dev/null
done | grep -F +++ | sort | uniq -c
1 +++ b/convert.c
1 +++ b/strbuf.cSo in short I have no idea what spatch is doing. But I remain unconvinced that there is anything wrong with the batch-size patch.
Running it like your patch will, feeding the header directly along with --no-includes, does find the correct result:
$ for i in *.c *.h; do
spatch --sp-file test.cocci --no-includes --patch . $i 2>/dev/null
done | grep -F +++ | sort | uniq -c
1 +++ b/convert.c
1 +++ b/strbuf.c
1 +++ b/strbuf.hthough I am still concerned by René's example which is missing more results.
-Peff
Re: [PATCH v2 2/4] Makefile/coccicheck: speed up and fix bug with duplicate hunks
Quoted 70 lines · Jeff King
Quoted 9 lines · Ævar Arnfjörð Bjarmason
Using --no-includes also fixes a subtle bug introduced in
960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) with duplicate hunks being written to the generated *.patch files.This is because that change altered a file-at-a-time for-loop to an invocation of "xargs -n X". This would not matter for most other programs, but it matters for spatch.
Quoted 5 lines
This is because each spatch invocation will maintain shared lock files in /tmp, check if files being parsed were changed etc. I haven't dug into why exactly, but it's easy to reproduce the issue[2]. The issue goes away entirely if we just use --no-includes, which as noted above would have made sense even without that issue.
This part still doesn't make any sense to me. If we are running with SPATCH_BATCH_SIZE=1, which is the default, then "xargs -n" is still going to run it in file-at-a-time mode. From spatch's perspective, there's no difference between a for-loop and "xargs -n 1" (unless it somehow cares about stdin, but it shouldn't).
Using strace, I do see it creating files in /tmp, but they are all named after the process id, and cleaned up before exit. So I don't see how they could interfere with each other (certainly not in a sequential run, but even if you were to use "xargs -P" to get parallel runs, they seem distinct).
If we increase the batch size, I'd expect _fewer_ duplicates. Because in file-at-a-time mode with --all-includes, wouldn't every file that mentions an include possibly end up emitting a patch for it?
The results you show here (which do replicate for me) imply something much weirder is going on:
Quoted 9 lines
with xargs -n 1: 1 +++ b/convert.c 1 +++ b/strbuf.c with xargs -n 2: 1 +++ b/convert.c 1 +++ b/strbuf.c with xargs -n 4: 1 +++ b/convert.c 1 +++ b/strbuf.cThese results are wrong! They are not finding the entry in
strbuf.hthat should be changed.Quoted 4 lines
with xargs -n 16: 1 +++ b/convert.c 1 +++ b/strbuf.c 2 +++ b/strbuf.hQuoted 8 lines
with xargs -n 64: 1 +++ b/convert.c 1 +++ b/strbuf.c 2 +++ b/strbuf.h with xargs -n 128: 1 +++ b/convert.c 1 +++ b/strbuf.c 2 +++ b/strbuf.hThese ones are also wrong. Now we find the
strbuf.hmention, but we are finding it twice.Quoted 4 lines
with xargs -n 512: 1 +++ b/convert.c 1 +++ b/strbuf.c 1 +++ b/strbuf.h
Quoted 5 lines
And this one, which is given all of the paths in one invocation gets it right. I'd expect that over the "128" version, which is running two independent spatch invocations. But the fact that "64" and "16" produce exactly two duplicates makes little sense. And even less that 1, 2, and 4 don't find the header change at all.
Yes, I don't know what's going on with spatch. Just the observed results of duplication before/after youc commit.
Quoted 11 lines
Running the same test with a for loop produces the same (wrong) results as "-n 1", as expected:
$ for i in *.c; do spatch --sp-file test.cocci --all-includes --patch . $i 2>/dev/null done | grep -F +++ | sort | uniq -c 1 +++ b/convert.c 1 +++ b/strbuf.cSo in short I have no idea what spatch is doing. But I remain unconvinced that there is anything wrong with the batch-size patch.
Right, but that's an unrelated "didn't change this thing it should have" bug (which we had before), not the duplicate hunk bug.
Quoted 10 lines
Running it like your patch will, feeding the header directly along with --no-includes, does find the correct result:
$ for i in *.c *.h; do spatch --sp-file test.cocci --no-includes --patch . $i 2>/dev/null done | grep -F +++ | sort | uniq -c 1 +++ b/convert.c 1 +++ b/strbuf.c 1 +++ b/strbuf.h
Quoted 2 lines
though I am still concerned by René's example which is missing more results.
*nod*. I just sent a patch on top to fix that, although it undoes most
of the speedup in this series.
PATCH v2 3/4 Makefile/coccicheck: allow for setting xargs concurrency
In reply to Ævar Arnfjörð BjarmasonExtend the SPATCH_BATCH_SIZE facility added in 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) and bcb4edf7af7 (coccicheck: make batch size of 0 mean "unlimited", 2019-05-08) to allow for both setting SPATCH_BATCH_SIZE=N, and also to have a more advanced SPATCH_XARGS argument.
The reason to replace the "$$limit" is that now you actually see under V=1 what argument your program will get invoked with.
The reason for the "9999" limit is that if you e.g. try to define an "$(XARGS)" which is conditionally an empty string or not depending on this setting then e.g.:
echo $(FILES) | $(XARGS) $(XARGS_FLAGS) $(SPATCH)
Over multiple lines with "\" will error out. I think just setting it to "xargs -n 9999" as a trivial workaround is the best solution here.
--- Makefile | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
Makefile +20 -6
@@ -1203,6 +1203,25 @@ SPATCH_FLAGS = --no-includes --patch . # Setting it to 0 will feed all files in a single spatch invocation. SPATCH_BATCH_SIZE = 1 +# For the 'coccicheck' target; SPATCH_XARGS can be used to manually +# tweak the xargs invocation. By default we invoke "xargs -n 1", and +# "xargs -n 9999" under SPATCH_BATCH_SIZE=0. +# +# Setting SPATCH_XARGS overrides SPATCH_BATCH_SIZE. To get concurrency +# when targeting a single contrib/coccinelle/%.patch use e.g. "-P" if +# your xargs(1) supports it: +# +# make contrib/coccinelle/strbuf.cocci.patch SPATCH_XARGS="xargs -P 8 -n 8" +# +# Or a combination -jN and "xargs -P": +# +# make -j4 coccicheck SPATCH_XARGS="xargs -P 2 -n 8" +ifeq (0,$(SPATCH_BATCH_SIZE)) +SPATCH_XARGS = xargs -n 9999 +else +SPATCH_XARGS = xargs -n $(SPATCH_BATCH_SIZE) +endif + include config.mak.uname -include config.mak.autogen -include config.mak
@@ -2859,12 +2878,7 @@ COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES) $(QUIET_SPATCH) \ - if test $(SPATCH_BATCH_SIZE) = 0; then \ - limit=; \ - else \ - limit='-n $(SPATCH_BATCH_SIZE)'; \ - fi; \ - if ! echo $(COCCI_SOURCES) | xargs $$limit \ + if ! echo $(COCCI_SOURCES) | $(SPATCH_XARGS) \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
Re: [PATCH v2 3/4] Makefile/coccicheck: allow for setting xargs concurrency
Makefile SPATCH_FLAGS = --no-includes --patch . · line 1218
Quoted 9 lines · Ævar Arnfjörð Bjarmason
Makefile +9
-0+# Setting SPATCH_XARGS overrides SPATCH_BATCH_SIZE. To get concurrency +# when targeting a single contrib/coccinelle/%.patch use e.g. "-P" if +# your xargs(1) supports it: +# +# make contrib/coccinelle/strbuf.cocci.patch SPATCH_XARGS="xargs -P 8 -n 8" +# +# Or a combination -jN and "xargs -P": +# +# make -j4 coccicheck SPATCH_XARGS="xargs -P 2 -n 8"
I don't think this is actually safe to do. At least not if you care about the output patch. All of the parallel processes will go to the same output file:
Makefile COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) · line 2884
Quoted 10 lines
Makefile +1
-6- if test $(SPATCH_BATCH_SIZE) = 0; then \ - limit=; \ - else \ - limit='-n $(SPATCH_BATCH_SIZE)'; \ - fi; \ - if ! echo $(COCCI_SOURCES) | xargs $$limit \ + if ! echo $(COCCI_SOURCES) | $(SPATCH_XARGS) \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \
which means they run the risk of getting jumbled racily. It might work OK in practice if the patches are smaller than spatch puts into a single write() call, and what the OS will treat as an atomic file-write (which is really under-specified in POSIX for regular files).
-Peff
PATCH v2 4/4 Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
In reply to Ævar Arnfjörð BjarmasonChange the "xargs -n X" limit for running spatch from 1 to 8, as suggested by Jeff King[1]. Now that we're not using --all-includes anymore this is going to take much less memory, so bumping the limit should be OK.
1. https://lore.kernel.org/git/[email protected]/
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -1201,7 +1201,7 @@ SPATCH_FLAGS = --no-includes --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_BATCH_SIZE = 1 +SPATCH_BATCH_SIZE = 8 # For the 'coccicheck' target; SPATCH_XARGS can be used to manually # tweak the xargs invocation. By default we invoke "xargs -n 1", and
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
[PATCH v2 5/4] Makefile/coccicheck: use --include-headers-for-types
Change the recently added --no-includes out for --all-includes --include-headers-for-types.
When I moved from --all-includes to --no-includes I missed that rules that use "type T" such as the one added dbc540c7a58 (add QSORT, 2016-09-29) won't work as intended. See [1] for a report of that.
So let's move back to --all-includes to potentially scour our includes for definitions, but supply --include-headers-for-types so we won't racily emit duplicate hunks. See [2] for more discussion about that issue.
This undoes most of the optimization we gained with --no-includes, using a very basic benchmark script [3] I get these results:
* ~1m50s: --all-includes (before my recent patches)
38 files changed, 74 insertions(+), 78 deletions(-) * ~55s: --no-includes 27 files changed, 55 insertions(+), 57 deletions(-) * ~1m35s: --all-includes --include-headers-for-types 38 files changed, 74 insertions(+), 78 deletions(-) * ~1m20s: --local-includes --include-headers-for-types 36 files changed, 70 insertions(+), 72 deletions(-) * ~1m20s: --local-includes --include-headers-for-types --no-loops 36 files changed, 70 insertions(+), 72 deletions(-)
And only the "--all-includes --include-headers-for-types" gets the same results as the previous "--all-includes", even with "--local-includes" we miss out on some definitions.
1. https://lore.kernel.org/git/[email protected]/
2. https://lore.kernel.org/git/[email protected]/
3.
for flags in \
'--all-includes' \
'--no-includes' \
'--all-includes --include-headers-for-types' \
'--local-includes --include-headers-for-types' \
'--local-includes --include-headers-for-types --no-loops' do
git reset --hard &&
git clean -dxfq contrib/
time make -j8 coccicheck SPATCH_FLAGS="$flags --patch ." SPATCH_XARGS="xargs -P 8 -n 16" 2>&1 | grep -v SPATCH cat contrib/coccinelle/*.patch | git apply
git --no-pager diff --shortstat
git --no-pager diff | git patch-id
done
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -1199,7 +1199,7 @@ SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target -SPATCH_FLAGS = --no-includes --patch . +SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory.
Signature · 1 line
2.31.0.rc0.126.g04f22c5b82
Re: [PATCH v2 5/4] Makefile/coccicheck: use --include-headers-for-types
Quoted 16 lines · Ævar Arnfjörð Bjarmason
Change the recently added --no-includes out for --all-includes --include-headers-for-types.
When I moved from --all-includes to --no-includes I missed that rules that use "type T" such as the one added
dbc540c7a58(add QSORT, 2016-09-29) won't work as intended. See [1] for a report of that.So let's move back to --all-includes to potentially scour our includes for definitions, but supply --include-headers-for-types so we won't racily emit duplicate hunks. See [2] for more discussion about that issue.
This undoes most of the optimization we gained with --no-includes, using a very basic benchmark script [3] I get these results:
* ~1m50s: --all-includes (before my recent patches)
Quoted 9 lines
38 files changed, 74 insertions(+), 78 deletions(-) * ~55s: --no-includes 27 files changed, 55 insertions(+), 57 deletions(-) * ~1m35s: --all-includes --include-headers-for-types 38 files changed, 74 insertions(+), 78 deletions(-) * ~1m20s: --local-includes --include-headers-for-types 36 files changed, 70 insertions(+), 72 deletions(-) * ~1m20s: --local-includes --include-headers-for-types --no-loops 36 files changed, 70 insertions(+), 72 deletions(-)
Where do these changes come from? I can't reproduce it running your script below, and get empty contrib/coccinelle/*.patch files for each sets of options.
Quoted 21 lines
And only the "--all-includes --include-headers-for-types" gets the same results as the previous "--all-includes", even with "--local-includes" we miss out on some definitions.
1. https://lore.kernel.org/git/[email protected]/
2. https://lore.kernel.org/git/[email protected]/
3.for flags in \ '--all-includes' \ '--no-includes' \ '--all-includes --include-headers-for-types' \ '--local-includes --include-headers-for-types' \ '--local-includes --include-headers-for-types --no-loops'do
git reset --hard &&
git clean -dxfq contrib/
time make -j8 coccicheck SPATCH_FLAGS="$flags --patch ." SPATCH_XARGS="xargs -P 8 -n 16" 2>&1 | grep -v SPATCH cat contrib/coccinelle/*.patch | git apply
git --no-pager diff --shortstat
git --no-pager diff | git patch-id
done
Re: [PATCH v2 5/4] Makefile/coccicheck: use --include-headers-for-types
Quoted 27 lines · SZEDER Gábor
Quoted 16 lines · Ævar Arnfjörð Bjarmason
Change the recently added --no-includes out for --all-includes --include-headers-for-types.
When I moved from --all-includes to --no-includes I missed that rules that use "type T" such as the one added
dbc540c7a58(add QSORT, 2016-09-29) won't work as intended. See [1] for a report of that.So let's move back to --all-includes to potentially scour our includes for definitions, but supply --include-headers-for-types so we won't racily emit duplicate hunks. See [2] for more discussion about that issue.
This undoes most of the optimization we gained with --no-includes, using a very basic benchmark script [3] I get these results:
* ~1m50s: --all-includes (before my recent patches)
Quoted 9 lines
38 files changed, 74 insertions(+), 78 deletions(-) * ~55s: --no-includes 27 files changed, 55 insertions(+), 57 deletions(-) * ~1m35s: --all-includes --include-headers-for-types 38 files changed, 74 insertions(+), 78 deletions(-) * ~1m20s: --local-includes --include-headers-for-types 36 files changed, 70 insertions(+), 72 deletions(-) * ~1m20s: --local-includes --include-headers-for-types --no-loops 36 files changed, 70 insertions(+), 72 deletions(-)
Quoted 3 lines
Where do these changes come from? I can't reproduce it running your script below, and get empty contrib/coccinelle/*.patch files for each sets of options.
It's from René's patch in <[email protected]> patch in the side-thread.
I'll clarify that commit message in any re-roll, i.e. it should just be something like: Here's a test of a patch that applies widely to the tree, showing that using [options] it's the same or different as before, as expected.
Quoted 21 lines
Quoted 21 lines
And only the "--all-includes --include-headers-for-types" gets the same results as the previous "--all-includes", even with "--local-includes" we miss out on some definitions.
1. https://lore.kernel.org/git/[email protected]/
2. https://lore.kernel.org/git/[email protected]/
3.for flags in \ '--all-includes' \ '--no-includes' \ '--all-includes --include-headers-for-types' \ '--local-includes --include-headers-for-types' \ '--local-includes --include-headers-for-types --no-loops'do
git reset --hard &&
git clean -dxfq contrib/
time make -j8 coccicheck SPATCH_FLAGS="$flags --patch ." SPATCH_XARGS="xargs -P 8 -n 16" 2>&1 | grep -v SPATCH cat contrib/coccinelle/*.patch | git apply
git --no-pager diff --shortstat
git --no-pager diff | git patch-id
done
v4 cover Makefile/coccicheck: fix bugs and speed it up
In reply to Ævar Arnfjörð BjarmasonA v4 (I'm counting the 5/4 patch I sent to v2 as a v3) which produces the exact same end result as that v2 + 5/4 patch, but with a rewritten commit message/squash as requested by Junio.
Ævar Arnfjörð Bjarmason (4):
Makefile/coccicheck: add comment heading for all SPATCH flags Makefile/coccicheck: speed up and fix bug with duplicate hunks Makefile/coccicheck: allow for setting xargs concurrency Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
Range-diff:
1: d3a2df76b04 = 1: d8c6efd2464 Makefile/coccicheck: add comment heading for all SPATCH flags 2: 6b0901e0fc5 ! 2: 3bca3239cb8 Makefile/coccicheck: speed up and fix bug with duplicate hunks
@@ Commit message
Makefile/coccicheck: speed up and fix bug with duplicate hunks
Change the coccicheck target to run on all of our *.c and *.h files
- with --no-includes, instead of only on the *.c files with
- --all-includes.
-
- This speeds it up significantly and reduces its memory usage, since it
- doesn't need to parse N includes for every file it visits.
-
- See [1] for a discussion thread about this commit with some timings
- for details, but briefly: This change speeds it up by ~2x and makes it
- use much less memory. Or a reduction of a max of around ~2GB
- per-process (under the old SPATCH_BATCH_SIZE=0) to around ~200MB.
-
- Looking at the history of the coccicheck target I think we've always
- been running it in the wrong mode for what we wanted to achieve:
-
- - When it was added in 63f0a758a06 (add coccicheck make target,
- 2016-09-15) it explicitly processed only the %.c files.
-
- - Then in a9a884aea57 (coccicheck: use --all-includes by default,
- 2016-09-30) it started processing the %.h files by looking around for
- its own includes.
-
- Let's instead just point it to both our *.c and *.h files, then
- there's no need to have it recursively look around for included files
- to change.
-
- Setting --no-includes would not work if we expected to set
- COCCI_SOURCES to a subset of our source files, but that's not what
- we're doing here. If anyone manually tweaks COCCI_SOURCES they'll now
- need to tweak SPATCH_FLAGS too. The speed and correctness we gain is
- worth that small trade-off.
-
- Using --no-includes also fixes a subtle bug introduced in
- 960154b9c17 (coccicheck: optionally batch spatch invocations,
- 2019-05-06) with duplicate hunks being written to the
- generated *.patch files.
-
- This is because that change altered a file-at-a-time for-loop to an
- invocation of "xargs -n X". This would not matter for most other
- programs, but it matters for spatch.
-
- This is because each spatch invocation will maintain shared lock files
- in /tmp, check if files being parsed were changed etc. I haven't dug
- into why exactly, but it's easy to reproduce the issue[2]. The issue
- goes away entirely if we just use --no-includes, which as noted above
- would have made sense even without that issue.
-
- 1. https://lore.kernel.org/git/[email protected]/
- 2. A session showing racy spatch under xargs -n X:
-
- $ cat test.cocci
- @@
- expression E1;
- @@
- - strbuf_avail(E1)
- + strbuf_has(E1)
- $ for i in 1 2 4 16 64 128 512
- do
- echo with xargs -n $i: &&
- echo *.c | xargs -n $i spatch --sp-file \
- test.cocci --all-includes --patch . 2>/dev/null | \
- grep -F +++ | sort | uniq -c
- done
- with xargs -n 1:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- with xargs -n 2:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- with xargs -n 4:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- with xargs -n 16:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- 2 +++ b/strbuf.h
- with xargs -n 64:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- 2 +++ b/strbuf.h
- with xargs -n 128:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- 2 +++ b/strbuf.h
- with xargs -n 512:
- 1 +++ b/convert.c
- 1 +++ b/strbuf.c
- 1 +++ b/strbuf.h
+ with --include-headers-for-types, instead of trusting it to find *.h
+ files and other includes to modify from its recursive walking of
+ includes as it has been doing with only --all-includes.
+
+ The --all-includes option introduced in a9a884aea57 (coccicheck: use
+ --all-includes by default, 2016-09-30) is needed because we have rules
+ that e.g. use the "type T" construct that wouldn't match unless we
+ scoured our headers for the definition of the relevant type.
+
+ But combining --all-includes it with processing N files at a time with
+ xargs as we've done since 960154b9c17 (coccicheck: optionally batch
+ spatch invocations, 2019-05-06) introduced a subtle bug with duplicate
+ hunks being written to the generated *.patch files. I did not dig down
+ to the root cause of that, but I think it's due to spatch doing (and
+ failing to do) some magical locking/racy mtime checking to decide if
+ it emits a hunk. See [1] for a way to reproduce the issue, and a
+ discussion of it.
+
+ This change speeds up the runtime of "make -j8 coccicheck" from ~1m50s
+ to ~1m20s for me. See [2] for more timings.
+
+ We could also use --no-includes for a runtime of ~55s, but that would
+ produce broken patches (we miss some hunks) in cases where we need the
+ type or other definitions from included files.
+
+ If anyone cares there's probably an optimization opportunity here to
+ e.g. detect that the whole file doesn't need to consider includes,
+ since the rules would be unambiguous without considering them.
+
+ Note on portability: The --include-headers-for-types option is not in
+ my "man spatch", but it's been part of spatch since 2014. See its
+ fe3a327a (include headers for types option, 2014-07-27), it was first
+ released with version 1.0.0 of spatch, released in April 2015. The
+ spatch developers are just inconsistent about updating their TeX docs
+ and manpages at the same time.
+
+ 1. https://lore.kernel.org/git/[email protected]/
+ 2. https://lore.kernel.org/git/[email protected]/
@@ Makefile: SPARSE_FLAGS ?=
# For the 'coccicheck' target
-SPATCH_FLAGS = --all-includes --patch .
-+SPATCH_FLAGS = --no-includes --patch .
++SPATCH_FLAGS = --all-includes --include-headers-for-types --patch .
+
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory.
3: c913d5dbe9b ! 3: 9d5814dacdc Makefile/coccicheck: allow for setting xargs concurrency
@@ Commit message
## Makefile ##
-@@ Makefile: SPATCH_FLAGS = --no-includes --patch .
+@@ Makefile: SPATCH_FLAGS = --all-includes --include-headers-for-types --patch .
# Setting it to 0 will feed all files in a single spatch invocation. SPATCH_BATCH_SIZE = 1
4: 98225e65d30 ! 4: 51b782bb9b6 Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
@@ Commit message
## Makefile ##
-@@ Makefile: SPATCH_FLAGS = --no-includes --patch .
+@@ Makefile: SPATCH_FLAGS = --all-includes --include-headers-for-types --patch .
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation.
5: 60649abddbb < -: ----------- Makefile/coccicheck: use --include-headers-for-types
Signature · 1 line
2.31.0.285.gb40d23e604f
PATCH v4 1/4 Makefile/coccicheck: add comment heading for all SPATCH flags
In 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) the comment being re-added here was amended and reworded to apply to the SPATCH_BATCH_SIZE variable.
If we'd like a separate comment on SPATCH_FLAGS now the diff to introduce it will need to also move the comment. So add this heading back to make subsequent diffs smaller.
--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
@@ -1198,10 +1198,11 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer +# For the 'coccicheck' target +SPATCH_FLAGS = --all-includes --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_FLAGS = --all-includes --patch . SPATCH_BATCH_SIZE = 1 include config.mak.uname
Signature · 1 line
2.31.0.285.gb40d23e604f
Re: [PATCH v4 1/4] Makefile/coccicheck: add comment heading for all SPATCH flags
Am 22.03.21 um 13:11 schrieb Ævar Arnfjörð Bjarmason:
Quoted 6 lines
In
960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) the comment being re-added here was amended and reworded to apply to theSPATCH_BATCH_SIZEvariable.If we'd like a separate comment on
SPATCH_FLAGSnow the diff to introduce it will need to also move the comment.
None of the patches in this series do actually add a separate comment. So SPATCH_FLAGS could stay where it is, no?
Quoted 26 lines
So add this heading
back to make subsequent diffs smaller.Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Makefile +2
-1@@ -1198,10 +1198,11 @@ PTHREAD_CFLAGS = SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer +# For the 'coccicheck' target +SPATCH_FLAGS = --all-includes --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_FLAGS = --all-includes --patch . SPATCH_BATCH_SIZE = 1 include config.mak.uname
PATCH v4 2/4 Makefile/coccicheck: speed up and fix bug with duplicate hunks
In reply to Ævar Arnfjörð BjarmasonChange the coccicheck target to run on all of our *.c and *.h files with --include-headers-for-types, instead of trusting it to find *.h files and other includes to modify from its recursive walking of includes as it has been doing with only --all-includes.
The --all-includes option introduced in a9a884aea57 (coccicheck: use --all-includes by default, 2016-09-30) is needed because we have rules that e.g. use the "type T" construct that wouldn't match unless we scoured our headers for the definition of the relevant type.
But combining --all-includes it with processing N files at a time with xargs as we've done since 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) introduced a subtle bug with duplicate hunks being written to the generated *.patch files. I did not dig down to the root cause of that, but I think it's due to spatch doing (and failing to do) some magical locking/racy mtime checking to decide if it emits a hunk. See [1] for a way to reproduce the issue, and a discussion of it.
This change speeds up the runtime of "make -j8 coccicheck" from ~1m50s to ~1m20s for me. See [2] for more timings.
We could also use --no-includes for a runtime of ~55s, but that would produce broken patches (we miss some hunks) in cases where we need the type or other definitions from included files.
If anyone cares there's probably an optimization opportunity here to e.g. detect that the whole file doesn't need to consider includes, since the rules would be unambiguous without considering them.
Note on portability: The --include-headers-for-types option is not in my "man spatch", but it's been part of spatch since 2014. See its fe3a327a (include headers for types option, 2014-07-27), it was first released with version 1.0.0 of spatch, released in April 2015. The spatch developers are just inconsistent about updating their TeX docs and manpages at the same time.
1. https://lore.kernel.org/git/[email protected]/
2. https://lore.kernel.org/git/[email protected]/
--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -1199,7 +1199,8 @@ SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target -SPATCH_FLAGS = --all-includes --patch . +SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . + # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation.
@@ -2860,7 +2861,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES)
Signature · 1 line
2.31.0.285.gb40d23e604f
Re: [PATCH v4 2/4] Makefile/coccicheck: speed up and fix bug with duplicate hunks
Am 22.03.21 um 13:11 schrieb Ævar Arnfjörð Bjarmason:
Quoted 19 lines
Change the coccicheck target to run on all of our *.c and *.h files with --include-headers-for-types, instead of trusting it to find *.h files and other includes to modify from its recursive walking of includes as it has been doing with only --all-includes.
The --all-includes option introduced in
a9a884aea57(coccicheck: use --all-includes by default, 2016-09-30) is needed because we have rules that e.g. use the "type T" construct that wouldn't match unless we scoured our headers for the definition of the relevant type.But combining --all-includes it with processing N files at a time with xargs as we've done since
960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) introduced a subtle bug with duplicate hunks being written to the generated *.patch files. I did not dig down to the root cause of that, but I think it's due to spatch doing (and failing to do) some magical locking/racy mtime checking to decide if it emits a hunk. See [1] for a way to reproduce the issue, and a discussion of it.
Quoted 2 lines
This change speeds up the runtime of "make -j8 coccicheck" from ~1m50s to ~1m20s for me. See [2] for more timings.
Without this patch, /usr/bin/time -l reports:
95.08 real 598.29 user 32.62 sys
103727104 maximum resident set size
With --include-headers-for-types, I get this:
76.37 real 483.83 user 26.77 sys
97107968 maximum resident set size
This is similar to your numbers. And adding that option to the demo script in your [1] gives consistent results for all xargs -n values, so that option alone fixes the subtle bug you refer to above, right?
However, with the second part of this patch also applied (adding %.h to FOUND_C_SOURCES), I get this:
90.38 real 558.38 user 38.32 sys
100073472 maximum resident set size
Is this still necessary?
Quoted 48 lines
We could also use --no-includes for a runtime of ~55s, but that would produce broken patches (we miss some hunks) in cases where we need the type or other definitions from included files.
If anyone cares there's probably an optimization opportunity here to e.g. detect that the whole file doesn't need to consider includes, since the rules would be unambiguous without considering them.
Note on portability: The --include-headers-for-types option is not in my "man spatch", but it's been part of spatch since 2014. See its
fe3a327a(include headers for types option, 2014-07-27), it was first released with version 1.0.0 of spatch, released in April 2015. The spatch developers are just inconsistent about updating their TeX docs and manpages at the same time.1. https://lore.kernel.org/git/[email protected]/
2. https://lore.kernel.org/git/[email protected]/Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Makefile +3
-2@@ -1199,7 +1199,8 @@ SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target -SPATCH_FLAGS = --all-includes --patch . +SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . + # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation.@@ -2860,7 +2861,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES)
Re: [PATCH v4 2/4] Makefile/coccicheck: speed up and fix bug with duplicate hunks
Quoted 17 lines · René Scharfe.
Quoted 2 lines
This change speeds up the runtime of "make -j8 coccicheck" from ~1m50s to ~1m20s for me. See [2] for more timings.
Without this patch,
/usr/bin/time-l reports:95.08 real 598.29 user 32.62 sys
103727104 maximum resident set sizeWith --include-headers-for-types, I get this:
76.37 real 483.83 user 26.77 sys
97107968 maximum resident set sizeThis is similar to your numbers. And adding that option to the demo script in your [1] gives consistent results for all xargs -n values, so that option alone fixes the subtle bug you refer to above, right?
Quoted 7 lines
However, with the second part of this patch also applied (adding %.h to
FOUND_C_SOURCES), I get this:90.38 real 558.38 user 38.32 sys
100073472 maximum resident set sizeIs this still necessary?
If I understand what the spatch options are doing (and I'm not at all sure that I do), then with --include-headers-for-types, aren't we avoiding looking for transformations in the included files?
In which case not adding *.h to the list of files we pass means that we'd fail to find instances in the header files that need to be mentioned in the output.
-Peff
Re: [PATCH v4 2/4] Makefile/coccicheck: speed up and fix bug with duplicate hunks
In reply to Ævar Arnfjörð BjarmasonQuoted 4 lines · Ævar Arnfjörð Bjarmason
Change the coccicheck target to run on all of our *.c and *.h files with --include-headers-for-types, instead of trusting it to find *.h files and other includes to modify from its recursive walking of includes as it has been doing with only --all-includes.
Meaning '--all-includes' that is fed a C source would use all the headers included (recursively) in it, but if we add the other option, --include-headers-for-types, some *.h files are missed?
If so, the above explains both hunks in the patch well (although it is unclear where that need to include *.h independently comes from, e.g. if it is working around a bug in spatch that we may expect for it to be fixed someday).
Quoted 23 lines
Makefile +3
-2@@ -1199,7 +1199,8 @@ SPARSE_FLAGS ?= SP_EXTRA_FLAGS = -Wno-universal-initializer # For the 'coccicheck' target -SPATCH_FLAGS = --all-includes --patch . +SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . + # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation.@@ -2860,7 +2861,7 @@ check: config-list.h command-list.h exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES))) +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))) COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES)
PATCH v4 3/4 Makefile/coccicheck: allow for setting xargs concurrency
In reply to Ævar Arnfjörð BjarmasonExtend the SPATCH_BATCH_SIZE facility added in 960154b9c17 (coccicheck: optionally batch spatch invocations, 2019-05-06) and bcb4edf7af7 (coccicheck: make batch size of 0 mean "unlimited", 2019-05-08) to allow for both setting SPATCH_BATCH_SIZE=N, and also to have a more advanced SPATCH_XARGS argument.
The reason to replace the "$$limit" is that now you actually see under V=1 what argument your program will get invoked with.
The reason for the "9999" limit is that if you e.g. try to define an "$(XARGS)" which is conditionally an empty string or not depending on this setting then e.g.:
echo $(FILES) | $(XARGS) $(XARGS_FLAGS) $(SPATCH)
Over multiple lines with "\" will error out. I think just setting it to "xargs -n 9999" as a trivial workaround is the best solution here.
--- Makefile | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
Makefile +20 -6
@@ -1206,6 +1206,25 @@ SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . # Setting it to 0 will feed all files in a single spatch invocation. SPATCH_BATCH_SIZE = 1 +# For the 'coccicheck' target; SPATCH_XARGS can be used to manually +# tweak the xargs invocation. By default we invoke "xargs -n 1", and +# "xargs -n 9999" under SPATCH_BATCH_SIZE=0. +# +# Setting SPATCH_XARGS overrides SPATCH_BATCH_SIZE. To get concurrency +# when targeting a single contrib/coccinelle/%.patch use e.g. "-P" if +# your xargs(1) supports it: +# +# make contrib/coccinelle/strbuf.cocci.patch SPATCH_XARGS="xargs -P 8 -n 8" +# +# Or a combination -jN and "xargs -P": +# +# make -j4 coccicheck SPATCH_XARGS="xargs -P 2 -n 8" +ifeq (0,$(SPATCH_BATCH_SIZE)) +SPATCH_XARGS = xargs -n 9999 +else +SPATCH_XARGS = xargs -n $(SPATCH_BATCH_SIZE) +endif + include config.mak.uname -include config.mak.autogen -include config.mak
@@ -2866,12 +2885,7 @@ COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) %.cocci.patch: %.cocci $(COCCI_SOURCES) $(QUIET_SPATCH) \ - if test $(SPATCH_BATCH_SIZE) = 0; then \ - limit=; \ - else \ - limit='-n $(SPATCH_BATCH_SIZE)'; \ - fi; \ - if ! echo $(COCCI_SOURCES) | xargs $$limit \ + if ! echo $(COCCI_SOURCES) | $(SPATCH_XARGS) \ $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \ >$@+ 2>[email protected]; \ then \
Signature · 1 line
2.31.0.285.gb40d23e604f
Re: [PATCH v4 3/4] Makefile/coccicheck: allow for setting xargs concurrency
Quoted 10 lines · Ævar Arnfjörð Bjarmason
Extend the
SPATCH_BATCH_SIZEfacility added in960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) andbcb4edf7af7(coccicheck: make batch size of 0 mean "unlimited", 2019-05-08) to allow for both setting SPATCH_BATCH_SIZE=N, and also to have a more advancedSPATCH_XARGSargument.The reason to replace the "$$limit" is that now you actually see under V=1 what argument your program will get invoked with.
Quoted 8 lines
The reason for the "9999" limit is that if you e.g. try to define an "$(XARGS)" which is conditionally an empty string or not depending on this setting then e.g.:
echo $(FILES) | $(XARGS) $(XARGS_FLAGS) $(SPATCH)Over multiple lines with "\" will error out. I think just setting it to "xargs -n 9999" as a trivial workaround is the best solution here.
I don't understand this 9999 comment. The original was sometimes setting $limit to the empty string, and then doing:
xargs $limit
How is that any different than setting SPATCH_XARGS to just "xargs" for the unlimited case?
Makefile SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . · line 1221
Quoted 13 lines
Makefile +13
-0+# For the 'coccicheck' target; SPATCH_XARGS can be used to manually +# tweak the xargs invocation. By default we invoke "xargs -n 1", and +# "xargs -n 9999" under SPATCH_BATCH_SIZE=0. +# +# Setting SPATCH_XARGS overrides SPATCH_BATCH_SIZE. To get concurrency +# when targeting a single contrib/coccinelle/%.patch use e.g. "-P" if +# your xargs(1) supports it: +# +# make contrib/coccinelle/strbuf.cocci.patch SPATCH_XARGS="xargs -P 8 -n 8" +# +# Or a combination -jN and "xargs -P": +# +# make -j4 coccicheck SPATCH_XARGS="xargs -P 2 -n 8"
As I mentioned in the last round, using "-P" is racy. I'm not sure if it's something we should be recommending to people.
-Peff
Re: [PATCH v4 3/4] Makefile/coccicheck: allow for setting xargs concurrency
Quoted 21 lines · Jeff King
Quoted 10 lines · Ævar Arnfjörð Bjarmason
Extend the
SPATCH_BATCH_SIZEfacility added in960154b9c17(coccicheck: optionally batch spatch invocations, 2019-05-06) andbcb4edf7af7(coccicheck: make batch size of 0 mean "unlimited", 2019-05-08) to allow for both setting SPATCH_BATCH_SIZE=N, and also to have a more advancedSPATCH_XARGSargument.The reason to replace the "$$limit" is that now you actually see under V=1 what argument your program will get invoked with.
Quoted 8 lines
The reason for the "9999" limit is that if you e.g. try to define an "$(XARGS)" which is conditionally an empty string or not depending on this setting then e.g.:
echo $(FILES) | $(XARGS) $(XARGS_FLAGS) $(SPATCH)Over multiple lines with "\" will error out. I think just setting it to "xargs -n 9999" as a trivial workaround is the best solution here.
Quoted 7 lines
I don't understand this 9999 comment. The original was sometimes setting $limit to the empty string, and then doing:
xargs $limit
How is that any different than setting
SPATCH_XARGSto just "xargs" for the unlimited case?
The "over multiple lines" is important. But it seems not anymore. I.e. in an earlier version I had:
$(XARGS) \
$(XARGS_FLAGS) \
$(SPATCH)And it would brek if XARGS_FLAGS was empty. So I set it to -n 9999 as a fallback.
Quoted 8 lines
Quoted 8 lines
Makefile +8
-0+# For the 'coccicheck' target; SPATCH_XARGS can be used to manually +# tweak the xargs invocation. By default we invoke "xargs -n 1", and +# "xargs -n 9999" under SPATCH_BATCH_SIZE=0. +# +# Setting SPATCH_XARGS overrides SPATCH_BATCH_SIZE. To get concurrency +# when targeting a single contrib/coccinelle/%.patch use e.g. "-P" if +# your xargs(1) supports it: +#
Quoted 8 lines
Makefile SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . · line 1221
Quoted 5 lines
Makefile +5
-0+# make contrib/coccinelle/strbuf.cocci.patch SPATCH_XARGS="xargs -P 8 -n 8" +# +# Or a combination -jN and "xargs -P": +# +# make -j4 coccicheck SPATCH_XARGS="xargs -P 2 -n 8"As I mentioned in the last round, using "-P" is racy. I'm not sure if it's something we should be recommending to people.
Yes, this would need to use N tempfiles we'd cat together at the end to be POSIX-reliable.
In practice I've never seen this sort of thing be unreliable for a case like this.
POSIX just guarantees that the output won't be interleaved up to PIPE_BUF, which is typically 4k. We certainly get patches bigger than that from spatch in some cases.
But from the OS's perspective emitting this output happens at a glacial pace. So even if it crosses that boundary it's unlikely to be interleaved.
Even:
perl -wE 'print "a" for 1..1024*1024*100' >1
perl -wE 'print "b" for 1..1024*1024*100' >2
perl -wE 'print "\n" for 1..1024*1024*100' >3
$ du -shc 1 2 3
100M 1
100M 2
100M 3
300M totalWhich at least on this computer I can't get to not print:
$ echo 1 2 3 | xargs -P 3 -n 1 cat|wc -l
104857600Suggesting that even for output of that size the \n's aren't mixed up. YMMV.
Anyway. I think I'll just redact this topic. Maybe I'll change my mind on it, or pick it up some other month/year/whatever.
I appreciate everyone's feedback on it, but for something I thought would be a rather trivial bugfix I've sunk way too much time into it. At this point I can't even remember why I was trying to run coccicheck in the first place.
There's e.g. still your outstanding feedback on what's really going on with that underlying spatch race I was trying to fix with this --include-headers-for-types workaround.
I think digging into that would be interesting for someone, but right now that's not me. I really don't want to spend time on digging into spatch's OCaml guts to figure that & any other outstanding stuff out.
Re: [PATCH v4 3/4] Makefile/coccicheck: allow for setting xargs concurrency
Quoted 11 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines
I don't understand this 9999 comment. The original was sometimes setting $limit to the empty string, and then doing:
xargs $limit
How is that any different than setting
SPATCH_XARGSto just "xargs" for the unlimited case?The "over multiple lines" is important. But it seems not anymore. I.e. in an earlier version I had:
Quoted 6 lines
$(XARGS) \ $(XARGS_FLAGS) \ $(SPATCH)And it would brek if
XARGS_FLAGSwas empty. So I set it to -n 9999 as a fallback.
Ah, OK, that makes more sense. Though I'm still slightly confused, just because I think the Makefile will eat those backslashed newlines, and the shell will just see extra whitespace. I.e.:
$ cat Makefile foo: echo \ $(A) \ $(B) \ $(C)
$ make foo A=one C=three echo \ one \ \ three one three
I suspect whatever you wrote that hit the problem was just slightly different. I doubt this is worth thinking about any further, but it is a weird curiosity to me. So feel free to explore and respond if you find it interesting, but don't feel compelled to. :)
Quoted 6 lines
Quoted 2 lines
As I mentioned in the last round, using "-P" is racy. I'm not sure if it's something we should be recommending to people.
Yes, this would need to use N tempfiles we'd cat together at the end to be POSIX-reliable.
Quoted 6 lines
In practice I've never seen this sort of thing be unreliable for a case like this.
POSIX just guarantees that the output won't be interleaved up to
PIPE_BUF, which is typically 4k. We certainly get patches bigger than that from spatch in some cases.
One nit (because I spent quite a long time looking into this a while ago for an unrelated thing): POSIX only talks about PIPE_BUF for pipes. For regular files in O_APPEND mode (or two processes sharing a descriptor from their parent, as we'd have here), I think write() is allowed to do a short write, at which point you'd lose atomicity.
In practice, I'd expect most small-ish (say, less than a page) writes to happen in a single go, especially on modern operating systems. But I wouldn't be too surprised if it depends on details of the filesystem, or even the file you're writing into. E.g., if there are 20 bytes left in a filesystem block that the end of the file is currently pointing to, and you ask to write 30 bytes, it seems plausible that we might write the first 20 to fill out the block, and then have a point where we could get interrupted by a signal and return early, etc.
Quoted 3 lines
But from the OS's perspective emitting this output happens at a glacial pace. So even if it crosses that boundary it's unlikely to be interleaved.
Yes, I think even if it's possible to race, the general lack of volume of writes is likely to save us.
Everything below is more curiosity, so again, don't sink time into it if it's not an interesting tangent for you.
Quoted 11 lines
Even:
perl -wE 'print "a" for 1..1024*1024*100' >1 perl -wE 'print "b" for 1..1024*1024*100' >2 perl -wE 'print "\n" for 1..1024*1024*100' >3 $ du -shc 1 2 3 100M 1 100M 2 100M 3 300M total
Quoted 7 lines
Which at least on this computer I can't get to not print:
$ echo 1 2 3 | xargs -P 3 -n 1 cat|wc -l 104857600Suggesting that even for output of that size the \n's aren't mixed up. YMMV.
I don't think this is telling us much, for two reasons:
- it's a pipe, not a file, so PIPE_BUF _does_ count here
- "wc -l" is counting the number of newlines, which always will be the same, whether there are interleaved blocks or not. The interesting thing is whether a single write() from one of the "cat" calls is interleaved with another, but we can't tell that without knowing how big a block cat is using.
A more interesting test is something like:
for i in a b c; do
perl -e '
syswrite(STDOUT,"this is $ARGV[0]\n") for 1..1024*1024*10
' $i & done >out
wait
sort <out | uniq -c
We are writing to a shared file here, and we care whether each individual syswrite ever got interleaved with another (which we would notice because our sort/uniq output would have more than the expected three lines).
We can even spice it up with some signals on one of the processes by putting:
$SIG{ALRM} = sub { print STDERR "alarm $ARGV[0]\n" };into the perl, and then doing:
for t in $(seq 1000); do
kill -ALRM %1
sleep 0.01
donebefore the wait. But at least on Linux (with ext4), that seems to always produce atomic results for each write(). Even if I increase the size of the message to 4k or larger.
So it seems pretty solid there, but I'm not sure I would guarantee it on other platforms or filesystems.
-Peff
PATCH v4 4/4 Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
In reply to Ævar Arnfjörð BjarmasonChange the "xargs -n X" limit for running spatch from 1 to 8, as suggested by Jeff King[1]. Now that we're not using --all-includes anymore this is going to take much less memory, so bumping the limit should be OK.
1. https://lore.kernel.org/git/[email protected]/
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -1204,7 +1204,7 @@ SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_BATCH_SIZE = 1 +SPATCH_BATCH_SIZE = 8 # For the 'coccicheck' target; SPATCH_XARGS can be used to manually # tweak the xargs invocation. By default we invoke "xargs -n 1", and
Signature · 1 line
2.31.0.285.gb40d23e604f
Re: [PATCH v4 4/4] Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
Am 22.03.21 um 13:11 schrieb Ævar Arnfjörð Bjarmason:
Quoted 4 lines
Change the "xargs -n X" limit for running spatch from 1 to 8, as suggested by Jeff King[1]. Now that we're not using --all-includes anymore this is going to take much less memory, so bumping the limit should be OK.
But --all-includes is still used, so does this patch still make sense?
Quoted 22 lines
1. https://lore.kernel.org/git/[email protected]/
Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Makefile +1
-1@@ -1204,7 +1204,7 @@ SPATCH_FLAGS = --all-includes --include-headers-for-types --patch . # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will # usually result in less CPU usage at the cost of higher peak memory. # Setting it to 0 will feed all files in a single spatch invocation. -SPATCH_BATCH_SIZE = 1 +SPATCH_BATCH_SIZE = 8 # For the 'coccicheck' target; SPATCH_XARGS can be used to manually # tweak the xargs invocation. By default we invoke "xargs -n 1", and
Re: [PATCH v4 4/4] Makefile/coccicheck: set SPATCH_BATCH_SIZE to 8
Quoted 7 lines · René Scharfe.
Am 22.03.21 um 13:11 schrieb Ævar Arnfjörð Bjarmason:
Quoted 4 lines
Change the "xargs -n X" limit for running spatch from 1 to 8, as suggested by Jeff King[1]. Now that we're not using --all-includes anymore this is going to take much less memory, so bumping the limit should be OK.
But --all-includes is still used, so does this patch still make sense?
I got similar results on the state before this series (using just --all-includes). So presumably it holds up. I'm not at all convinced, though, that this isn't simply unique to my system, or to a version of spatch.
-Peff
Re: [PATCH v4 0/4] Makefile/coccicheck: fix bugs and speed it up
In reply to Ævar Arnfjörð BjarmasonQuoted 4 lines · Ævar Arnfjörð Bjarmason
A v4 (I'm counting the 5/4 patch I sent to v2 as a v3) which produces the exact same end result as that v2 + 5/4 patch, but with a rewritten commit message/squash as requested by Junio.
Quoted 8 lines
Ævar Arnfjörð Bjarmason (4):
Makefile/coccicheck: add comment heading for all SPATCH flags Makefile/coccicheck: speed up and fix bug with duplicate hunks Makefile/coccicheck: allow for setting xargs concurrency Makefile/coccicheck: setSPATCH_BATCH_SIZEto 8Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
It seems that after some back and forth, nobody is talking about this series anymore since Wednesday 24th.
Am I correct to assume that we are now all waiting for a cleaned-up new iteration to get us closer to the finalized version?
Thanks.
Re: [PATCH v4 0/4] Makefile/coccicheck: fix bugs and speed it up
Quoted 12 lines · Junio C Hamano
Quoted 10 lines · Ævar Arnfjörð Bjarmason
A v4 (I'm counting the 5/4 patch I sent to v2 as a v3) which produces the exact same end result as that v2 + 5/4 patch, but with a rewritten commit message/squash as requested by Junio.
Ævar Arnfjörð Bjarmason (4):
Makefile/coccicheck: add comment heading for all SPATCH flags Makefile/coccicheck: speed up and fix bug with duplicate hunks Makefile/coccicheck: allow for setting xargs concurrency Makefile/coccicheck: setSPATCH_BATCH_SIZEto 8
Quoted 8 lines
Quoted 2 lines
Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)It seems that after some back and forth, nobody is talking about this series anymore since Wednesday 24th.
Am I correct to assume that we are now all waiting for a cleaned-up new iteration to get us closer to the finalized version?
Let's just eject it as noted at the end of [1] (last 4 paragraphs), I should have sent a reply to the "What's Cooking" or something, sorry.
Re: [PATCH v3 0/4] remove extern from function declarations
In reply to SZEDER GáborQuoted 1 line · SZEDER Gábor
On Wed, May 01, 2019 at 06:01:08AM -0400, Denton Liu wrote:
[snip]
Quoted 13 lines
Quoted 10 lines
-- >8 --
Subject: [PATCH]Makefile: filter out compat/ from coccicheckSince most files in compat/ are pulled from external sources, ensure that they do not get modified when we run coccicheck because we do not want them to differ from upstream as much as possible.
Make exceptions for
mingw.cand win32/*.c as these are files that we have created and not pulled from upstream.I'm not sure that we really need these exceptions.
Quoted 8 lines
C_SOURCEScomes fromC_OBJ, i.e. it is basically all '*.c' source files that we compile, taking the platform andMakefileknobs into account. On Linux we don't compile 'compat/mingw.c' and 'compat/win32/*.c', so when running 'make coccicheck' on Linux it won't look into these source files anyway, so we don't need these exceptions. On Windows, however... well, is it even possible to build and run Coccinelle on Windows in the first place, with all its OCaml dependencies?! If not, then these exceptions won't do any good.
I assumed that Coccinelle runs on Windows but now that you mention it, Cocci's origin was as a Linux refactoring tool so I'm not really sure if it actually does run. Unfortunately, I don't have a Windows box available to test it out on so let's assume that it doesn't work on Windows, unless someone says otherwise.
Quoted 4 lines
Anyway, if we do want these exceptions, then what about '
compat/win32mmap.c' and 'compat/winansi.c'? They look like "ours" as well.
Good point, I wasn't really sure which ones were ours so I just went off of what Johannes said. If we decide to keep the exceptions, I'll dig through the log messages to find all of "our" files.
Quoted 7 lines
FWIW, out of curiosity I've run 'make coccicheck' on Linux with '
compat/mingw.c' and its friends explicitly added toC_SOURCES, and it seems to work... it even found two places in 'mingw.c' whereCOPY_ARRAYcould replacememcpy():)
Since you mentioned this, shouldn't we run Coccinelle on all of our source files, not just the ones that are compiled? Since the Windows-files aren't checked, they are in a blindspot for us.
I guess a point against that would be if one were patching a file that they couldn't even test-compile, then it could be possible that faulty patches are sent, but I guess we have enough people on the mailing list that could verify the patches so I don't think that's a problem.
Perhaps we could implement a 'coccicheckall' target which excludes contrib/ but excepts mingw.c and friends?
v4 cover remove extern from function declarations
In reply to Denton LiuThanks for the review, Peff.
I've excluded all the files under compat/ from being changed as it's easier this way. After this patchset is merged, I'll probably get around to removing the externs from compat/ files later (the ones that aren't copied from some external source) but for now, this patchset is big enough as it is so we can leave those for now.
I also opted not to remove the noextern.cocci since we can probably do this in the future but it's probably beneficial to leave it in for now for the reasons that you've mentioned.
---
Changes since v1:
* Used spatch with sed instead of sed alone
* Fixed sed expression to ignore function variables
Changes since v2:
* Rebased on latest master (since last patchset hasn't been picked up yet)
* Manually aligned parameter lists that were mangled by the tools
Changes since v3:
* Excluded compat/ from cleanup
Denton Liu (4):
*.[ch]: remove extern from function declarations using spatch *.[ch]: remove extern from function declarations using sed *.[ch]: manually align parameter lists
cocci: prevent extern function declarations
advice.h | 2 +- archive.h | 24 +- bisect.h | 26 +- blame.h | 2 +- branch.h | 14 +- builtin.h | 254 ++++++++++---------- bulk-checkin.h | 10 +- cache.h | 386 +++++++++++++++--------------- checkout.h | 6 +- column.h | 16 +- commit.h | 116 ++++----- config.h | 226 ++++++++--------- connect.h | 22 +- contrib/coccinelle/noextern.cocci | 6 + csum-file.h | 20 +- decorate.h | 4 +- delta.h | 14 +- dir.h | 144 +++++------ exec-cmd.h | 16 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 132 +++++----- grep.h | 22 +- hashmap.h | 30 +-- help.h | 36 +-- http.h | 62 ++--- khash.h | 16 +- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 12 +- ls-refs.h | 4 +- mailinfo.h | 6 +- merge-blobs.h | 6 +- object-store.h | 32 +-- object.h | 12 +- oidmap.h | 12 +- pack.h | 26 +- packfile.h | 82 +++---- path.h | 42 ++-- pkt-line.h | 10 +- ppc/sha1.c | 4 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 34 +-- reachable.h | 8 +- reflog-walk.h | 28 +-- refs.h | 2 +- remote.h | 24 +- replace-object.h | 4 +- resolve-undo.h | 14 +- run-command.h | 8 +- serve.h | 6 +- sha1-lookup.h | 8 +- streaming.h | 8 +- string-list.h | 4 +- sub-process.h | 8 +- submodule-config.h | 22 +- tag.h | 16 +- tempfile.h | 30 +-- trace.h | 44 ++-- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 8 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 4 +- worktree.h | 36 +-- xdiff-interface.h | 12 +- 72 files changed, 1145 insertions(+), 1139 deletions(-) create mode 100644 contrib/coccinelle/noextern.cocci
Range-diff against v3:
1: 2ed74c5e5b ! 1: 720d50aea7 *.[ch]: remove extern from function declarations using spatch
@@ -19,7 +19,13 @@
and it was run with:
- $ spatch --sp-file contrib/coccinelle/noextern.cocci --dir . --include-headers --in-place
+ $ git ls-files \*.{c,h} | \
+ grep -v ^compat/ | \
+ xargs spatch --sp-file contrib/coccinelle/noextern.cocci --in-place
+
+ Files under compat/ are intentionally excluded as some are directly
+ copied from external sources and we should avoid churning them as much
+ as possible.
@@ -1388,242 +1394,6 @@
/* record author-date for each commit object */ struct author_date_slab;
- diff --git a/compat/mingw.c b/compat/mingw.c
- --- a/compat/mingw.c
- +++ b/compat/mingw.c
-@@
- int newmode;
- } _startupinfo;
-
--extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob, -+int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,
- _startupinfo *si);
-
- static NORETURN void die_startup(void)
-
- diff --git a/compat/mingw.h b/compat/mingw.h
- --- a/compat/mingw.h
- +++ b/compat/mingw.h
-@@
- #undef _POSIX_THREAD_SAFE_FUNCTIONS
- #endif
-
--extern int mingw_core_config(const char *var, const char *value, void *cb); -+int mingw_core_config(const char *var, const char *value, void *cb);
- #define platform_core_config mingw_core_config
-
- /*
-@@
- *path = '/';
- }
- #define PATH_SEP ';'
--extern char *mingw_query_user_email(void);
-+char *mingw_query_user_email(void);
- #define query_user_email mingw_query_user_email
- #if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER < 1800)
- #define PRIuMAX "I64u"
-@@
- /*
- * Used by Pthread API implementation for Windows
- */
--extern int err_win_to_posix(DWORD winerr);
-+int err_win_to_posix(DWORD winerr);
-
- diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
- --- a/compat/nedmalloc/malloc.c.h
- +++ b/compat/nedmalloc/malloc.c.h
-@@
- #include <unistd.h> /* for sbrk, sysconf */
- #else /* LACKS_UNISTD_H */
- #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
--extern void* sbrk(ptrdiff_t);
-+void* sbrk(ptrdiff_t);
- #endif /* FreeBSD etc */
- #endif /* LACKS_UNISTD_H */
-
-@@
- # define malloc_getpagesize sysconf(_SC_PAGE_SIZE)
- # else
- # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
-- extern size_t getpagesize();
-+ size_t getpagesize();
- # define malloc_getpagesize getpagesize()
- # else
- # ifdef WIN32 /* use supplied emulation of getpagesize */
-@@
- /* skipped internal declaration from pthread.h */
- #ifdef linux
- #ifndef PTHREAD_MUTEX_RECURSIVE
--extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, -+int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr,
- int __kind));
- #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
- #define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) -
- diff --git a/compat/obstack.h b/compat/obstack.h
- --- a/compat/obstack.h
- +++ b/compat/obstack.h
-@@
-
- /* Declare the external functions we use; they are in obstack.c. */ -
--extern void _obstack_newchunk (struct obstack *, int);
--extern int _obstack_begin (struct obstack *, int, int,
-+void _obstack_newchunk (struct obstack *, int);
-+int _obstack_begin (struct obstack *, int, int,
- void *(*) (long), void (*) (void *));
--extern int _obstack_begin_1 (struct obstack *, int, int,
-+int _obstack_begin_1 (struct obstack *, int, int,
- void *(*) (void *, long),
- void (*) (void *, void *), void *);
--extern int _obstack_memory_used (struct obstack *);
-+int _obstack_memory_used (struct obstack *);
-
- void obstack_free (struct obstack *, void *);
-
-
- diff --git a/compat/poll/poll.h b/compat/poll/poll.h
- --- a/compat/poll/poll.h
- +++ b/compat/poll/poll.h
-@@
-
- typedef unsigned long nfds_t;
-
--extern int poll (struct pollfd *pfd, nfds_t nfd, int timeout);
-+int poll (struct pollfd *pfd, nfds_t nfd, int timeout);
-
- /* Define INFTIM only if doing so conforms to POSIX. */
- #if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
-
- diff --git a/compat/regex/regex.h b/compat/regex/regex.h
- --- a/compat/regex/regex.h
- +++ b/compat/regex/regex.h
-@@
- #ifdef __USE_GNU
- /* Sets the current default syntax to SYNTAX, and return the old syntax.
- You can also simply assign to the `re_syntax_options' variable. */
--extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); -+reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
-
- /* Compile the regular expression PATTERN, with length LENGTH
- and syntax given by the global `re_syntax_options', into the buffer
- BUFFER. Return NULL if successful, and an error string if not. */
--extern const char *re_compile_pattern (const char *__pattern, size_t __length, -+const char *re_compile_pattern (const char *__pattern, size_t __length,
- struct re_pattern_buffer *__buffer);
-
-
- /* Compile a fastmap for the compiled pattern in BUFFER; used to
- accelerate searches. Return 0 if successful and -2 if was an
- internal error. */
--extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); -+int re_compile_fastmap (struct re_pattern_buffer *__buffer);
-
-
- /* Search in the string STRING (with length LENGTH) for the pattern -@@
- characters. Return the starting position of the match, -1 for no
- match, or -2 for an internal error. Also return register
- information in REGS (if REGS and BUFFER->no_sub are nonzero). */
--extern int re_search (struct re_pattern_buffer *__buffer, const char *__cstring, -+int re_search (struct re_pattern_buffer *__buffer, const char *__cstring,
- int __length, int __start, int __range,
- struct re_registers *__regs);
-
-
- /* Like `re_search', but search in the concatenation of STRING1 and
- STRING2. Also, stop searching at index START + STOP. */
--extern int re_search_2 (struct re_pattern_buffer *__buffer,
-+int re_search_2 (struct re_pattern_buffer *__buffer,
- const char *__string1, int __length1,
- const char *__string2, int __length2, int __start,
- int __range, struct re_registers *__regs, int __stop);
-@@
-
- /* Like `re_search', but return how many characters in STRING the regexp
- in BUFFER matched, starting at position START. */
--extern int re_match (struct re_pattern_buffer *__buffer, const char *__cstring, -+int re_match (struct re_pattern_buffer *__buffer, const char *__cstring,
- int __length, int __start, struct re_registers *__regs);
-
-
- /* Relates to re_match' as re_search_2' relates to `re_search'. */ --extern int re_match_2 (struct re_pattern_buffer *__buffer,
-+int re_match_2 (struct re_pattern_buffer *__buffer,
- const char *__string1, int __length1,
- const char *__string2, int __length2, int __start,
- struct re_registers *__regs, int __stop);
-@@
- Unless this function is called, the first search or match using
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
--extern void re_set_registers (struct re_pattern_buffer *__buffer, -+void re_set_registers (struct re_pattern_buffer *__buffer,
- struct re_registers *__regs,
- unsigned int __num_regs,
- regoff_t *__starts, regoff_t *__ends);
-@@
- #if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
- # ifndef _CRAY
- /* 4.2 bsd compatibility. */
--extern char *re_comp (const char *);
--extern int re_exec (const char *);
-+char *re_comp (const char *);
-+int re_exec (const char *);
- # endif
- #endif
-
-@@
- #endif
-
- /* POSIX compatibility. */
--extern int regcomp (regex_t *__restrict __preg,
-+int regcomp (regex_t *__restrict __preg,
- const char *__restrict __pattern,
- int __cflags);
-
--extern int regexec (const regex_t *__restrict __preg,
-+int regexec (const regex_t *__restrict __preg,
- const char *__restrict __cstring, size_t __nmatch,
- regmatch_t __pmatch[__restrict_arr],
- int __eflags);
-
--extern size_t regerror (int __errcode, const regex_t *__restrict __preg, -+size_t regerror (int __errcode, const regex_t *__restrict __preg,
- char *__restrict __errbuf, size_t __errbuf_size);
-
--extern void regfree (regex_t *__preg);
-+void regfree (regex_t *__preg);
-
-
- #ifdef __cplusplus
-
- diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
- --- a/compat/win32/pthread.h
- +++ b/compat/win32/pthread.h
-@@
- DWORD tid;
- } pthread_t;
-
--extern int pthread_create(pthread_t *thread, const void *unused, -+int pthread_create(pthread_t *thread, const void *unused,
- void *(*start_routine)(void*), void *arg);
-
- /*
-@@
- */
- #define pthread_join(a, b) win32_pthread_join(&(a), (b))
-
--extern int win32_pthread_join(pthread_t *thread, void **value_ptr); -+int win32_pthread_join(pthread_t *thread, void **value_ptr);
-
- #define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
--extern pthread_t pthread_self(void);
-+pthread_t pthread_self(void);
-
- static inline void NORETURN pthread_exit(void *ret)
- {
-
diff --git a/config.h b/config.h
--- a/config.h
+++ b/config.h
2: 7d35a052a6 ! 2: 0ebda47252 *.[ch]: remove extern from function declarations using sed
@@ -8,7 +8,13 @@
This was done by running the following on my system with sed 4.2.2:
- $ git ls-files \*.{c,h} | xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\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
3: 916c34450f ! 3: a813c36cab *.[ch]: manually align parameter lists
@@ -391,125 +391,6 @@
/*
- diff --git a/compat/obstack.h b/compat/obstack.h
- --- a/compat/obstack.h
- +++ b/compat/obstack.h
-@@
-
- void _obstack_newchunk (struct obstack *, int);
- int _obstack_begin (struct obstack *, int, int,
-- void *(*) (long), void (*) (void *));
-+ void *(*) (long), void (*) (void *));
- int _obstack_begin_1 (struct obstack *, int, int,
-- void *(*) (void *, long),
-- void (*) (void *, void *), void *);
-+ void *(*) (void *, long),
-+ void (*) (void *, void *), void *);
- int _obstack_memory_used (struct obstack *);
-
- void obstack_free (struct obstack *, void *);
-
- diff --git a/compat/regex/regex.h b/compat/regex/regex.h
- --- a/compat/regex/regex.h
- +++ b/compat/regex/regex.h
-@@
- and syntax given by the global `re_syntax_options', into the buffer
- BUFFER. Return NULL if successful, and an error string if not. */
- const char *re_compile_pattern (const char *__pattern, size_t __length,
-- struct re_pattern_buffer *__buffer);
-+ struct re_pattern_buffer *__buffer);
-
-
- /* Compile a fastmap for the compiled pattern in BUFFER; used to
-@@
- match, or -2 for an internal error. Also return register
- information in REGS (if REGS and BUFFER->no_sub are nonzero). */
- int re_search (struct re_pattern_buffer *__buffer, const char *__cstring,
-- int __length, int __start, int __range,
-- struct re_registers *__regs);
-+ int __length, int __start, int __range,
-+ struct re_registers *__regs);
-
-
- /* Like `re_search', but search in the concatenation of STRING1 and
- STRING2. Also, stop searching at index START + STOP. */
- int re_search_2 (struct re_pattern_buffer *__buffer,
-- const char *__string1, int __length1,
-- const char *__string2, int __length2, int __start,
-- int __range, struct re_registers *__regs, int __stop);
-+ const char *__string1, int __length1,
-+ const char *__string2, int __length2, int __start,
-+ int __range, struct re_registers *__regs, int __stop);
-
-
- /* Like `re_search', but return how many characters in STRING the regexp
- in BUFFER matched, starting at position START. */
- int re_match (struct re_pattern_buffer *__buffer, const char *__cstring,
-- int __length, int __start, struct re_registers *__regs);
-+ int __length, int __start, struct re_registers *__regs);
-
-
- /* Relates to `re_match' as `re_search_2' relates to `re_search'. */
- int re_match_2 (struct re_pattern_buffer *__buffer,
-- const char *__string1, int __length1,
-- const char *__string2, int __length2, int __start,
-- struct re_registers *__regs, int __stop);
-+ const char *__string1, int __length1,
-+ const char *__string2, int __length2, int __start,
-+ struct re_registers *__regs, int __stop);
-
-
- /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
-@@
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
- void re_set_registers (struct re_pattern_buffer *__buffer,
-- struct re_registers *__regs,
-- unsigned int __num_regs,
-- regoff_t *__starts, regoff_t *__ends);
-+ struct re_registers *__regs,
-+ unsigned int __num_regs,
-+ regoff_t *__starts, regoff_t *__ends);
- #endif /* Use GNU */
-
- #if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
-@@
-
- /* POSIX compatibility. */
- int regcomp (regex_t *__restrict __preg,
-- const char *__restrict __pattern,
-- int __cflags);
-+ const char *__restrict __pattern,
-+ int __cflags);
-
- int regexec (const regex_t *__restrict __preg,
-- const char *__restrict __cstring, size_t __nmatch,
-- regmatch_t __pmatch[__restrict_arr],
-- int __eflags);
-+ const char *__restrict __cstring, size_t __nmatch,
-+ regmatch_t __pmatch[__restrict_arr],
-+ int __eflags);
-
- size_t regerror (int __errcode, const regex_t *__restrict __preg,
-- char *__restrict __errbuf, size_t __errbuf_size);
-+ char *__restrict __errbuf, size_t __errbuf_size);
-
- void regfree (regex_t *__preg);
-
-
- diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
- --- a/compat/win32/pthread.h
- +++ b/compat/win32/pthread.h
-@@
- } pthread_t;
-
- int pthread_create(pthread_t *thread, const void *unused,
-- void *(*start_routine)(void*), void *arg);
-+ void *(*start_routine)(void*), void *arg);
-
- /*
- * To avoid the need of copying a struct, we use small macro wrapper to pass
-
diff --git a/config.h b/config.h
--- a/config.h
+++ b/config.h4: d5a1663048 = 4: 23ed6ad679 cocci: prevent extern function declarations
Signature · 1 line
2.21.0.1000.g7817e26e80
PATCH v4 1/4 *.[ch]: remove extern from function declarations using spatch
There has been a push to remove extern from function declarations. Remove some instances of "extern" for function declarations which are caught by Coccinelle. Note that Coccinelle has some difficulty with processing functions with __attribute__ or varargs so some extern declarations are left behind to be dealt with in a future patch.
This was the Coccinelle patch used:
@@ type T; identifier f; @@ - extern T f(...);
and it was run with:
$ git ls-files \*.{c,h} | \
grep -v ^compat/ | \
xargs spatch --sp-file contrib/coccinelle/noextern.cocci --in-placeFiles under compat/ are intentionally excluded as some are directly copied from external sources and we should avoid churning them as much as possible.
--- advice.h | 2 +- archive.h | 14 +- bisect.h | 12 +- blame.h | 2 +- branch.h | 12 +- builtin.h | 252 ++++++++++++++--------------- bulk-checkin.h | 6 +- cache.h | 340 +++++++++++++++++++-------------------- checkout.h | 2 +- column.h | 12 +- commit.h | 70 ++++---- config.h | 182 ++++++++++----------- connect.h | 20 +-- csum-file.h | 20 +-- decorate.h | 4 +- delta.h | 10 +- dir.h | 70 ++++---- exec-cmd.h | 14 +- fmt-merge-msg.h | 2 +- fsmonitor.h | 14 +- gettext.h | 8 +- git-compat-util.h | 108 ++++++------- grep.h | 22 +-- hashmap.h | 30 ++-- help.h | 30 ++-- http.h | 52 +++--- kwset.h | 10 +- line-log.h | 16 +- lockfile.h | 10 +- ls-refs.h | 2 +- mailinfo.h | 6 +- merge-blobs.h | 2 +- object-store.h | 16 +- object.h | 12 +- oidmap.h | 10 +- pack.h | 24 +-- packfile.h | 74 ++++----- path.h | 2 +- pkt-line.h | 6 +- ppc/sha1.c | 2 +- prio-queue.h | 10 +- protocol.h | 6 +- quote.h | 30 ++-- reachable.h | 4 +- reflog-walk.h | 16 +- refs.h | 2 +- remote.h | 12 +- replace-object.h | 2 +- resolve-undo.h | 14 +- run-command.h | 6 +- serve.h | 4 +- sha1-lookup.h | 2 +- streaming.h | 8 +- string-list.h | 2 +- sub-process.h | 2 +- submodule-config.h | 20 +-- tag.h | 14 +- tempfile.h | 26 +-- trace.h | 16 +- transport.h | 4 +- tree-walk.h | 4 +- upload-pack.h | 4 +- url.h | 16 +- urlmatch.h | 4 +- utf8.h | 2 +- varint.h | 4 +- vcs-svn/sliding_window.h | 2 +- vcs-svn/svndiff.h | 2 +- worktree.h | 20 +-- xdiff-interface.h | 10 +- 70 files changed, 885 insertions(+), 885 deletions(-)
advice.h +1 -1
@@ -31,7 +31,7 @@ int git_default_advice_config(const char *var, const char *value); __attribute__((format (printf,1 ,2 )))void advise (const char *advice, ...);int error_resolve_conflict (const char *me); -extern void NORETURN die_resolve_conflict(const char *me); +void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void);void detach_advice (const char *new_name);
archive.h +7 -7
@@ -23,7 +23,7 @@ struct archiver_args {/* main api */ -extern int write_archive (int argc,const char **argv,const char *prefix, +int write_archive (int argc,const char **argv,const char *prefix,struct repository *repo,const char *name_hint,int remote);
@@ -39,19 +39,19 @@ struct archiver {unsigned flags;void *data; }; -extern void register_archiver (struct archiver *); +void register_archiver (struct archiver *); -extern void init_tar_archiver (void ); -extern void init_zip_archiver (void ); -extern void init_archivers (void ); +void init_tar_archiver (void ); +void init_zip_archiver (void ); +void init_archivers (void );typedef int (*write_archive_entry_fn_t )(struct archiver_args *args,const struct object_id *oid,const char *path,size_t pathlen,unsigned int mode); -extern int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); -extern void *object_file_to_archive (const struct archiver_args *args, +int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); +void *object_file_to_archive (const struct archiver_args *args,const char *path,const struct object_id *oid,unsigned int mode,enum object_type *type,unsigned long *sizep);
bisect.h +6 -6
@@ -11,10 +11,10 @@ struct repository;* Otherwise, it will be either all non-SAMETREE commits or the single * best commit, as chosen by `find_all`. */ -extern void find_bisection (struct commit_list **list,int *reaches,int *all, +void find_bisection (struct commit_list **list,int *reaches,int *all,int find_all); -extern struct commit_list *filter_skipped(struct commit_list *list, +struct commit_list *filter_skipped(struct commit_list *list, struct commit_list **tried, int show_all, int *count,
@@ -31,14 +31,14 @@ struct rev_list_info { const char *header_prefix; }; -extern int bisect_next_all (struct repository *r, +int bisect_next_all (struct repository *r,const char *prefix,int no_checkout); -extern int estimate_bisect_steps (int all); +int estimate_bisect_steps (int all); -extern void read_bisect_terms (const char **bad,const char **good); +void read_bisect_terms (const char **bad,const char **good); -extern int bisect_clean_state (void ); +int bisect_clean_state (void );#endif
blame.h +1 -1
@@ -177,6 +177,6 @@ struct blame_entry *blame_entry_prepend(struct blame_entry *head, long start, long end, struct blame_origin *o); -extern struct blame_origin *get_blame_suspects (struct commit *commit); +struct blame_origin *get_blame_suspects (struct commit *commit);#endif /* BLAME_H */
branch.h +6 -6
@@ -50,7 +50,7 @@ void create_branch(struct repository *r,* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_branchname (const char *name,struct strbuf *ref); +int validate_branchname (const char *name,struct strbuf *ref);/* * Check if a branch 'name' can be created as a new branch; die otherwise.
@@ -58,7 +58,7 @@ extern int validate_branchname(const char *name, struct strbuf *ref);* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -extern int validate_new_branchname (const char *name,struct strbuf *ref,int force); +int validate_new_branchname (const char *name,struct strbuf *ref,int force);/* * Remove information about the state of working on the current
@@ -72,26 +72,26 @@ void remove_branch_state(struct repository *r);* Returns 0 on success. */ #define BRANCH_CONFIG_VERBOSE 01 -extern int install_branch_config (int flag,const char *local,const char *origin,const char *remote); +int install_branch_config (int flag,const char *local,const char *origin,const char *remote);/* * Read branch description */ -extern int read_branch_desc (struct strbuf *,const char *branch_name); +int read_branch_desc (struct strbuf *,const char *branch_name);/* * Check if a branch is checked out in the main worktree or any linked * worktree and die (with a message describing its checkout location) if * it is. */ -extern void die_if_checked_out (const char *branch,int ignore_current_worktree); +void die_if_checked_out (const char *branch,int ignore_current_worktree);/* * Update all per-worktree HEADs pointing at the old ref to point the new ref. * This will be used when renaming a branch. Returns 0 if successful, non-zero * otherwise. */ -extern int replace_each_worktree_head_symref (const char *oldref,const char *newref, +int replace_each_worktree_head_symref (const char *oldref,const char *newref,const char *logmsg);#endif
builtin.h +126 -126
271 lines not on this page · raw message
bulk-checkin.h +3 -3
@@ -6,11 +6,11 @@#include "cache.h" -extern int index_bulk_checkin (struct object_id *oid, +int index_bulk_checkin (struct object_id *oid,int fd,size_t size,enum object_type type,const char *path,unsigned flags); -extern void plug_bulk_checkin (void ); -extern void unplug_bulk_checkin (void ); +void plug_bulk_checkin (void ); +void unplug_bulk_checkin (void );#endif
cache.h +170 -170
663 lines not on this page · raw message
checkout.h +1 -1
@@ -8,7 +8,7 @@* tracking branch. Return the name of the remote if such a branch * exists, NULL otherwise. */ -extern const char *unique_tracking_name (const char *name, +const char *unique_tracking_name (const char *name,struct object_id *oid,int *dwim_remotes_matched);
column.h +6 -6
@@ -27,20 +27,20 @@ struct column_options { };struct option ; -extern int parseopt_column_callback (const struct option *,const char *,int ); -extern int git_column_config (const char *var,const char *value, +int parseopt_column_callback (const struct option *,const char *,int ); +int git_column_config (const char *var,const char *value,const char *command,unsigned int *colopts); -extern int finalize_colopts (unsigned int *colopts,int stdout_is_tty); +int finalize_colopts (unsigned int *colopts,int stdout_is_tty);static inline int column_active (unsigned int colopts) {return (colopts &COL_ENABLE_MASK ) ==COL_ENABLED ; }struct string_list ; -extern void print_columns (const struct string_list *list,unsigned int colopts, +void print_columns (const struct string_list *list,unsigned int colopts,const struct column_options *opts); -extern int run_column_filter (int colopts,const struct column_options *); -extern int stop_column_filter (void ); +int run_column_filter (int colopts,const struct column_options *); +int stop_column_filter (void );#endif
commit.h +35 -35
155 lines not on this page · raw message
config.h +91 -91
254 lines not on this page · raw message
connect.h +10 -10
@@ -7,19 +7,19 @@#define CONNECT_DIAG_URL (1u << 1)#define CONNECT_IPV4 (1u << 2)#define CONNECT_IPV6 (1u << 3) -extern struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); -extern int finish_connect (struct child_process *conn); -extern int git_connection_is_socket (struct child_process *conn); -extern int server_supports (const char *feature); -extern int parse_feature_request (const char *features,const char *feature); -extern const char *server_feature_value (const char *feature,int *len_ret); -extern int url_is_local_not_ssh (const char *url); +struct child_process *git_connect (int fd[2 ],const char *url,const char *prog,int flags); +int finish_connect (struct child_process *conn); +int git_connection_is_socket (struct child_process *conn); +int server_supports (const char *feature); +int parse_feature_request (const char *features,const char *feature); +const char *server_feature_value (const char *feature,int *len_ret); +int url_is_local_not_ssh (const char *url);struct packet_reader ; -extern enum protocol_version discover_version (struct packet_reader *reader); +enum protocol_version discover_version (struct packet_reader *reader); -extern int server_supports_v2 (const char *c,int die_on_error); -extern int server_supports_feature (const char *c,const char *feature, +int server_supports_v2 (const char *c,int die_on_error); +int server_supports_feature (const char *c,const char *feature,int die_on_error);#endif
csum-file.h +10 -10
@@ -25,22 +25,22 @@ struct hashfile_checkpoint {git_hash_ctx ctx; }; -extern void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); -extern int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *); +void hashfile_checkpoint (struct hashfile *,struct hashfile_checkpoint *); +int hashfile_truncate (struct hashfile *,struct hashfile_checkpoint *);/* finalize_hashfile flags */ #define CSUM_CLOSE 1#define CSUM_FSYNC 2#define CSUM_HASH_IN_STREAM 4 -extern struct hashfile *hashfd (int fd,const char *name); -extern struct hashfile *hashfd_check (const char *name); -extern struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); -extern int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); -extern void hashwrite (struct hashfile *,const void *,unsigned int ); -extern void hashflush (struct hashfile *f); -extern void crc32_begin (struct hashfile *); -extern uint32_t crc32_end (struct hashfile *); +struct hashfile *hashfd (int fd,const char *name); +struct hashfile *hashfd_check (const char *name); +struct hashfile *hashfd_throughput (int fd,const char *name,struct progress *tp); +int finalize_hashfile (struct hashfile *,unsigned char *,unsigned int ); +void hashwrite (struct hashfile *,const void *,unsigned int ); +void hashflush (struct hashfile *f); +void crc32_begin (struct hashfile *); +uint32_t crc32_end (struct hashfile *);static inline void hashwrite_u8 (struct hashfile *f,uint8_t data) {
decorate.h +2 -2
@@ -50,12 +50,12 @@ struct decoration {* NULL), returning the previously associated pointer. If there is no previous * association, this function returns NULL. */ -extern void *add_decoration (struct decoration *n,const struct object *obj,void *decoration); +void *add_decoration (struct decoration *n,const struct object *obj,void *decoration);/* * Return the pointer associated to the given object. If there is no * association, this function returns NULL. */ -extern void *lookup_decoration (struct decoration *n,const struct object *obj); +void *lookup_decoration (struct decoration *n,const struct object *obj);#endif
delta.h +5 -5
@@ -13,7 +13,7 @@ struct delta_index;* before free_delta_index() is called. The returned pointer must be freed * using free_delta_index(). */ -extern struct delta_index * +struct delta_index *create_delta_index (const void *buf,unsigned long bufsize);/*
@@ -21,14 +21,14 @@ create_delta_index(const void *buf, unsigned long bufsize);* * Given pointer must be what create_delta_index() returned, or NULL. */ -extern void free_delta_index (struct delta_index *index); +void free_delta_index (struct delta_index *index);/* * sizeof_delta_index: returns memory usage of delta index * * Given pointer must be what create_delta_index() returned, or NULL. */ -extern unsigned long sizeof_delta_index (struct delta_index *index); +unsigned long sizeof_delta_index (struct delta_index *index);/* * create_delta: create a delta from given index for the given buffer
@@ -40,7 +40,7 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);* returned and *delta_size is updated with its size. The returned buffer * must be freed by the caller. */ -extern void * +void *create_delta (const struct delta_index *index,const void *buf,unsigned long bufsize,unsigned long *delta_size,unsigned long max_delta_size);
@@ -75,7 +75,7 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,* *trg_bufsize is updated with its size. On failure a NULL pointer is * returned. The returned buffer must be freed by the caller. */ -extern void *patch_delta (const void *src_buf,unsigned long src_size, +void *patch_delta (const void *src_buf,unsigned long src_size,const void *delta_buf,unsigned long delta_size,unsigned long *dst_size);
dir.h +35 -35
145 lines not on this page · raw message
exec-cmd.h +7 -7
@@ -3,14 +3,14 @@struct argv_array ; -extern void git_set_exec_path (const char *exec_path); -extern void git_resolve_executable_dir (const char *path); -extern const char *git_exec_path (void ); -extern void setup_path (void ); -extern const char **prepare_git_cmd (struct argv_array *out,const char **argv); -extern int execv_git_cmd (const char **argv);/* NULL terminated */ +void git_set_exec_path (const char *exec_path); +void git_resolve_executable_dir (const char *path); +const char *git_exec_path (void ); +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, ...); -extern char *system_path (const char *path); +char *system_path (const char *path);#endif /* GIT_EXEC_CMD_H */
fmt-merge-msg.h +1 -1
@@ -2,6 +2,6 @@#define FMT_MERGE_MSG_H extern int merge_log_config; -extern int fmt_merge_msg_config (const char *key,const char *value,void *cb); +int fmt_merge_msg_config (const char *key,const char *value,void *cb);#endif /* FMT_MERGE_MSG_H */
fsmonitor.h +7 -7
@@ -10,31 +10,31 @@ extern struct trace_key trace_fsmonitor;* Read the fsmonitor index extension and (if configured) restore the * CE_FSMONITOR_VALID state. */ -extern int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz); +int read_fsmonitor_extension (struct index_state *istate,const void *data,unsigned long sz);/* * Fill the fsmonitor_dirty ewah bits with their state from the index, * before it is split during writing. */ -extern void fill_fsmonitor_bitmap (struct index_state *istate); +void fill_fsmonitor_bitmap (struct index_state *istate);/* * Write the CE_FSMONITOR_VALID state into the fsmonitor index * extension. Reads from the fsmonitor_dirty ewah in the index. */ -extern void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate); +void write_fsmonitor_extension (struct strbuf *sb,struct index_state *istate);/* * Add/remove the fsmonitor index extension */ -extern void add_fsmonitor (struct index_state *istate); -extern void remove_fsmonitor (struct index_state *istate); +void add_fsmonitor (struct index_state *istate); +void remove_fsmonitor (struct index_state *istate);/* * Add/remove the fsmonitor index extension as necessary based on the current * core.fsmonitor setting. */ -extern void tweak_fsmonitor (struct index_state *istate); +void tweak_fsmonitor (struct index_state *istate);/* * Run the configured fsmonitor integration script and clear the
@@ -42,7 +42,7 @@ extern void tweak_fsmonitor(struct index_state *istate);* any corresponding untracked cache directory structures. Optimized to only * run the first time it is called. */ -extern void refresh_fsmonitor (struct index_state *istate); +void refresh_fsmonitor (struct index_state *istate);/* * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
gettext.h +4 -4
@@ -28,11 +28,11 @@#define FORMAT_PRESERVING (n) __attribute__((format_arg(n))) -extern int use_gettext_poison (void ); +int use_gettext_poison (void );#ifndef NO_GETTEXT -extern void git_setup_gettext (void ); -extern int gettext_width (const char *s); +void git_setup_gettext (void ); +int gettext_width (const char *s);#else static inline void git_setup_gettext (void ) {
@@ -87,6 +87,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)#endif const char *get_preferred_languages (void ); -extern int is_utf8_locale (void ); +int is_utf8_locale (void );#endif
git-compat-util.h +54 -54
242 lines not on this page · raw message
grep.h +11 -11
@@ -186,17 +186,17 @@ struct grep_opt {void *output_priv; }; -extern void init_grep_defaults (struct repository *); -extern int grep_config (const char *var,const char *value,void *); -extern void grep_init (struct grep_opt *,struct repository *repo,const char *prefix); +void init_grep_defaults (struct repository *); +int grep_config (const char *var,const char *value,void *); +void grep_init (struct grep_opt *,struct repository *repo,const char *prefix);void grep_commit_pattern_type (enum grep_pattern_type ,struct grep_opt *opt); -extern void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); -extern void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); -extern void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); -extern void compile_grep_patterns (struct grep_opt *opt); -extern void free_grep_patterns (struct grep_opt *opt); -extern int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size); +void append_grep_pat (struct grep_opt *opt,const char *pat,size_t patlen,const char *origin,int no,enum grep_pat_token t); +void append_grep_pattern (struct grep_opt *opt,const char *pat,const char *origin,int no,enum grep_pat_token t); +void append_header_grep_pattern (struct grep_opt *,enum grep_header_field ,const char *); +void compile_grep_patterns (struct grep_opt *opt); +void free_grep_patterns (struct grep_opt *opt); +int grep_buffer (struct grep_opt *opt,char *buf,unsigned long size);struct grep_source {char *name;
@@ -226,8 +226,8 @@ void grep_source_load_driver(struct grep_source *gs,int grep_source (struct grep_opt *opt,struct grep_source *gs); -extern struct grep_opt *grep_opt_dup (const struct grep_opt *opt); -extern int grep_threads_ok (const struct grep_opt *opt); +struct grep_opt *grep_opt_dup (const struct grep_opt *opt); +int grep_threads_ok (const struct grep_opt *opt);/* * Mutex used around access to the attributes machinery if
hashmap.h +15 -15
@@ -104,11 +104,11 @@* `memihash_cont` is a variant of `memihash` that allows a computation to be * continued with another chunk of data. */ -extern unsigned int strhash (const char *buf); -extern unsigned int strihash (const char *buf); -extern unsigned int memhash (const void *buf,size_t len); -extern unsigned int memihash (const void *buf,size_t len); -extern unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len); +unsigned int strhash (const char *buf); +unsigned int strihash (const char *buf); +unsigned int memhash (const void *buf,size_t len); +unsigned int memihash (const void *buf,size_t len); +unsigned int memihash_cont (unsigned int hash_seed,const void *buf,size_t len);/* * Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code
@@ -216,7 +216,7 @@ struct hashmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void hashmap_init (struct hashmap *map, +void hashmap_init (struct hashmap *map,hashmap_cmp_fn equals_function,const void *equals_function_data,size_t initial_size);
@@ -227,7 +227,7 @@ extern void hashmap_init(struct hashmap *map,* If `free_entries` is true, each hashmap_entry in the map is freed as well * using stdlibs free(). */ -extern void hashmap_free (struct hashmap *map,int free_entries); +void hashmap_free (struct hashmap *map,int free_entries);/* hashmap_entry functions */
@@ -284,7 +284,7 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)* If an entry with matching hash code is found, `key` and `keydata` are passed * to `hashmap_cmp_fn` to decide whether the entry matches the key. */ -extern void *hashmap_get (const struct hashmap *map,const void *key, +void *hashmap_get (const struct hashmap *map,const void *key,const void *keydata);/*
@@ -316,7 +316,7 @@ static inline void *hashmap_get_from_hash(const struct hashmap *map,* `entry` is the hashmap_entry to start the search from, obtained via a previous * call to `hashmap_get` or `hashmap_get_next`. */ -extern void *hashmap_get_next (const struct hashmap *map,const void *entry); +void *hashmap_get_next (const struct hashmap *map,const void *entry);/* * Adds a hashmap entry. This allows to add duplicate entries (i.e.
@@ -325,7 +325,7 @@ extern void *hashmap_get_next(const struct hashmap *map, const void *entry);* `map` is the hashmap structure. * `entry` is the entry to add. */ -extern void hashmap_add (struct hashmap *map,void *entry); +void hashmap_add (struct hashmap *map,void *entry);/* * Adds or replaces a hashmap entry. If the hashmap contains duplicate
@@ -335,7 +335,7 @@ extern void hashmap_add(struct hashmap *map, void *entry);* `entry` is the entry to add or replace. * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *hashmap_put (struct hashmap *map,void *entry); +void *hashmap_put (struct hashmap *map,void *entry);/* * Removes a hashmap entry matching the specified key. If the hashmap contains
@@ -344,7 +344,7 @@ extern void *hashmap_put(struct hashmap *map, void *entry);* * Argument explanation is the same as in `hashmap_get`. */ -extern void *hashmap_remove (struct hashmap *map,const void *key, +void *hashmap_remove (struct hashmap *map,const void *key,const void *keydata);/*
@@ -365,10 +365,10 @@ struct hashmap_iter { };/* Initializes a `hashmap_iter` structure. */ -extern void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter); +void hashmap_iter_init (struct hashmap *map,struct hashmap_iter *iter);/* Returns the next hashmap_entry, or NULL if there are no more entries. */ -extern void *hashmap_iter_next (struct hashmap_iter *iter); +void *hashmap_iter_next (struct hashmap_iter *iter);/* Initializes the iterator and returns the first entry, if any. */ static inline void *hashmap_iter_first(struct hashmap *map,
@@ -429,7 +429,7 @@ static inline void hashmap_enable_item_counting(struct hashmap *map)* * Uses a hashmap to store the pool of interned strings. */ -extern const void *memintern (const void *data,size_t len); +const void *memintern (const void *data,size_t len);static inline const char *strintern (const char *string) {return memintern (string,strlen (string));
help.h +15 -15
@@ -19,31 +19,31 @@ static inline void mput_char(char c, unsigned int num)putchar (c); } -extern void list_common_cmds_help (void ); -extern void list_all_cmds_help (void ); -extern void list_common_guides_help (void ); -extern void list_config_help (int for_human); +void list_common_cmds_help (void ); +void list_all_cmds_help (void ); +void list_common_guides_help (void ); +void list_config_help (int for_human); -extern void list_all_main_cmds (struct string_list *list); -extern void list_all_other_cmds (struct string_list *list); -extern void list_cmds_by_category (struct string_list *list, +void list_all_main_cmds (struct string_list *list); +void list_all_other_cmds (struct string_list *list); +void list_cmds_by_category (struct string_list *list,const char *category); -extern void list_cmds_by_config (struct string_list *list); -extern const char *help_unknown_cmd (const char *cmd); -extern void load_command_list (const char *prefix, +void list_cmds_by_config (struct string_list *list); +const char *help_unknown_cmd (const char *cmd); +void load_command_list (const char *prefix,struct cmdnames *main_cmds,struct cmdnames *other_cmds); -extern void add_cmdname (struct cmdnames *cmds,const char *name,int len); +void add_cmdname (struct cmdnames *cmds,const char *name,int len);/* Here we require that excludes is a sorted list. */ -extern void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); -extern int is_in_cmdlist (struct cmdnames *cmds,const char *name); -extern void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds); +void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes); +int is_in_cmdlist (struct cmdnames *cmds,const char *name); +void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds);/* * call this to die(), when it is suspected that the user mistyped a * ref to the command, to give suggested "correct" refs. */ -extern void help_unknown_ref (const char *ref,const char *cmd,const char *error); +void help_unknown_ref (const char *ref,const char *cmd,const char *error); static inline void list_config_item(struct string_list *list, const char *prefix,
http.h +26 -26
101 lines not on this page · raw message
kwset.h +5 -5
@@ -37,16 +37,16 @@ typedef struct kwset_t* kwset_t;if enough memory cannot be obtained. The argument if non-NULL specifies a table of character translations to be applied to all pattern and search text. */ -extern kwset_t kwsalloc (unsigned char const *); +kwset_t kwsalloc (unsigned char const *);/* Incrementally extend the keyword set to include the given string. Return NULL for success, or an error message. Remember an index number for each keyword included in the set. */ -extern const char *kwsincr (kwset_t ,char const *,size_t ); +const char *kwsincr (kwset_t ,char const *,size_t );/* When the keyword set has been completely built, prepare it for use. Return NULL for success, or an error message. */ -extern const char *kwsprep (kwset_t ); +const char *kwsprep (kwset_t );/* Search through the given buffer for a member of the keyword set. Return a pointer to the leftmost longest match found, or NULL if
@@ -54,8 +54,8 @@ extern const char *kwsprep(kwset_t);the matching substring in the integer it points to. Similarly, if foundindex is non-NULL, store the index of the particular keyword found therein. */ -extern size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *); +size_t kwsexec (kwset_t ,char const *,size_t ,struct kwsmatch *);/* Deallocate the given keyword set and all its associated storage. */ -extern void kwsfree (kwset_t ); +void kwsfree (kwset_t );
line-log.h +8 -8
@@ -25,17 +25,17 @@ struct diff_ranges {struct range_set target; }; -extern void range_set_init (struct range_set *,size_t prealloc); -extern void range_set_release (struct range_set *); +void range_set_init (struct range_set *,size_t prealloc); +void range_set_release (struct range_set *);/* Range includes start; excludes end */ -extern void range_set_append_unsafe (struct range_set *,long start,long end); +void range_set_append_unsafe (struct range_set *,long start,long end);/* New range must begin at or after end of last added range */ -extern void range_set_append (struct range_set *,long start,long end); +void range_set_append (struct range_set *,long start,long end);/* * In-place pass of sorting and merging the ranges in the range set, * to sort and make the ranges disjoint. */ -extern void sort_and_merge_range_set (struct range_set *); +void sort_and_merge_range_set (struct range_set *);/* Linked list of interesting files and their associated ranges. The * list must be kept sorted by path.
@@ -54,10 +54,10 @@ struct line_log_data { struct diff_ranges diff; }; -extern void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); +void line_log_init (struct rev_info *rev,const char *prefix,struct string_list *args); -extern int line_log_filter (struct rev_info *rev); +int line_log_filter (struct rev_info *rev); -extern int line_log_print (struct rev_info *rev,struct commit *commit); +int line_log_print (struct rev_info *rev,struct commit *commit);#endif /* LINE_LOG_H */
lockfile.h +5 -5
@@ -159,7 +159,7 @@ struct lock_file {* timeout_ms is -1, retry indefinitely. The flags argument and error * handling are described above. */ -extern int hold_lock_file_for_update_timeout ( +int hold_lock_file_for_update_timeout (struct lock_file *lk,const char *path,int flags,long timeout_ms);
@@ -188,7 +188,7 @@ static inline int is_lock_file_locked(struct lock_file *lk)* of `hold_lock_file_for_update()` to lock `path`. `err` should be the * `errno` set by the failing call. */ -extern void unable_to_lock_message (const char *path,int err, +void unable_to_lock_message (const char *path,int err,struct strbuf *buf);/*
@@ -197,7 +197,7 @@ extern void unable_to_lock_message(const char *path, int err,* `errno` set by the failing * call. */ -extern NORETURN void unable_to_lock_die(const char *path, int err); +NORETURN void unable_to_lock_die(const char *path, int err);/* * Associate a stdio stream with the lockfile (which must still be
@@ -234,7 +234,7 @@ static inline FILE *get_lock_file_fp(struct lock_file *lk)* Return the path of the file that is locked by the specified * lock_file object. The caller must free the memory. */ -extern char *get_locked_file_path (struct lock_file *lk); +char *get_locked_file_path (struct lock_file *lk);/* * If the lockfile is still open, close it (and the file pointer if it
@@ -282,7 +282,7 @@ static inline int reopen_lock_file(struct lock_file *lk)* call `commit_lock_file()` for a `lock_file` object that is not * currently locked. */ -extern int commit_lock_file (struct lock_file *lk); +int commit_lock_file (struct lock_file *lk);/* * Like `commit_lock_file()`, but rename the lockfile to the provided
ls-refs.h +1 -1
@@ -4,7 +4,7 @@struct repository ;struct argv_array ;struct packet_reader ; -extern int ls_refs (struct repository *r,struct argv_array *keys, +int ls_refs (struct repository *r,struct argv_array *keys,struct packet_reader *request);#endif /* LS_REFS_H */
mailinfo.h +3 -3
@@ -39,8 +39,8 @@ struct mailinfo { int input_error; }; -extern void setup_mailinfo (struct mailinfo *); -extern int mailinfo (struct mailinfo *,const char *msg,const char *patch); -extern void clear_mailinfo (struct mailinfo *); +void setup_mailinfo (struct mailinfo *); +int mailinfo (struct mailinfo *,const char *msg,const char *patch); +void clear_mailinfo (struct mailinfo *);#endif /* MAILINFO_H */
merge-blobs.h +1 -1
@@ -4,7 +4,7 @@struct blob ;struct index_state ; -extern void *merge_blobs (struct index_state *,const char *, +void *merge_blobs (struct index_state *,const char *,struct blob *,struct blob *,struct blob *,unsigned long *);
object-store.h +8 -8
@@ -162,7 +162,7 @@ const char *loose_object_path(struct repository *r, struct strbuf *buf,void *map_loose_object (struct repository *r,const struct object_id *oid,unsigned long *size); -extern void *read_object_file_extended (struct repository *r, +void *read_object_file_extended (struct repository *r,const struct object_id *oid,enum object_type *type,unsigned long *size,int lookup_replace);
@@ -180,20 +180,20 @@ static inline void *repo_read_object_file(struct repository *r,/* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info (struct repository *r,const struct object_id *,unsigned long *); -extern int hash_object_file (const void *buf,unsigned long len, +int hash_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int write_object_file (const void *buf,unsigned long len, +int write_object_file (const void *buf,unsigned long len,const char *type,struct object_id *oid); -extern int hash_object_file_literally (const void *buf,unsigned long len, +int hash_object_file_literally (const void *buf,unsigned long len,const char *type,struct object_id *oid,unsigned flags); -extern int pretend_object_file (void *,unsigned long ,enum object_type , +int pretend_object_file (void *,unsigned long ,enum object_type ,struct object_id *oid); -extern int force_object_loose (const struct object_id *oid,time_t mtime); +int force_object_loose (const struct object_id *oid,time_t mtime);/* * Open the loose object at path, check its hash, and return the contents,
@@ -227,9 +227,9 @@ int repo_has_object_file_with_flags(struct repository *r,* with the specified name. This function does not respect replace * references. */ -extern int has_loose_object_nonlocal (const struct object_id *); +int has_loose_object_nonlocal (const struct object_id *); -extern void assert_oid_type (const struct object_id *oid,enum object_type expect); +void assert_oid_type (const struct object_id *oid,enum object_type expect);struct object_info {/* Request */
object.h +6 -6
@@ -90,19 +90,19 @@ struct object {struct object_id oid; }; -extern const char *type_name (unsigned int type); -extern int type_from_string_gently (const char *str,ssize_t ,int gentle); +const char *type_name (unsigned int type); +int type_from_string_gently (const char *str,ssize_t ,int gentle);#define type_from_string (str) type_from_string_gently(str, -1, 0)/* * Return the current number of buckets in the object hashmap. */ -extern unsigned int get_max_object_index (void ); +unsigned int get_max_object_index (void );/* * Return the object from the specified bucket in the object hashmap. */ -extern struct object *get_indexed_object (unsigned int ); +struct object *get_indexed_object (unsigned int );/* * This can be used to see if we have heard of the object before, but
@@ -118,7 +118,7 @@ extern struct object *get_indexed_object(unsigned int);*/ struct object *lookup_object (struct repository *r,const unsigned char *sha1); -extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj); +void *create_object (struct repository *r,const unsigned char *sha1,void *obj);void *object_as_type (struct repository *r,struct object *obj,enum object_type type,int quiet);
@@ -189,6 +189,6 @@ void clear_object_flags(unsigned flags);/* * Clear the specified object flags from all in-core commit objects. */ -extern void clear_commit_marks_all (unsigned int flags); +void clear_commit_marks_all (unsigned int flags);#endif /* OBJECT_H */
oidmap.h +5 -5
@@ -33,7 +33,7 @@ struct oidmap {* parameter may be used to preallocate a sufficiently large table and thus * prevent expensive resizing. If 0, the table is dynamically resized. */ -extern void oidmap_init (struct oidmap *map,size_t initial_size); +void oidmap_init (struct oidmap *map,size_t initial_size);/* * Frees an oidmap structure and allocated memory.
@@ -41,12 +41,12 @@ extern void oidmap_init(struct oidmap *map, size_t initial_size);* If `free_entries` is true, each oidmap_entry in the map is freed as well * using stdlibs free(). */ -extern void oidmap_free (struct oidmap *map,int free_entries); +void oidmap_free (struct oidmap *map,int free_entries);/* * Returns the oidmap entry for the specified oid, or NULL if not found. */ -extern void *oidmap_get (const struct oidmap *map, +void *oidmap_get (const struct oidmap *map,const struct object_id *key);/*
@@ -57,14 +57,14 @@ extern void *oidmap_get(const struct oidmap *map,* * Returns the replaced entry, or NULL if not found (i.e. the entry was added). */ -extern void *oidmap_put (struct oidmap *map,void *entry); +void *oidmap_put (struct oidmap *map,void *entry);/* * Removes an oidmap entry matching the specified oid. * * Returns the removed entry, or NULL if not found. */ -extern void *oidmap_remove (struct oidmap *map,const struct object_id *key); +void *oidmap_remove (struct oidmap *map,const struct object_id *key);struct oidmap_iter {
pack.h +12 -12
@@ -55,7 +55,7 @@ struct pack_idx_option {uint32_t *anomaly; }; -extern void reset_pack_idx_option (struct pack_idx_option *); +void reset_pack_idx_option (struct pack_idx_option *);/* * Packed object index header
@@ -79,28 +79,28 @@ struct progress;/* Note, the data argument could be NULL if object type is blob */ typedef int (*verify_fn )(const struct object_id *,enum object_type ,unsigned long ,void *,int *); -extern const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); -extern int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); -extern int verify_pack_index (struct packed_git *); -extern int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); -extern off_t write_pack_header (struct hashfile *f,uint32_t ); -extern void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); -extern char *index_pack_lockfile (int fd); +const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1); +int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr); +int verify_pack_index (struct packed_git *); +int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t ); +off_t write_pack_header (struct hashfile *f,uint32_t ); +void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t ); +char *index_pack_lockfile (int fd);/* * The "hdr" output buffer should be at least this big, which will handle sizes * up to 2^67. */ #define MAX_PACK_OBJECT_HEADER 10 -extern int encode_in_pack_object_header (unsigned char *hdr,int hdr_len, +int encode_in_pack_object_header (unsigned char *hdr,int hdr_len,enum object_type ,uintmax_t );#define PH_ERROR_EOF (-1)#define PH_ERROR_PACK_SIGNATURE (-2)#define PH_ERROR_PROTOCOL (-3) -extern int read_pack_header (int fd,struct pack_header *); +int read_pack_header (int fd,struct pack_header *); -extern struct hashfile *create_tmp_packfile (char **pack_tmp_name); -extern void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]); +struct hashfile *create_tmp_packfile (char **pack_tmp_name); +void finish_tmp_packfile (struct strbuf *name_buffer,const char *pack_tmp_name,struct pack_idx_entry **written_list,uint32_t nr_written,struct pack_idx_option *pack_idx_opts,unsigned char sha1[]);#endif
packfile.h +37 -37
175 lines not on this page · raw message
path.h +1 -1
@@ -143,7 +143,7 @@ extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path, const char *fmt, ...) __attribute__((format (printf, 3, 4))); -extern void report_linked_checkout_garbage (void ); +void report_linked_checkout_garbage (void );/* * You can define a static memoized git path like:
pkt-line.h +3 -3
@@ -172,7 +172,7 @@ struct packet_reader {* Initialize a 'struct packet_reader' object which is an * abstraction around the 'packet_read_with_status()' function. */ -extern void packet_reader_init (struct packet_reader *reader,int fd, +void packet_reader_init (struct packet_reader *reader,int fd,char *src_buffer,size_t src_len,int options);
@@ -186,7 +186,7 @@ extern void packet_reader_init(struct packet_reader *reader, int fd,* 'line' is set to point at the read line * PACKET_READ_FLUSH: 'pktlen' is set to '0' and 'line' is set to NULL */ -extern enum packet_read_status packet_reader_read (struct packet_reader *reader); +enum packet_read_status packet_reader_read (struct packet_reader *reader);/* * Peek the next packet line without consuming it and return the status.
@@ -196,7 +196,7 @@ extern enum packet_read_status packet_reader_read(struct packet_reader *reader);* Peeking multiple times without calling 'packet_reader_read()' will return * the same result. */ -extern enum packet_read_status packet_reader_peek (struct packet_reader *reader); +enum packet_read_status packet_reader_peek (struct packet_reader *reader);#define DEFAULT_PACKET_MAX 1000#define LARGE_PACKET_MAX 65520
ppc/sha1.c +1 -1
@@ -10,7 +10,7 @@#include <string.h> #include "sha1.h" -extern void ppc_sha1_core (uint32_t *hash,const unsigned char *p, +void ppc_sha1_core (uint32_t *hash,const unsigned char *p,unsigned int nblocks);int ppc_SHA1_Init (ppc_SHA_CTX *c)
prio-queue.h +5 -5
@@ -37,24 +37,24 @@ struct prio_queue {/* * Add the "thing" to the queue. */ -extern void prio_queue_put (struct prio_queue *,void *thing); +void prio_queue_put (struct prio_queue *,void *thing);/* * Extract the "thing" that compares the smallest out of the queue, * or NULL. If compare function is NULL, the queue acts as a LIFO * stack. */ -extern void *prio_queue_get (struct prio_queue *); +void *prio_queue_get (struct prio_queue *);/* * Gain access to the "thing" that would be returned by * prio_queue_get, but do not remove it from the queue. */ -extern void *prio_queue_peek (struct prio_queue *); +void *prio_queue_peek (struct prio_queue *); -extern void clear_prio_queue (struct prio_queue *); +void clear_prio_queue (struct prio_queue *);/* Reverse the LIFO elements */ -extern void prio_queue_reverse (struct prio_queue *); +void prio_queue_reverse (struct prio_queue *);#endif /* PRIO_QUEUE_H */
protocol.h +3 -3
@@ -14,7 +14,7 @@ enum protocol_version {* 'protocol.version' config. If unconfigured, a value of 'protocol_v0' is * returned. */ -extern enum protocol_version get_protocol_version_config (void ); +enum protocol_version get_protocol_version_config (void );/* * Used by a server to determine which protocol version should be used based on
@@ -23,12 +23,12 @@ extern enum protocol_version get_protocol_version_config(void);* request a particular protocol version, a default of 'protocol_v0' will be * used. */ -extern enum protocol_version determine_protocol_version_server (void ); +enum protocol_version determine_protocol_version_server (void );/* * Used by a client to determine which protocol version the server is speaking * based on the server's initial response. */ -extern enum protocol_version determine_protocol_version_client (const char *server_response); +enum protocol_version determine_protocol_version_client (const char *server_response);#endif /* PROTOCOL_H */
quote.h +15 -15
@@ -29,8 +29,8 @@ struct strbuf;* sq_quotef() quotes the entire formatted string as a single result. */ -extern void sq_quote_buf (struct strbuf *,const char *src); -extern void sq_quote_argv (struct strbuf *,const char **argv); +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, ...);/*
@@ -45,14 +45,14 @@ void sq_quote_argv_pretty(struct strbuf *, const char **argv);* NULL if the input does not look like what sq_quote would have * produced. */ -extern char *sq_dequote (char *); +char *sq_dequote (char *);/* * Same as the above, but can be used to unwrap many arguments in the * same string separated by space. Like sq_quote, it works in place, * modifying arg and appending pointers into it to argv. */ -extern int sq_dequote_to_argv (char *arg,const char ***argv,int *nr,int *alloc); +int sq_dequote_to_argv (char *arg,const char ***argv,int *nr,int *alloc);/* * Same as above, but store the unquoted strings in an argv_array. We will
@@ -60,24 +60,24 @@ extern int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc* will duplicate and take ownership of the strings. */ struct argv_array ; -extern int sq_dequote_to_argv_array (char *arg,struct argv_array *); +int sq_dequote_to_argv_array (char *arg,struct argv_array *); -extern int unquote_c_style (struct strbuf *,const char *quoted,const char **endp); -extern size_t quote_c_style (const char *name,struct strbuf *,FILE *,int no_dq); -extern void quote_two_c_style (struct strbuf *,const char *,const char *,int ); +int unquote_c_style (struct strbuf *,const char *quoted,const char **endp); +size_t quote_c_style (const char *name,struct strbuf *,FILE *,int no_dq); +void quote_two_c_style (struct strbuf *,const char *,const char *,int ); -extern void write_name_quoted (const char *name,FILE *,int terminator); -extern void write_name_quoted_relative (const char *name,const char *prefix, +void write_name_quoted (const char *name,FILE *,int terminator); +void write_name_quoted_relative (const char *name,const char *prefix,FILE *fp,int terminator);/* quote path as relative to the given prefix */ -extern char *quote_path_relative (const char *in,const char *prefix, +char *quote_path_relative (const char *in,const char *prefix,struct strbuf *out);
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.1000.g7817e26e80
Part of the diff is not shown here. View the raw message.
PATCH v4 2/4 *.[ch]: remove extern from function declarations using sed
In reply to Denton LiuThere 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.
--- cache.h | 4 ++-- commit.h | 2 +- config.h | 2 +- exec-cmd.h | 2 +- git-compat-util.h | 20 ++++++++++---------- khash.h | 14 +++++++------- path.h | 30 +++++++++++++++--------------- quote.h | 2 +- run-command.h | 2 +- trace.h | 18 +++++++++--------- worktree.h | 2 +- 11 files changed, 49 insertions(+), 49 deletions(-)
cache.h +2 -2
@@ -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)
@@ -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 );
commit.h +1 -1
@@ -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 */
config.h +1 -1
@@ -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) \
exec-cmd.h +1 -1
@@ -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 */
git-compat-util.h +10 -10
@@ -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
@@ -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
@@ -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);
@@ -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
khash.h +7 -7
@@ -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) { \
path.h +15 -15
@@ -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 )));/*
@@ -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 )));
@@ -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 )));
@@ -66,7 +66,7 @@ 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 )));
@@ -74,7 +74,7 @@ extern char *repo_git_path(const struct repository *repo,* 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 )));
@@ -83,13 +83,13 @@ 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 )));/*
@@ -97,14 +97,14 @@ extern char *git_pathdup(const char *fmt, ...)* 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 )));/*
@@ -112,7 +112,7 @@ extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)* * 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 )));
@@ -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 )));
@@ -131,7 +131,7 @@ 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 )));/*
@@ -139,7 +139,7 @@ extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)* 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 )));
quote.h +1 -1
@@ -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
run-command.h +1 -1
@@ -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
trace.h +9 -9
@@ -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, ...);
@@ -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) {
worktree.h +1 -1
@@ -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 )));
Signature · 1 line
2.21.0.1000.g7817e26e80
Re: [PATCH v4 2/4] *.[ch]: remove extern from function declarations using sed
Quoted 8 lines · Denton Liu
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/ | \
Lose the backslash. Your shell knows its own syntax sufficiently well, and when you end a line with a pipe, it knows that you haven't finished speaking to it and waits for you to give the command downstream of the pipe, without being told that you haven't finished with a backslash.
Re: [PATCH v4 2/4] *.[ch]: remove extern from function declarations using sed
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Denton Liu
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:
Quoted 8 lines
Quoted 2 lines
$ git ls-files \*.{c,h} | \ grep -v ^compat/ | \Lose the backslash. Your shell knows its own syntax sufficiently well, and when you end a line with a pipe, it knows that you haven't finished speaking to it and waits for you to give the command downstream of the pipe, without being told that you haven't finished with a backslash.
Thanks. Could you please make this change for me in 1/4 and 2/4 in case this patchset doesn't get another reroll?