build: fix error C4146 on MSVC (#3271)

> error C4146: unary minus operator applied to unsigned type, result still unsigned
This commit is contained in:
UMU 2022-02-13 13:57:43 +08:00 committed by GitHub
parent 636cb8633b
commit 8ec1732af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,7 @@
#include "idna.h"
#include <assert.h>
#include <string.h>
#include <limits.h> /* UINT_MAX */
static unsigned uv__utf8_decode1_slow(const char** p,
const char* pe,
@ -129,7 +130,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
while (s < se) {
c = uv__utf8_decode1(&s, se);
if (c == -1u)
if (c == UINT_MAX)
return UV_EINVAL;
if (c < 128)
@ -151,7 +152,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
s = ss;
while (s < se) {
c = uv__utf8_decode1(&s, se);
assert(c != -1u);
assert(c != UINT_MAX);
if (c > 127)
continue;
@ -182,7 +183,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
while (s < se) {
c = uv__utf8_decode1(&s, se);
assert(c != -1u);
assert(c != UINT_MAX);
if (c >= n)
if (c < m)
@ -201,7 +202,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
s = ss;
while (s < se) {
c = uv__utf8_decode1(&s, se);
assert(c != -1u);
assert(c != UINT_MAX);
if (c < n)
if (++delta == 0)
@ -280,7 +281,7 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
st = si;
c = uv__utf8_decode1(&si, se);
if (c == -1u)
if (c == UINT_MAX)
return UV_EINVAL;
if (c != '.')