diff --git a/features/netsocket/SocketAddress.cpp b/features/netsocket/SocketAddress.cpp index 8fc2595294..15a46a2f4b 100644 --- a/features/netsocket/SocketAddress.cpp +++ b/features/netsocket/SocketAddress.cpp @@ -66,13 +66,15 @@ static void ipv4_from_address(uint8_t *bytes, const char *addr) int i = 0; for (; count < NSAPI_IPv4_BYTES; count++) { - unsigned char b; - int scanned = sscanf(&addr[i], "%hhu", &b); + unsigned d; + // Not using %hh, since it might be missing in newlib-based toolchains. + // See also: https://git.io/vxiw5 + int scanned = sscanf(&addr[i], "%u", &d); if (scanned < 1) { return; } - bytes[count] = b; + bytes[count] = static_cast(d); for (; addr[i] != '.'; i++) { if (!addr[i]) {