Fixups for warnings on Windows (esp 64bit).
authorPaul Smith <psmith@gnu.org>
Mon, 5 Jul 2010 18:32:03 +0000 (18:32 +0000)
committerPaul Smith <psmith@gnu.org>
Mon, 5 Jul 2010 18:32:03 +0000 (18:32 +0000)
ChangeLog
ar.c
arscan.c
dir.c
hash.c
implicit.c
job.c
signame.c
tests/scripts/features/parallelism

index 9f3c62217927283d766e630d05f277f30ec2a011..7b9711b9b9a56b89f39135a05c144427f28ecccf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-07-05  Paul Smith  <psmith@gnu.org>
+
+       * implicit.c (pattern_search): lastslash can be const.
+       * dir.c (downcase): Remove unused variable.
+       * hash.c (hash_init): Cast sizeof for error message.
+       * arscan.c (ar_scan): Cast to char* for WINDOWS32.
+       (ar_member_touch): Ditto.
+       * ar.c (glob_pattern_p): Avoid symbol collision: open -> opened
+       * signame.c (strsignal): Ditto: signal -> sig
+       * job.c (create_batch_file): Ditto: error -> error_string
+       (pid2str): Portably convert a pid_t into a string
+       (reap_children): Use it.
+       (start_waiting_job): Use it.
+       Savannah bug #27809.  Patch by Ozkan Sezer <sezeroz@gmail.com>
+
 2010-07-03  Paul Smith  <psmith@gnu.org>
 
        * read.c (parse_file_seq): All archive groups must end with ')' as
diff --git a/ar.c b/ar.c
index 4f29b68be5bc9c4b95d7709c64783ade1c66ca61..66afd9003e66165a8c0320dc3005aa66182777c3 100644 (file)
--- a/ar.c
+++ b/ar.c
@@ -212,7 +212,7 @@ static int
 glob_pattern_p (const char *pattern, int quote)
 {
   const char *p;
-  int open = 0;
+  int opened = 0;
 
   for (p = pattern; *p != '\0'; ++p)
     switch (*p)
@@ -227,11 +227,11 @@ glob_pattern_p (const char *pattern, int quote)
        break;
 
       case '[':
-       open = 1;
+       opened = 1;
        break;
 
       case ']':
-       if (open)
+       if (opened)
          return 1;
        break;
       }
index 771e394ebccac5fbbf36c9453e76ff005c61be11..7bdc15d96ec7aa006f3c02e00ab0dcf537a95840 100644 (file)
--- a/arscan.c
+++ b/arscan.c
@@ -272,6 +272,7 @@ struct ar_hdr
     char ar_fmag[2];           /* Always contains ARFMAG.  */
   };
 # endif
+# define TOCHAR(_m)     (_m)
 #else
 /* These should allow us to read Windows (VC++) libraries (according to Frank
  * Libbrecht <frankl@abzx.belgium.hp.com>)
@@ -288,6 +289,8 @@ struct ar_hdr
 # define ar_date    Date
 # define ar_uid     UserID
 # define ar_gid     GroupID
+/* In Windows the member names have type BYTE so we must cast them.  */
+# define TOCHAR(_m)     ((char *)(_m))
 #endif
 
 /* Cray's <ar.h> apparently defines this.  */
@@ -630,8 +633,8 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
        }
 
 #ifndef        M_XENIX
-       sscanf (member_header.ar_mode, "%o", &eltmode);
-       eltsize = atol (member_header.ar_size);
+       sscanf (TOCHAR (member_header.ar_mode), "%o", &eltmode);
+       eltsize = atol (TOCHAR (member_header.ar_size));
 #else  /* Xenix.  */
        eltmode = (unsigned short int) member_header.ar_mode;
        eltsize = member_header.ar_size;
@@ -641,9 +644,9 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
          (*function) (desc, name, ! long_name, member_offset,
                       member_offset + AR_HDR_SIZE, eltsize,
 #ifndef        M_XENIX
-                      atol (member_header.ar_date),
-                      atoi (member_header.ar_uid),
-                      atoi (member_header.ar_gid),
+                      atol (TOCHAR (member_header.ar_date)),
+                      atoi (TOCHAR (member_header.ar_uid)),
+                      atoi (TOCHAR (member_header.ar_gid)),
 #else  /* Xenix.  */
                       member_header.ar_date,
                       member_header.ar_uid,
@@ -812,7 +815,7 @@ ar_member_touch (const char *arname, const char *memname)
   /* Advance member's time to that time */
   for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++)
     ar_hdr.ar_date[ui] = ' ';
-  sprintf (ar_hdr.ar_date, "%ld", (long int) statbuf.st_mtime);
+  sprintf (TOCHAR (ar_hdr.ar_date), "%ld", (long int) statbuf.st_mtime);
 #ifdef AIAMAG
   ar_hdr.ar_date[strlen(ar_hdr.ar_date)] = ' ';
 #endif
