diff --git a/sys/net/sock/sock_util.c b/sys/net/sock/sock_util.c index 428dec044bff..52b0dae4ca3a 100644 --- a/sys/net/sock/sock_util.c +++ b/sys/net/sock/sock_util.c @@ -117,7 +117,7 @@ static char* _find_pathstart(const char *url) int sock_urlsplit(const char *url, char *hostport, char *urlpath) { - assert(url); + assert(url != NULL); char *hoststart = _find_hoststart(url); if (!hoststart) { return -EINVAL; @@ -125,7 +125,7 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath) char *pathstart = _find_pathstart(hoststart); - if (hostport) { + if (hostport != NULL) { size_t hostlen = pathstart - hoststart; /* hostlen must be smaller SOCK_HOSTPORT_MAXLEN to have space for the null * terminator */ @@ -133,18 +133,16 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath) return -EOVERFLOW; } memcpy(hostport, hoststart, hostlen); - *(hostport + hostlen) = '\0'; + hostport[hostlen] = '\0'; } - if (urlpath) { + if (urlpath != NULL) { size_t pathlen = strlen(pathstart); - if (pathlen) { - if (pathlen > SOCK_URLPATH_MAXLEN - 1) { - return -EOVERFLOW; - } - memcpy(urlpath, pathstart, pathlen); + if (pathlen > SOCK_URLPATH_MAXLEN - 1) { + return -EOVERFLOW; } - *(urlpath + pathlen) = '\0'; + memcpy(urlpath, pathstart, pathlen); + urlpath[pathlen] = '\0'; } return 0; }