1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-01 13:41:39 +03:00

Fix Windows compiler warnings

Fixes bug 788317. Thanks to J. Peter Mugaas for the initial patch.
This commit is contained in:
Nick Wellnhofer
2017-10-25 16:21:23 +02:00
parent 8b4babb8f7
commit 8760bb2276
8 changed files with 33 additions and 34 deletions

View File

@ -121,12 +121,14 @@ exsltCryptoHex2Bin (const unsigned char *hex, int hexlen,
#include <windows.h>
#include <wincrypt.h>
#ifdef _MSC_VER
#pragma comment(lib, "advapi32.lib")
#endif
static void
exsltCryptoCryptoApiReportError (xmlXPathParserContextPtr ctxt,
int line) {
LPVOID lpMsgBuf;
char *lpMsgBuf;
DWORD dw = GetLastError ();
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
@ -143,7 +145,7 @@ exsltCryptoCryptoApiReportError (xmlXPathParserContextPtr ctxt,
static HCRYPTHASH
exsltCryptoCryptoApiCreateHash (xmlXPathParserContextPtr ctxt,
HCRYPTPROV hCryptProv, ALG_ID algorithm,
const char *msg, unsigned int msglen,
const unsigned char *msg, unsigned int msglen,
char *dest, unsigned int destlen)
{
HCRYPTHASH hHash = 0;
@ -154,12 +156,12 @@ exsltCryptoCryptoApiCreateHash (xmlXPathParserContextPtr ctxt,
return 0;
}
if (!CryptHashData (hHash, (const BYTE *) msg, msglen, 0)) {
if (!CryptHashData (hHash, msg, msglen, 0)) {
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
goto fail;
}
if (!CryptGetHashParam (hHash, HP_HASHVAL, dest, &dwHashLen, 0)) {
if (!CryptGetHashParam (hHash, HP_HASHVAL, (BYTE *) dest, &dwHashLen, 0)) {
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
goto fail;
}
@ -194,8 +196,8 @@ exsltCryptoCryptoApiHash (xmlXPathParserContextPtr ctxt,
}
hHash = exsltCryptoCryptoApiCreateHash (ctxt, hCryptProv,
algorithm, msg, msglen,
dest, HASH_DIGEST_LENGTH);
algorithm, (unsigned char *) msg,
msglen, dest, HASH_DIGEST_LENGTH);
if (0 != hHash) {
CryptDestroyHash (hHash);
}
@ -212,7 +214,7 @@ exsltCryptoCryptoApiRc4Encrypt (xmlXPathParserContextPtr ctxt,
HCRYPTKEY hKey;
HCRYPTHASH hHash;
DWORD dwDataLen;
unsigned char hash[HASH_DIGEST_LENGTH];
char hash[HASH_DIGEST_LENGTH];
if (msglen > destlen) {
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,
@ -263,7 +265,7 @@ exsltCryptoCryptoApiRc4Decrypt (xmlXPathParserContextPtr ctxt,
HCRYPTKEY hKey;
HCRYPTHASH hHash;
DWORD dwDataLen;
unsigned char hash[HASH_DIGEST_LENGTH];
char hash[HASH_DIGEST_LENGTH];
if (msglen > destlen) {
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,

View File

@ -808,8 +808,9 @@ exsltDateCurrent (void)
gmtime_r(&secs, &gmTm);
#else
tb = gmtime(&secs);
if (tb != NULL)
gmTm = *tb;
if (tb == NULL)
return NULL;
gmTm = *tb;
#endif
ret->tz_flag = 0;
#if 0

View File

@ -22,6 +22,7 @@
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
@ -5872,7 +5873,8 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
*/
root = xmlDocGetRootElement(doc);
if (root != NULL) {
if (((long) root->content) >= 0 && (xslDebugStatus == XSLT_DEBUG_NONE))
if (((ptrdiff_t) root->content >= 0) &&
(xslDebugStatus == XSLT_DEBUG_NONE))
xmlXPathOrderDocElems(doc);
}

View File

@ -187,7 +187,7 @@ xsltNewLocale(const xmlChar *languageTag) {
region = xsltDefaultRegion(localeName);
if (region == NULL) goto end;
strcpy(localeName + llen + 1, region);
strcpy((char *) localeName + llen + 1, (char *) region);
locale = xslt_locale_WINAPI(localeName);
end:
return(locale);
@ -382,7 +382,7 @@ xsltStrxfrm(xsltLocale locale, const xmlChar *string)
#endif
#ifdef XSLT_LOCALE_WINAPI
xstrlen = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
xstrlen = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, NULL, 0);
if (xstrlen == 0) {
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar check failed\n");
return(NULL);
@ -392,7 +392,7 @@ xsltStrxfrm(xsltLocale locale, const xmlChar *string)
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
return(NULL);
}
r = MultiByteToWideChar(CP_UTF8, 0, string, -1, xstr, xstrlen);
r = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, xstr, xstrlen);
if (r == 0) {
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar failed\n");
xmlFree(xstr);
@ -479,9 +479,11 @@ xsltIterateSupportedLocales(LPSTR lcid) {
k = sscanf(lcid, "%lx", (long*)&p->lcid);
if (k < 1) goto end;
/*don't count terminating null character*/
k = GetLocaleInfoA(p->lcid, LOCALE_SISO639LANGNAME , iso639lang , sizeof(iso639lang ));
k = GetLocaleInfoA(p->lcid, LOCALE_SISO639LANGNAME,
(char *) iso639lang, sizeof(iso639lang));
if (--k < 1) goto end;
l = GetLocaleInfoA(p->lcid, LOCALE_SISO3166CTRYNAME, iso3136ctry, sizeof(iso3136ctry));
l = GetLocaleInfoA(p->lcid, LOCALE_SISO3166CTRYNAME,
(char *) iso3136ctry, sizeof(iso3136ctry));
if (--l < 1) goto end;
{ /*fill results*/

View File

@ -42,16 +42,9 @@
#include "imports.h"
#include "transform.h"
/* gettimeofday on Windows ??? */
#if defined(WIN32) && !defined(__CYGWIN__)
#ifdef _MSC_VER
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#define gettimeofday(p1,p2)
#define HAVE_GETTIMEOFDAY
#define XSLT_WIN32_PERFORMANCE_COUNTER
#endif /* _MS_VER */
#endif /* WIN32 */
#endif
/************************************************************************
* *
@ -1811,6 +1804,8 @@ static long calibration = -1;
*
* Returns the number of milliseconds used by xsltTimestamp()
*/
#if !defined(XSLT_WIN32_PERFORMANCE_COUNTER) && \
(defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETTIMEOFDAY))
static long
xsltCalibrateTimestamps(void) {
register int i;
@ -1819,6 +1814,7 @@ xsltCalibrateTimestamps(void) {
xsltTimestamp();
return(xsltTimestamp() / 1000);
}
#endif
/**
* xsltCalibrateAdjust:

View File

@ -21,6 +21,7 @@
#include "libxslt-py.h"
#include <stdio.h>
#include <stddef.h>
#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(vsnprintf)
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
@ -105,7 +106,7 @@ libxslt_xsltGetTransformContextHashCode(PyObject *self ATTRIBUTE_UNUSED, PyObjec
return NULL;
tctxt = (xsltTransformContextPtr) PytransformCtxt_Get(py_tctxt);
hash_code = (long) tctxt;
hash_code = (ptrdiff_t) tctxt;
ret = PyInt_FromLong(hash_code);
return ret;
@ -142,7 +143,7 @@ libxslt_xsltGetStylesheetHashCode(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg
return NULL;
style = (xsltStylesheetPtr) Pystylesheet_Get(py_style);
hash_code = (long) style;
hash_code = (ptrdiff_t) style;
ret = PyInt_FromLong(hash_code);
return ret;

View File

@ -16,7 +16,9 @@
#include <stdlib.h>
#include <stdio.h>
#ifndef _REENTRANT
#define _REENTRANT
#endif
#include <libxml/xmlversion.h>
#if defined(LIBXML_THREAD_ENABLED) && defined(HAVE_PTHREAD_H)

View File

@ -54,18 +54,11 @@
#include <libexslt/exsltconfig.h>
#if defined(WIN32) && !defined (__CYGWIN__)
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <winsock2.h>
#define gettimeofday(p1,p2)
#endif /* _MS_VER */
#else /* WIN32 */
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#elif defined(HAVE_TIME_H)
#include <time.h>
#endif
#endif /* WIN32 */
#ifdef HAVE_SYS_TIMEB_H
#include <sys/timeb.h>
@ -595,7 +588,7 @@ main(int argc, char **argv)
(!strcmp(argv[i], "--output"))) {
i++;
#if defined(WIN32) || defined (__CYGWIN__)
output = xmlCanonicPath(argv[i]);
output = (char *) xmlCanonicPath((xmlChar *) argv[i]);
if (output == NULL)
#endif
output = (char *) xmlStrdup((xmlChar *) argv[i]);