diff --git a/dir.c b/dir.c
index 4224abbed45505240db6939144c5f888369d28ee..7277fe6cd6e57cac1479fb5c0c7a19d0ff058ea1 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -123,14 +123,11 @@ downcase (const char *filename)
 {
   static PATH_VAR (new_filename);
   char *df;
-  int i;
 
   if (filename == 0)
     return 0;
 
   df = new_filename;
-
-  /* First, transform the name part.  */
   while (*filename != '\0')
     {
       *df++ = tolower ((unsigned char)*filename);
diff --git a/hash.c b/hash.c
index 7f9530dda92c69fbf2c2fa8e56bac7ea1aef20bc..a4df1f606c5c6a534d1557a684f43eda607e2aa9 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -46,8 +46,8 @@ hash_init (struct hash_table *ht, unsigned long size,
   ht->ht_vec = (void**) CALLOC (struct token *, ht->ht_size);
   if (ht->ht_vec == 0)
     {
-      fprintf (stderr, _("can't allocate %ld bytes for hash table: memory exhausted"),
-              ht->ht_size * sizeof(struct token *));
+      fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"),
+              ht->ht_size * (unsigned long) sizeof (struct token *));
       exit (1);
     }
 
index 6e67b718eb9b7fab15fb0ba62cf0db1018a36eb3..081ccb6595c535dbf3e6f2ddcefc73f8faf0bd17 100644 (file)
@@ -211,7 +211,7 @@ pattern_search (struct file *file, int archive,
   unsigned int namelen = strlen (filename);
 
   /* The last slash in FILENAME (or nil if there is none).  */
-  char *lastslash;
+  const char *lastslash;
 
   /* This is a file-object used as an argument in
      recursive calls.  It never contains any data
diff --git a/job.c b/job.c
index edbf569c54d3c2330fd4cd2ca1a354aab83a9a66..03d8a83abce7c5eb5d7d4e31453e2982cdc17819 100644 (file)
--- a/job.c
+++ b/job.c
@@ -186,6 +186,20 @@ int getgid ();
 # endif
 #endif
 
+/* Different systems have different requirements for pid_t.
+   Plus we have to support gettext string translation... Argh.  */
+static const char *
+pid2str (pid_t pid)
+{
+  static char pidstring[100];
+#ifdef WINDOWS32
+  sprintf (pidstring, "%Id", pid);
+#else
+  sprintf (pidstring, "%lu", (unsigned long) pid);
+#endif
+  return pidstring;
+}
+
 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);
@@ -246,7 +260,7 @@ static char *
 create_batch_file (char const *base, int unixy, int *fd)
 {
   const char *const ext = unixy ? "sh" : "bat";
-  const char *error = NULL;
+  const char *error_string = NULL;
   char temp_path[MAXPATHLEN]; /* need to know its length */
   unsigned path_size = GetTempPath(sizeof temp_path, temp_path);
   int path_is_dot = 0;
@@ -292,7 +306,7 @@ create_batch_file (char const *base, int unixy, int *fd)
 
           else
             {
-              error = map_windows32_error_to_string (er);
+              error_string = map_windows32_error_to_string (er);
               break;
             }
         }
@@ -315,9 +329,9 @@ create_batch_file (char const *base, int unixy, int *fd)
     }
 
   *fd = -1;
-  if (error == NULL)
-    error = _("Cannot create a temporary file\n");
-  fatal (NILF, error);
+  if (error_string == NULL)
+    error_string = _("Cannot create a temporary file\n");
+  fatal (NILF, error_string);
 
   /* not reached */
   return NULL;
@@ -513,9 +527,9 @@ reap_children (int block, int err)
        {
          any_remote |= c->remote;
          any_local |= ! c->remote;
-         DB (DB_JOBS, (_("Live child 0x%08lx (%s) PID %ld %s\n"),
-                        (unsigned long int) c, c->file->name,
-                        (long) c->pid, c->remote ? _(" (remote)") : ""));
+         DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"),
+                        c, c->file->name, pid2str (c->pid),
+                        c->remote ? _(" (remote)") : ""));
 #ifdef VMS
          break;
 #endif
@@ -636,8 +650,7 @@ reap_children (int block, int err)
                              e, map_windows32_error_to_string(e));
                   }
                 else
-                  DB (DB_VERBOSE, ("Main thread handle = 0x%08lx\n",
-                                   (unsigned long)main_thread));
+                  DB (DB_VERBOSE, ("Main thread handle = %p\n", main_thread));
               }
 
             /* wait for anything to finish */
