Fix compiler warnings in the MS-Windows build.

* 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.
This commit is contained in:
Eli Zaretskii 2022-09-25 17:11:12 +03:00
parent caad0e2181
commit 387d349dc8
4 changed files with 16 additions and 6 deletions

View 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;

View 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>

View 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 == '\\')

View 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;
}