From ba8383efd8b1fded117f2587c78c40b28fe4e016 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 1 May 2016 15:52:58 -0400 Subject: [PATCH] Fixes for enhanced GCC warnings. Move function prototypes into header files and out of .c files. Use void argument lists for functions that accept no args. Remove unused macros. Make private functions static. Align types with printf format characters. --- ar.c | 8 ++++---- arscan.c | 7 ++++--- commands.c | 2 -- commands.h | 1 + dir.c | 4 ++-- file.c | 3 --- filedef.h | 5 ++++- function.c | 7 ++++--- job.c | 10 ++-------- main.c | 19 +++---------------- makeint.h | 43 +++++++++++++++++++++++++++++++------------ os.h | 18 +++++++++--------- output.c | 6 +++--- posixos.c | 16 ++++++++-------- read.c | 6 ------ remake.c | 4 +--- rule.h | 1 + variable.c | 6 ++---- variable.h | 2 +- vpath.c | 2 +- 20 files changed, 81 insertions(+), 89 deletions(-) diff --git a/ar.c b/ar.c index 85e91c84..b9c1cf72 100644 --- a/ar.c +++ b/ar.c @@ -73,7 +73,7 @@ static long int ar_member_date_1 (int desc UNUSED, const char *mem, int truncated, long int hdrpos UNUSED, long int datapos UNUSED, long int size UNUSED, long int date, - int uid UNUSED, int gid UNUSED, int mode UNUSED, + int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED, const void *name) { return ar_name_equal (name, mem, truncated) ? date : 0; @@ -198,7 +198,7 @@ static long int ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, long int hdrpos UNUSED, long int datapos UNUSED, long int size UNUSED, long int date UNUSED, int uid UNUSED, - int gid UNUSED, int mode UNUSED, const void *arg) + int gid UNUSED, unsigned int mode UNUSED, const void *arg) { struct ar_glob_state *state = (struct ar_glob_state *)arg; @@ -224,7 +224,7 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ static int -glob_pattern_p (const char *pattern, int quote) +ar_glob_pattern_p (const char *pattern, int quote) { const char *p; int opened = 0; @@ -267,7 +267,7 @@ ar_glob (const char *arname, const char *member_pattern, unsigned int size) #ifdef VMS char *vms_member_pattern; #endif - if (! glob_pattern_p (member_pattern, 1)) + if (! ar_glob_pattern_p (member_pattern, 1)) return 0; /* Scan the archive for matches. diff --git a/arscan.c b/arscan.c index d35686dd..549fe1ec 100644 --- a/arscan.c +++ b/arscan.c @@ -547,7 +547,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg) int long_name = 0; #endif long int eltsize; - int eltmode; + unsigned int eltmode; long int fnval; off_t o; @@ -872,7 +872,7 @@ static long int ar_member_pos (int desc UNUSED, const char *mem, int truncated, long int hdrpos, long int datapos UNUSED, long int size UNUSED, long int date UNUSED, int uid UNUSED, int gid UNUSED, - int mode UNUSED, const void *name) + unsigned int mode UNUSED, const void *name) { if (!ar_name_equal (name, mem, truncated)) return 0; @@ -957,7 +957,8 @@ ar_member_touch (const char *arname, const char *memname) long int describe_member (int desc, const char *name, int truncated, long int hdrpos, long int datapos, long int size, - long int date, int uid, int gid, int mode, const void *arg) + long int date, int uid, int gid, unsigned int mode, + const void *arg) { extern char *ctime (); diff --git a/commands.c b/commands.c index 4303b86d..124b93e3 100644 --- a/commands.c +++ b/commands.c @@ -31,8 +31,6 @@ this program. If not, see . */ # define FILE_LIST_SEPARATOR ' ' #endif -int remote_kill (int id, int sig); - #ifndef HAVE_UNISTD_H int getpid (); #endif diff --git a/commands.h b/commands.h index db95fb2f..f7cf0640 100644 --- a/commands.h +++ b/commands.h @@ -34,6 +34,7 @@ struct commands #define COMMANDS_SILENT 2 /* Silent: @. */ #define COMMANDS_NOERROR 4 /* No errors: -. */ +RETSIGTYPE fatal_error_signal (int sig); void execute_file_commands (struct file *file); void print_commands (const struct commands *cmds); void delete_child_targets (struct child *child); diff --git a/dir.c b/dir.c index a286d2ea..63c82a03 100644 --- a/dir.c +++ b/dir.c @@ -1169,8 +1169,6 @@ print_dir_data_base (void) /* Hooks for globbing. */ -#include - /* Structure describing state of iterating through a directory hash table. */ struct dirstream @@ -1263,7 +1261,9 @@ read_dirstream (__ptr_t stream) */ #if !defined(stat) && !defined(WINDOWS32) || defined(VMS) # ifndef VMS +# ifndef HAVE_SYS_STAT_H int stat (const char *path, struct stat *sbuf); +# endif # else /* We are done with the fake stat. Go back to the real stat */ # ifdef stat diff --git a/file.c b/file.c index 2207be45..ae1c2857 100644 --- a/file.c +++ b/file.c @@ -57,9 +57,6 @@ file_hash_cmp (const void *x, const void *y) ((struct file const *) y)->hname); } -#ifndef FILE_BUCKETS -#define FILE_BUCKETS 1007 -#endif static struct hash_table files; /* Whether or not .SECONDARY with no prerequisites was given. */ diff --git a/filedef.h b/filedef.h index b280fb8a..507a0279 100644 --- a/filedef.h +++ b/filedef.h @@ -103,7 +103,7 @@ struct file }; -extern struct file *suffix_file, *default_file; +extern struct file *default_file; struct file *lookup_file (const char *name); @@ -117,9 +117,12 @@ void rehash_file (struct file *file, const char *name); void set_command_state (struct file *file, enum cmd_state state); void notice_finished_file (struct file *file); void init_hash_files (void); +void verify_file_data_base (void); char *build_target_list (char *old_list); void print_prereqs (const struct dep *deps); void print_file_data_base (void); +int try_implicit_rule (struct file *file, unsigned int depth); +int stemlen_compare (const void *v1, const void *v2); #if FILE_TIMESTAMP_HI_RES # define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \ diff --git a/function.c b/function.c index b8e69b22..c9fcec2c 100644 --- a/function.c +++ b/function.c @@ -627,6 +627,7 @@ func_basename_dir (char *o, char **argv, const char *funcname) else if (is_dir) #ifdef VMS { + extern int vms_report_unix_paths; if (vms_report_unix_paths) o = variable_buffer_output (o, "./", 2); else @@ -1975,7 +1976,7 @@ func_shell_base (char *o, char **argv, int trim_newlines) } #endif /* _AMIGA */ -char * +static char * func_shell (char *o, char **argv, const char *funcname UNUSED) { return func_shell_base (o, argv, 1); @@ -2653,10 +2654,10 @@ define_new_function (const gmk_floc *flocp, const char *name, OS (fatal, flocp, _("Function name too long: %s"), name); if (min > 255) ONS (fatal, flocp, - _("Invalid minimum argument count (%d) for function %s"), min, name); + _("Invalid minimum argument count (%u) for function %s"), min, name); if (max > 255 || (max && max < min)) ONS (fatal, flocp, - _("Invalid maximum argument count (%d) for function %s"), max, name); + _("Invalid maximum argument count (%u) for function %s"), max, name); ent = xmalloc (sizeof (struct function_table_entry)); ent->name = name; diff --git a/job.c b/job.c index 2d2c8037..ddac6c41 100644 --- a/job.c +++ b/job.c @@ -24,7 +24,6 @@ this program. If not, see . */ #include "commands.h" #include "variable.h" #include "os.h" -#include "debug.h" #include @@ -208,14 +207,10 @@ pid2str (pid_t pid) return pidstring; } +#ifndef HAVE_GETLOADAVG int getloadavg (double loadavg[], int nelem); -int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote, - int *id_ptr, int *used_stdin); -int start_remote_job_p (int); -int remote_status (int *exit_code_ptr, int *signal_ptr, int *coredump_ptr, - int block); +#endif -RETSIGTYPE child_handler (int); static void free_child (struct child *); static void start_job_command (struct child *child); static int load_too_high (void); @@ -2285,7 +2280,6 @@ exec_command (char **argv, char **envp) case ENOEXEC: { /* The file is not executable. Try it as a shell script. */ - extern char *getenv (); const char *shell; char **new_argv; int argc; diff --git a/main.c b/main.c index c812ba4a..576f2e96 100644 --- a/main.c +++ b/main.c @@ -84,18 +84,6 @@ char x; } #endif -void init_dir (void); -void remote_setup (void); -void remote_cleanup (void); -RETSIGTYPE fatal_error_signal (int sig); - -void print_variable_data_base (void); -void print_dir_data_base (void); -void print_rule_data_base (void); -void print_vpath_data_base (void); - -void verify_file_data_base (void); - #if defined HAVE_WAITPID || defined HAVE_WAIT3 # define HAVE_WAIT_NOHANG #endif @@ -645,7 +633,7 @@ initialize_global_hash_tables (void) Each element is true if we should stop parsing on that character. */ static void -initialize_stopchar_map () +initialize_stopchar_map (void) { int i; @@ -1063,7 +1051,7 @@ msdos_return_to_initial_directory (void) #endif /* __MSDOS__ */ static void -reset_jobserver () +reset_jobserver (void) { jobserver_clear (); free (jobserver_auth); @@ -1895,7 +1883,6 @@ main (int argc, char **argv, char **envp) If none of these are true, we don't need a signal handler at all. */ { - RETSIGTYPE child_handler (int sig); # if defined SIGCHLD bsd_signal (SIGCHLD, child_handler); # endif @@ -3369,7 +3356,7 @@ print_version (void) /* Print a bunch of information about this and that. */ static void -print_data_base () +print_data_base (void) { time_t when = time ((time_t *) 0); diff --git a/makeint.h b/makeint.h index 0ee5acc3..ad0a511e 100644 --- a/makeint.h +++ b/makeint.h @@ -450,6 +450,8 @@ extern int unixy_shell; extern struct rlimit stack_limit; #endif +#include + #define NILF ((gmk_floc *)0) #define CSTRLEN(_s) (sizeof (_s)-1) @@ -518,7 +520,8 @@ time_t ar_member_date (const char *); typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated, long int hdrpos, long int datapos, long int size, long int date, int uid, - int gid, int mode, const void *arg); + int gid, unsigned int mode, + const void *arg); long int ar_scan (const char *archive, ar_member_func_t function, const void *arg); int ar_name_equal (const char *name, const char *mem, int truncated); @@ -532,6 +535,8 @@ int file_exists_p (const char *); int file_impossible_p (const char *); void file_impossible (const char *); const char *dir_name (const char *); +void print_dir_data_base (void); +void dir_setup_glob (glob_t *); void hash_init_directories (void); void define_default_variables (void); @@ -554,7 +559,7 @@ void child_access (void); char *strip_whitespace (const char **begpp, const char **endpp); -void show_goal_error (); +void show_goal_error (void); /* String caching */ void strcache_init (void); @@ -581,16 +586,16 @@ long int atol (); long int lseek (); # endif -#endif /* Not GNU C library or POSIX. */ - -#ifdef HAVE_GETCWD -# if !defined(VMS) && !defined(__DECC) +# ifdef HAVE_GETCWD +# if !defined(VMS) && !defined(__DECC) char *getcwd (); -# endif -#else +# endif +# else char *getwd (); -# define getcwd(buf, len) getwd (buf) -#endif +# define getcwd(buf, len) getwd (buf) +# endif + +#endif /* Not GNU C library or POSIX. */ #if !HAVE_STRCASECMP # if HAVE_STRICMP @@ -619,11 +624,12 @@ int strncasecmp (const char *s1, const char *s2, int n); #define OUTPUT_SYNC_TARGET 2 #define OUTPUT_SYNC_RECURSE 3 +/* Non-GNU systems may not declare this in unistd.h. */ +extern char **environ; + extern const gmk_floc *reading_file; extern const gmk_floc **expanding_var; -extern char **environ; - extern unsigned short stopchar_map[]; extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag; @@ -634,6 +640,8 @@ extern int warn_undefined_variables_flag, trace_flag, posix_pedantic; extern int not_parallel, second_expansion, clock_skew_detected; extern int rebuilding_makefiles, one_shell, output_sync, verify_flag; +extern const char *default_shell; + /* can we run commands via 'sh -c xxx' or must we use batch files? */ extern int batch_mode_shell; @@ -685,6 +693,17 @@ vms_restore_symbol (const char *string); #endif +void remote_setup (void); +void remote_cleanup (void); +int start_remote_job_p (int); +int start_remote_job (char **, char **, int, int *, int *, int *); +int remote_status (int *, int *, int *, int); +void block_remote_children (void); +void unblock_remote_children (void); +int remote_kill (int id, int sig); +void print_variable_data_base (void); +void print_vpath_data_base (void); + extern char *starting_directory; extern unsigned int makelevel; extern char *version_string, *remote_description, *make_host; diff --git a/os.h b/os.h index ac5350b1..c1a19e1b 100644 --- a/os.h +++ b/os.h @@ -20,7 +20,7 @@ this program. If not, see . */ #ifdef MAKE_JOBSERVER /* Returns 1 if the jobserver is enabled, else 0. */ -unsigned int jobserver_enabled (); +unsigned int jobserver_enabled (void); /* Called in the master instance to set up the jobserver initially. */ unsigned int jobserver_setup (int job_slots); @@ -29,28 +29,28 @@ unsigned int jobserver_setup (int job_slots); unsigned int jobserver_parse_auth (const char* auth); /* Returns an allocated buffer used to pass to child instances. */ -char *jobserver_get_auth (); +char *jobserver_get_auth (void); /* Clear this instance's jobserver configuration. */ -void jobserver_clear (); +void jobserver_clear (void); /* Recover all the jobserver tokens and return the number we got. */ -unsigned int jobserver_acquire_all (); +unsigned int jobserver_acquire_all (void); /* Release a jobserver token. If it fails and is_fatal is 1, fatal. */ void jobserver_release (int is_fatal); /* Notify the jobserver that a child exited. */ -void jobserver_signal (); +void jobserver_signal (void); /* Get ready to start a non-recursive child. */ -void jobserver_pre_child (); +void jobserver_pre_child (int); /* Complete starting a non-recursive child. */ -void jobserver_post_child (); +void jobserver_post_child (int); /* Set up to acquire a new token. */ -void jobserver_pre_acquire (); +void jobserver_pre_acquire (void); /* Wait until we can acquire a jobserver token. TIMEOUT is 1 if we have other jobs waiting for the load to go down; @@ -78,7 +78,7 @@ unsigned int jobserver_acquire (int timeout); /* Create a "bad" file descriptor for stdin when parallel jobs are run. */ #if !defined(VMD) && !defined(WINDOWS32) && !defined(_AMIGA) && !defined(__MSDOS__) -int get_bad_stdin (); +int get_bad_stdin (void); #else # define get_bad_stdin() (-1) #endif diff --git a/output.c b/output.c index 475862f0..0a0420c6 100644 --- a/output.c +++ b/output.c @@ -174,7 +174,7 @@ static sync_handle_t sync_handle = -1; /* Set up the sync handle. Disables output_sync on error. */ static int -sync_init () +sync_init (void) { int combined_output = 0; @@ -283,7 +283,7 @@ release_semaphore (void *sem) /* Returns a file descriptor to a temporary file. The file is automatically closed/deleted on exit. Don't use a FILE* stream. */ int -output_tmpfd () +output_tmpfd (void) { int fd = -1; FILE *tfile = tmpfile (); @@ -558,7 +558,7 @@ output_close (struct output *out) /* We're about to generate output: be sure it's set up. */ void -output_start () +output_start (void) { #ifndef NO_OUTPUT_SYNC /* If we're syncing output make sure the temporary file is set up. */ diff --git a/posixos.c b/posixos.c index 4a88b3cf..4a787e4d 100644 --- a/posixos.c +++ b/posixos.c @@ -45,7 +45,7 @@ static int job_rfd = -1; static char token = '+'; static int -make_job_rfd () +make_job_rfd (void) { #ifdef HAVE_PSELECT /* Pretend we succeeded. */ @@ -117,7 +117,7 @@ jobserver_parse_auth (const char *auth) } char * -jobserver_get_auth () +jobserver_get_auth (void) { char *auth = xmalloc ((INTSTR_LENGTH * 2) + 2); sprintf (auth, "%d,%d", job_fds[0], job_fds[1]); @@ -125,13 +125,13 @@ jobserver_get_auth () } unsigned int -jobserver_enabled () +jobserver_enabled (void) { return job_fds[0] >= 0; } void -jobserver_clear () +jobserver_clear (void) { if (job_fds[0] >= 0) close (job_fds[0]); @@ -157,7 +157,7 @@ jobserver_release (int is_fatal) } unsigned int -jobserver_acquire_all () +jobserver_acquire_all (void) { unsigned int tokens = 0; @@ -210,7 +210,7 @@ jobserver_post_child (int recursive) } void -jobserver_signal () +jobserver_signal (void) { if (job_rfd >= 0) { @@ -220,7 +220,7 @@ jobserver_signal () } void -jobserver_pre_acquire () +jobserver_pre_acquire (void) { /* Make sure we have a dup'd FD. */ if (job_rfd < 0 && job_fds[0] >= 0 && make_job_rfd () < 0) @@ -402,7 +402,7 @@ jobserver_acquire (int timeout) /* Create a "bad" file descriptor for stdin when parallel jobs are run. */ int -get_bad_stdin () +get_bad_stdin (void) { static int bad_stdin = -1; diff --git a/read.c b/read.c index a71eaebe..c6eb5c88 100644 --- a/read.c +++ b/read.c @@ -18,8 +18,6 @@ this program. If not, see . */ #include -#include - #include "filedef.h" #include "dep.h" #include "job.h" @@ -2920,7 +2918,6 @@ tilde_expand (const char *name) #ifndef VMS if (name[1] == '/' || name[1] == '\0') { - extern char *getenv (); char *home_dir; int is_variable; @@ -2943,7 +2940,6 @@ tilde_expand (const char *name) # if !defined(_AMIGA) && !defined(WINDOWS32) if (home_dir == 0 || home_dir[0] == '\0') { - extern char *getlogin (); char *logname = getlogin (); home_dir = 0; if (logname != 0) @@ -3008,8 +3004,6 @@ tilde_expand (const char *name) PARSEFS_NOCACHE - Do not add filenames to the strcache (caller frees) */ -void dir_setup_glob (glob_t *glob); - void * parse_file_seq (char **stringp, unsigned int size, int stopmap, const char *prefix, int flags) diff --git a/remake.c b/remake.c index c837903e..63ee6485 100644 --- a/remake.c +++ b/remake.c @@ -37,8 +37,6 @@ this program. If not, see . */ #include #endif -extern int try_implicit_rule (struct file *file, unsigned int depth); - /* The test for circular dependencies is based on the 'updating' bit in 'struct file'. However, double colon targets have separate 'struct @@ -269,7 +267,7 @@ update_goal_chain (struct goaldep *goaldeps) about errors, show an error message the first time. */ void -show_goal_error () +show_goal_error (void) { struct goaldep *goal; diff --git a/rule.h b/rule.h index 72ff2e99..9156b8e6 100644 --- a/rule.h +++ b/rule.h @@ -55,3 +55,4 @@ void install_pattern_rule (struct pspec *p, int terminal); void create_pattern_rule (const char **targets, const char **target_percents, unsigned int num, int terminal, struct dep *deps, struct commands *commands, int override); +void print_rule_data_base (void); diff --git a/variable.c b/variable.c index 9c932d4d..26baabd4 100644 --- a/variable.c +++ b/variable.c @@ -822,7 +822,6 @@ merge_variable_set_lists (struct variable_set_list **setlist0, void define_automatic_variables (void) { - extern const char* default_shell; struct variable *v; char buf[200]; @@ -1049,7 +1048,6 @@ target_environment (struct file *file) /* If this is the SHELL variable and it's not exported, then add the value from our original environment, if the original environment defined a value for SHELL. */ - extern struct variable shell_var; if (streq (v->name, "SHELL") && shell_var.value) { v = &shell_var; @@ -1136,7 +1134,7 @@ set_special_var (struct variable *var) * result. This removes only ONE newline (if any) at the end, for maximum * compatibility with the *BSD makes. If it fails, returns NULL. */ -char * +static char * shell_result (const char *p) { char *buf; @@ -1739,7 +1737,7 @@ print_variable_data_base (void) { struct pattern_var *p; - int rules = 0; + unsigned int rules = 0; for (p = pattern_vars; p != 0; p = p->next) { diff --git a/variable.h b/variable.h index 75d4c0b6..583a65f4 100644 --- a/variable.h +++ b/variable.h @@ -110,6 +110,7 @@ struct pattern_var extern char *variable_buffer; extern struct variable_set_list *current_variable_set_list; extern struct variable *default_goal_var; +extern struct variable shell_var; /* expand.c */ char *variable_buffer_output (char *ptr, const char *string, unsigned int length); @@ -148,7 +149,6 @@ void pop_variable_scope (void); void define_automatic_variables (void); void initialize_file_variables (struct file *file, int reading); void print_file_variables (const struct file *file); -void print_file_variables (const struct file *file); void print_target_variables (const struct file *file); void merge_variable_set_lists (struct variable_set_list **to_list, struct variable_set_list *from_list); diff --git a/vpath.c b/vpath.c index 2f1dafd5..0c7dce35 100644 --- a/vpath.c +++ b/vpath.c @@ -52,7 +52,7 @@ static struct vpath *gpaths; variable. */ void -build_vpath_lists () +build_vpath_lists (void) { register struct vpath *new = 0; register struct vpath *old, *nexto;