@@ -693,10 +706,9 @@ reap_children (int block, int err)
         continue;
 
       DB (DB_JOBS, (child_failed
-                    ? _("Reaping losing child 0x%08lx PID %ld %s\n")
-                    : _("Reaping winning child 0x%08lx PID %ld %s\n"),
-                    (unsigned long int) c, (long) c->pid,
-                    c->remote ? _(" (remote)") : ""));
+                    ? _("Reaping losing child %p PID %s %s\n")
+                    : _("Reaping winning child %p PID %s %s\n"),
+                    c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
 
       if (c->sh_batch_file) {
         DB (DB_JOBS, (_("Cleaning up temp batch file %s\n"),
@@ -797,9 +809,8 @@ reap_children (int block, int err)
            update_status to its also_make files.  */
         notice_finished_file (c->file);
 
-      DB (DB_JOBS, (_("Removing child 0x%08lx PID %ld%s from chain.\n"),
-                    (unsigned long int) c, (long) c->pid,
-                    c->remote ? _(" (remote)") : ""));
+      DB (DB_JOBS, (_("Removing child %p PID %s%s from chain.\n"),
+                    c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
 
       /* Block fatal signals while frobnicating the list, so that
          children and job_slots_used are always consistent.  Otherwise
@@ -842,8 +853,8 @@ static void
 free_child (struct child *child)
 {
   if (!jobserver_tokens)
-    fatal (NILF, "INTERNAL: Freeing child 0x%08lx (%s) but no tokens left!\n",
-           (unsigned long int) child, child->file->name);
+    fatal (NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n",
+           child, child->file->name);
 
   /* If we're using the jobserver and this child is not the only outstanding
      job, put a token back into the pipe for it.  */
@@ -859,8 +870,8 @@ free_child (struct child *child)
       if (r != 1)
        pfatal_with_name (_("write jobserver"));
 
-      DB (DB_JOBS, (_("Released token for child 0x%08lx (%s).\n"),
-                    (unsigned long int) child, child->file->name));
+      DB (DB_JOBS, (_("Released token for child %p (%s).\n"),
+                    child, child->file->name));
     }
 
   --jobserver_tokens;
@@ -1459,9 +1470,9 @@ start_waiting_job (struct child *c)
     {
     case cs_running:
       c->next = children;
-      DB (DB_JOBS, (_("Putting child 0x%08lx (%s) PID %ld%s on the chain.\n"),
-                    (unsigned long int) c, c->file->name,
-                    (long) c->pid, c->remote ? _(" (remote)") : ""));
+      DB (DB_JOBS, (_("Putting child %p (%s) PID %s%s on the chain.\n"),
+                    c, c->file->name, pid2str (c->pid),
+                    c->remote ? _(" (remote)") : ""));
       children = c;
       /* One more job slot is in use.  */
       ++job_slots_used;
@@ -1712,8 +1723,8 @@ new_job (struct file *file)
         /* If we got one, we're done here.  */
        if (got_token == 1)
           {
-            DB (DB_JOBS, (_("Obtained token for child 0x%08lx (%s).\n"),
-                          (unsigned long int) c, c->file->name));
+            DB (DB_JOBS, (_("Obtained token for child %p (%s).\n"),
+                          c, c->file->name));
             break;
           }
 
@@ -2058,8 +2069,8 @@ exec_command (char **argv, char **envp)
           break;
       else
           fprintf(stderr,
-                  _("make reaped child pid %ld, still waiting for pid %ld\n"),
-                  (DWORD)hWaitPID, (DWORD)hPID);
+                  _("make reaped child pid %Iu, still waiting for pid %Iu\n"),
+                  (DWORD_PTR)hWaitPID, (DWORD_PTR)hPID);
     }
 
   /* return child's exit code as our exit code */
index 1360b43bb9a850ba4d1b2d4c969313dd79dc1103..bdae74b9dba00f1e431ffa3cb4e2107096e130ab 100644 (file)
--- a/signame.c
+++ b/signame.c
@@ -229,7 +229,7 @@ signame_init (void)
 
 
 char *
-strsignal (int signal)
+strsignal (int sig)
 {
   static char buf[] = "Signal 12345678901234567890";
 
@@ -246,10 +246,10 @@ strsignal (int signal)
 # endif
 #endif
 
-  if (signal > 0 || signal < NSIG)
-    return (char *) sys_siglist[signal];
+  if (sig > 0 || sig < NSIG)
+    return (char *) sys_siglist[sig];
 
-  sprintf (buf, "Signal %d", signal);
+  sprintf (buf, "Signal %d", sig);
   return buf;
 }
 
index 8bf24a41e1cafb931d52a5dc20951d2b695648ed..cc0f84f6645c32d44a686336f3c4883688352316 100644 (file)
@@ -194,6 +194,28 @@ rm main.x");
     rmfiles(qw(foo.y foo.y.in main.bar));
 }
 
+if ($all_tests) {
+    # Jobserver FD handling is messed up in some way.
+    # Savannah bug #28189
+    # It doesn't look like that bug anymore but this is the code it runs
+
+    run_make_test(q!
+ifdef EXTRA
+vpath %.dst /
+xxx.dst: ; true
+yyy.dst: ; true
+endif
+
+M := $(MAKE)
+xx: ; $M --no-print-directory -j2 -f $(MAKEFILE_LIST) xxx.dst yyy.dst EXTRA=1
+!,
+                  '-j2',
+                  '#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.
+true
+true
+');
+}
+
 # Make sure that all jobserver FDs are closed if we need to re-exec the
 # master copy.
 #