From 6c03949644d77f1780689dfa5e79e69bad3f78f1 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 12 May 2014 23:17:14 +0200 Subject: [PATCH] Fix warnings when building jam. Sorry for the included whitespace cleanup. --- jam/execunix.c | 26 ++++++++++++++---------- jam/hcache.c | 54 +++++++++++++++++++++++++------------------------- jam/pathunix.c | 20 +++++++++---------- 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/jam/execunix.c b/jam/execunix.c index 3795c001f6..62176d3b8c 100644 --- a/jam/execunix.c +++ b/jam/execunix.c @@ -15,7 +15,7 @@ * * Each word must be an individual element in a jam variable value. * - * In $(JAMSHELL), % expands to the command string and ! expands to + * In $(JAMSHELL), % expands to the command string and ! expands to * the slot number (starting at 1) for multiprocess (-j) invocations. * If $(JAMSHELL) doesn't include a %, it is tacked on as the last * argument. @@ -50,13 +50,17 @@ # include # endif -# ifdef OS_NT +# ifdef unix +# include +# endif + +# ifdef OS_NT # define USE_EXECNT # include # define WIN32_LEAN_AND_MEAN # include /* do the ugly deed */ # define USE_MYWAIT -# if !defined( __BORLANDC__ ) +# if !defined( __BORLANDC__ ) # define wait my_wait static int my_wait( int *status ); # endif @@ -94,7 +98,7 @@ onintr( int disp ) */ void -execcmd( +execcmd( char *string, void (*func)( void *closure, int status ), void *closure, @@ -133,7 +137,7 @@ execcmd( cmdtab[ slot ].tempfile = malloc( strlen( tempdir ) + 32 ); - sprintf( cmdtab[ slot ].tempfile, "%s\\jam%dt%d.bat", + sprintf( cmdtab[ slot ].tempfile, "%s\\jam%dt%d.bat", tempdir, GetCurrentProcessId(), slot ); } @@ -223,15 +227,15 @@ execcmd( } # else # ifdef NO_VFORK - if ((pid = fork()) == 0) + if ((pid = fork()) == 0) { execvp( argv[0], argv ); _exit(127); } # else - if ((pid = vfork()) == 0) + if ((pid = vfork()) == 0) { - execvp( argv[0], argv ); + execvp( argv[0], (char* const*)argv ); _exit(127); } # endif @@ -272,10 +276,10 @@ execwait() if( !cmdsrunning ) return 0; - do + do { /* Pick up process pid and status */ - + while( ( w = wait( &status ) ) == -1 && errno == EINTR ) ; @@ -377,7 +381,7 @@ my_wait( int *status ) FAILED: errno = GetLastError(); return -1; - + } # endif /* USE_MYWAIT */ diff --git a/jam/hcache.c b/jam/hcache.c index 9e846a70aa..fec4f2c7ef 100644 --- a/jam/hcache.c +++ b/jam/hcache.c @@ -35,14 +35,14 @@ * hcache_init() - read and parse the local .jamdeps file. * hcache_done() - write a new .jamdeps file * hcache() - return list of headers on target. Use cache or do a scan. - * + * * The dependency file format is an ascii file with 1 line per target. * Each line has the following fields: * @boundname@ timestamp @file@ @file@ @file@ ... \n * */ struct hcachedata { - char *boundname; + const char *boundname; time_t time; LIST *includes; LIST *hdrscan; /* the HDRSCAN value for this target */ @@ -54,7 +54,7 @@ typedef struct hcachedata HCACHEDATA ; static struct hash *hcachehash = 0; -static HCACHEDATA *hcachelist = 0; +static HCACHEDATA *hcachelist = 0; static int queries = 0; static int hits = 0; @@ -70,10 +70,10 @@ static int hits = 0; * We cache the result so the user can't change the cache file during * header scanning. */ -static char* +static const char* cache_name(void) { - static char* name = 0; + static const char* name = 0; if (!name) { LIST *hcachevar = var_get("HCACHEFILE"); @@ -116,7 +116,7 @@ cache_maxage(void) * ASCII 0. The returned value is as returned by newstr(), so it need * not be freed. */ -char* +const char* read_netstring(FILE* f) { unsigned long len; @@ -168,10 +168,10 @@ void hcache_init() { HCACHEDATA cachedata, *c; - FILE *f; - char *version; - int header_count = 0; - char* hcachename; + FILE *f; + const char *version; + int header_count = 0; + const char* hcachename; hcachehash = hashinit (sizeof (HCACHEDATA), "hcache"); @@ -180,7 +180,7 @@ hcache_init() if (! (f = fopen (hcachename, "rb" ))) return; - + version = read_netstring(f); if (!version || strcmp(version, CACHE_FILE_VERSION)) { fclose(f); @@ -189,11 +189,11 @@ hcache_init() while (1) { - char* record_type; - char *time_str; - char *age_str; - char *includes_count_str; - char *hdrscan_count_str; + const char* record_type; + const char *time_str; + const char *age_str; + const char *includes_count_str; + const char *hdrscan_count_str; int i, count; LIST *l; @@ -210,14 +210,14 @@ hcache_init() hcachename, record_type ? record_type : ""); goto bail; } - + c = &cachedata; - + c->boundname = read_netstring(f); time_str = read_netstring(f); age_str = read_netstring(f); includes_count_str = read_netstring(f); - + if (!c->boundname || !time_str || !age_str || !includes_count_str) { @@ -230,7 +230,7 @@ hcache_init() count = atoi(includes_count_str); for (l = 0, i = 0; i < count; i++) { - char* s = read_netstring(f); + const char* s = read_netstring(f); if (!s) { fprintf(stderr, "invalid %s\n", hcachename); goto bail; @@ -248,7 +248,7 @@ hcache_init() count = atoi(hdrscan_count_str); for (l = 0, i = 0; i < count; i++) { - char* s = read_netstring(f); + const char* s = read_netstring(f); if (!s) { fprintf(stderr, "invalid %s\n", hcachename); goto bail; @@ -272,7 +272,7 @@ hcache_init() if (DEBUG_HEADER) { printf("hcache read from file %s\n", hcachename); } - + bail: fclose(f); } @@ -280,12 +280,12 @@ hcache_init() void hcache_done() { - FILE *f; + FILE *f; HCACHEDATA *c; - int header_count = 0; - char* hcachename; - int maxage; - + int header_count = 0; + const char* hcachename; + int maxage; + if (!hcachehash) return; diff --git a/jam/pathunix.c b/jam/pathunix.c index 6a3df2b7fb..058b8ccd1f 100644 --- a/jam/pathunix.c +++ b/jam/pathunix.c @@ -38,9 +38,7 @@ # ifdef USE_PATHUNIX -# if defined( OS_MACOSX ) -/* need unistd for the prototype for getcwd to avoid defaulting return to int on 64bit */ -/* XXX: others too ? */ +# if defined( unix ) # include # endif @@ -49,13 +47,13 @@ */ void -path_parse( +path_parse( const char *file, PATHNAME *f ) { const char *p, *q; const char *end; - + memset( (char *)f, 0, sizeof( *f ) ); /* Look for */ @@ -83,7 +81,7 @@ path_parse( { f->f_dir.ptr = file; f->f_dir.len = p - file; - + /* Special case for / - dirname is /, not "" */ if( !f->f_dir.len ) @@ -108,7 +106,7 @@ path_parse( f->f_member.ptr = p + 1; f->f_member.len = end - p - 2; end = p; - } + } /* Look for .suffix */ /* This would be memrchr() */ @@ -157,13 +155,13 @@ path_build( # if PATH_DELIM == '/' - if( f->f_root.len + if( f->f_root.len && !( f->f_root.len == 1 && f->f_root.ptr[0] == '.' ) && !( f->f_dir.len && f->f_dir.ptr[0] == '/' ) ) # else /* unix */ - if( f->f_root.len + if( f->f_root.len && !( f->f_root.len == 1 && f->f_root.ptr[0] == '.' ) && !( f->f_dir.len && f->f_dir.ptr[0] == '/' ) && !( f->f_dir.len && f->f_dir.ptr[0] == '\\' ) @@ -233,8 +231,8 @@ path_parent( PATHNAME *f ) f->f_suffix.ptr = f->f_member.ptr = ""; - f->f_base.len = - f->f_suffix.len = + f->f_base.len = + f->f_suffix.len = f->f_member.len = 0; }