From ab973ec40cc7a79bbf930085b1293824caf73e7f Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Fri, 17 Apr 2015 11:39:26 +0200 Subject: [PATCH] misc x64 VS 2015 CTP fixes [#39308] --- CHANGES | 3 +++ bin/named/client.c | 2 +- bin/named/server.c | 4 ++-- bin/named/win32/os.c | 26 +++++++++++++------------- lib/dns/rdata.c | 2 +- lib/dns/view.c | 4 ++-- lib/isc/entropy.c | 5 +++++ lib/isccc/cc.c | 4 ++-- 8 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index a769298ca9..25767e1c93 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4105. [port] Misc fixes for Microsoft Visual Studio + 2015 CTP6 in 64 bit mode. [RT #39308] + 4104. [bug] Address uninitialized elements. [RT #39252] 4103. [port] Misc fixes for Microsoft Visual Studio diff --git a/bin/named/client.c b/bin/named/client.c index 62ef45c649..21afbbd3fc 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -1875,7 +1875,7 @@ process_ecs(ns_client_t *client, isc_buffer_t *buf, size_t optlen) { client->ecs_scope = 0; client->attributes |= NS_CLIENTATTR_HAVEECS; - isc_buffer_forward(buf, optlen); + isc_buffer_forward(buf, (unsigned int)optlen); return (ISC_R_SUCCESS); } diff --git a/bin/named/server.c b/bin/named/server.c index 1e42634adf..bb7e087804 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10122,11 +10122,11 @@ static isc_result_t putmem(isc_buffer_t **b, const char *str, size_t len) { isc_result_t result; - result = isc_buffer_reserve(b, len); + result = isc_buffer_reserve(b, (unsigned int)len); if (result != ISC_R_SUCCESS) return (ISC_R_NOSPACE); - isc_buffer_putmem(*b, (const unsigned char *)str, len); + isc_buffer_putmem(*b, (const unsigned char *)str, (unsigned int)len); return (ISC_R_SUCCESS); } diff --git a/bin/named/win32/os.c b/bin/named/win32/os.c index 45ed5501b5..34a4fbf772 100644 --- a/bin/named/win32/os.c +++ b/bin/named/win32/os.c @@ -50,7 +50,7 @@ static char *lockfile = NULL; static char *pidfile = NULL; static int devnullfd = -1; -static int singletonfd = -1; +static int lockfilefd = -1; static BOOL Initialized = FALSE; @@ -212,9 +212,9 @@ cleanup_pidfile(void) { static void cleanup_lockfile(void) { - if (singletonfd != -1) { - close(singletonfd); - singletonfd = -1; + if (lockfilefd != -1) { + close(lockfilefd); + lockfilefd = -1; } if (lockfile != NULL) { @@ -307,7 +307,7 @@ ns_os_issingleton(const char *filename) { char strbuf[ISC_STRERRORSIZE]; OVERLAPPED o; - if (singletonfd != -1) + if (lockfilefd != -1) return (ISC_TRUE); if (strcasecmp(filename, "none") == 0) @@ -324,16 +324,16 @@ ns_os_issingleton(const char *filename) { * ns_os_openfile() uses safeopen() which removes any existing * files. We can't use that here. */ - singletonfd = open(filename, O_WRONLY | O_CREAT, - S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); - if (singletonfd == -1) { + lockfilefd = open(filename, O_WRONLY | O_CREAT, + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + if (lockfilefd == -1) { cleanup_lockfile(); return (ISC_FALSE); } memset(&o, 0, sizeof(o)); /* Expect ERROR_LOCK_VIOLATION if already locked */ - if (!LockFileEx((HANDLE) _get_osfhandle(singletonfd), + if (!LockFileEx((HANDLE) _get_osfhandle(lockfilefd), LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, 0, 1, &o)) { cleanup_lockfile(); @@ -349,11 +349,11 @@ ns_os_shutdown(void) { closelog(); cleanup_pidfile(); - if (singletonfd != -1) { - (void) UnlockFile((HANDLE) _get_osfhandle(singletonfd), + if (lockfilefd != -1) { + (void) UnlockFile((HANDLE) _get_osfhandle(lockfilefd), 0, 0, 0, 1); - close(singletonfd); - singletonfd = -1; + close(lockfilefd); + lockfilefd = -1; } ntservice_shutdown(); /* This MUST be the last thing done */ } diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 42a966c62c..d00b2e4dcb 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -1397,7 +1397,7 @@ multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target) { if (escape) return (DNS_R_SYNTAX); - isc_buffer_add(target, t - t0); + isc_buffer_add(target, (unsigned int)(t - t0)); } while (n != 0); return (ISC_R_SUCCESS); } diff --git a/lib/dns/view.c b/lib/dns/view.c index c31df78b16..84c00640f7 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -2150,8 +2150,8 @@ dns_view_loadnta(dns_view_t *view) { dns_fixedname_init(&fn); ntaname = dns_fixedname_name(&fn); - isc_buffer_init(&b, name, len); - isc_buffer_add(&b, len); + isc_buffer_init(&b, name, (unsigned int)len); + isc_buffer_add(&b, (unsigned int)len); CHECK(dns_name_fromtext(ntaname, &b, dns_rootname, 0, NULL)); } diff --git a/lib/isc/entropy.c b/lib/isc/entropy.c index 389038637b..ffdd88f196 100644 --- a/lib/isc/entropy.c +++ b/lib/isc/entropy.c @@ -319,7 +319,12 @@ entropypool_adddata(isc_entropy_t *ent, void *p, unsigned int len, unsigned long addr; isc_uint8_t *buf; + /* Silly MSVC in 64 bit mode complains here... */ +#ifdef _WIN64 + addr = (unsigned long)((unsigned long long)p); +#else addr = (unsigned long)p; +#endif buf = p; if ((addr & 0x03U) != 0U) { diff --git a/lib/isccc/cc.c b/lib/isccc/cc.c index 8b8cc3a380..400108e3a4 100644 --- a/lib/isccc/cc.c +++ b/lib/isccc/cc.c @@ -207,7 +207,7 @@ table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer) { isccc_sexpr_t *kv, *elt, *k, *v; char *ks; isc_result_t result; - size_t len; + unsigned int len; for (elt = isccc_alist_first(alist); elt != NULL; @@ -216,7 +216,7 @@ table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer) { k = ISCCC_SEXPR_CAR(kv); ks = isccc_sexpr_tostring(k); v = ISCCC_SEXPR_CDR(kv); - len = strlen(ks); + len = (unsigned int)strlen(ks); INSIST(len <= 255U); /* * Emit the key name.