]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Fix compiler warnings in the MS-Windows build.
authorEli Zaretskii <eliz@gnu.org>
Sun, 25 Sep 2022 14:11:12 +0000 (17:11 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 25 Sep 2022 14:11:12 +0000 (17:11 +0300)
* src/w32/w32os.c (osync_get_mutex, osync_parse_mutex): Cast to
DWORD_PTR when converting integers to HANDLEs and vice versa.

* src/w32/pathstuff.c (w32ify): Pacify compiler warnings about
'strncpy'.

* src/makeint.h (PRId64) [!HAVE_INTTYPES_H]: Define if undefined.
* src/function.c (func_wordlist): Use PRId64 instead of %lld.

src/function.c
src/makeint.h
src/w32/pathstuff.c
src/w32/w32os.c

index a2fd90a7fca5f05a2369e6c972f916255e89942c..ce6e76037df873e53e6da58836d4c8f02efa08e2 100644 (file)
@@ -825,11 +825,11 @@ func_wordlist (char *o, char **argv, const char *funcname UNUSED)
 
   if (start < 1)
     ON (fatal, *expanding_var,
-        "invalid first argument to 'wordlist' function: '%lld'", start);
+        "invalid first argument to 'wordlist' function: '%" PRId64 "'", start);
 
   if (stop < 0)
     ON (fatal, *expanding_var,
-        "invalid second argument to 'wordlist' function: '%lld'", stop);
+        "invalid second argument to 'wordlist' function: '%" PRId64 "'", stop);
 
   count = stop - start + 1;
 
index d941ff3d825ee96e87a78faac89d9fda0efcb1cc..54b500f3ae881e10d294f8b6e3f970dbc5ad23a0 100644 (file)
@@ -290,6 +290,14 @@ char *strerror (int errnum);
 
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
+#else
+# ifndef PRId64
+#  ifdef WINDOWS32
+#   define PRId64 "I64d"
+#  else
+#   define PRId64 "lld"
+#  endif
+# endif
 #endif
 #if HAVE_STDINT_H
 # include <stdint.h>
index afee0a4afd48f96d7e4eab9b04719916b46fe556..ae761ae641001f3ea081190d02d0d30171e402a2 100644 (file)
@@ -102,11 +102,11 @@ w32ify(const char *filename, int resolve)
     if (resolve)
       {
         char *fp = _fullpath (NULL, filename, sizeof (w32_path));
-        strncpy (w32_path, fp, sizeof (w32_path));
+        strncpy (w32_path, fp, sizeof (w32_path) - 1);
         free (fp);
       }
     else
-      strncpy(w32_path, filename, sizeof (w32_path));
+      strncpy(w32_path, filename, sizeof (w32_path) - 1);
 
     for (p = w32_path; p && *p; p++)
       if (*p == '\\')
index 528b5b7085ba8ca6baf7a6cbeb9e6c42e433cd9d..23acccb9e22343925bc81c1336fe97cbf5915f9b 100644 (file)
@@ -22,7 +22,9 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <windows.h>
 #include <process.h>
 #include <io.h>
+#if _WIN32_WINNT > 0x0601
 #include <synchapi.h>
+#endif
 #include "pathstuff.h"
 #include "sub_proc.h"
 #include "w32err.h"
@@ -429,7 +431,7 @@ osync_get_mutex ()
       /* Prepare the mutex handle string for our children.
          2 hex digits per byte + 2 characters for "0x" + null.  */
       mutex = xmalloc ((2 * sizeof (osync_handle)) + 2 + 1);
-      sprintf (mutex, "0x%Ix", (unsigned long long)osync_handle);
+      sprintf (mutex, "0x%Ix", (unsigned long long)(DWORD_PTR)osync_handle);
     }
 
   return mutex;
@@ -449,7 +451,7 @@ osync_parse_mutex (const char *mutex)
   if (endp[0] != '\0')
     OS (fatal, NILF, _("invalid output sync mutex: %s"), mutex);
 
-  osync_handle = (HANDLE) i;
+  osync_handle = (HANDLE) (DWORD_PTR) i;
 
   return 1;
 }