From: Amos Jeffries Date: Wed, 23 Feb 2022 18:42:41 +0000 (+0000) Subject: Maintenance: code style updates in libcompat (#880) X-Git-Tag: SQUID_6_0_1~229 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f70cf39b14872dddac2e14c2858bded78429150a;p=thirdparty%2Fsquid.git Maintenance: code style updates in libcompat (#880) The libcompat code is targeted here specifically because it is rarely touched so is not likely to be soon updated by our "upgrade when modified" policy for source style changes. Doing this part of the code semi-manually also allows us to trivially exclude the directory from automated conversion attempts and not bother with automating the detection of whether a .h is included in C files. --- diff --git a/compat/cmsg.h b/compat/cmsg.h index ee6c167edb..a61a1e948b 100644 --- a/compat/cmsg.h +++ b/compat/cmsg.h @@ -58,7 +58,7 @@ struct cmsghdr { #ifndef CMSG_FIRSTHDR # define CMSG_FIRSTHDR(mhdr) \ ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ - ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL) + ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) nullptr) #endif #ifndef CMSG_ALIGN diff --git a/compat/compat.cc b/compat/compat.cc index d3d5e845fc..17afe7af27 100644 --- a/compat/compat.cc +++ b/compat/compat.cc @@ -9,5 +9,5 @@ #include "squid.h" #include "compat.h" -void (*failure_notify) (const char *) = NULL; +void (*failure_notify) (const char *) = nullptr; diff --git a/compat/getaddrinfo.cc b/compat/getaddrinfo.cc index eaa8998ae4..b74434188e 100644 --- a/compat/getaddrinfo.cc +++ b/compat/getaddrinfo.cc @@ -84,13 +84,13 @@ dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen) { struct addrinfo *ret; ret = (struct addrinfo *)malloc(sizeof (struct addrinfo)); - if (ret == NULL) - return NULL; + if (!ret) + return nullptr; memcpy (ret, info, sizeof (struct addrinfo)); ret->ai_addr = (struct sockaddr*)malloc(addrlen); - if (ret->ai_addr == NULL) { + if (!ret->ai_addr) { free (ret); - return NULL; + return nullptr; } memcpy (ret->ai_addr, addr, addrlen); ret->ai_addrlen = addrlen; @@ -109,19 +109,19 @@ xgetaddrinfo (const char *nodename, const char *servname, struct addrinfo *ai, *sai, *eai; char **addrs; - if (servname == NULL && nodename == NULL) + if (!servname && !nodename) return EAI_NONAME; memset (&result, 0, sizeof result); /* default for hints */ - if (hints == NULL) { + if (!hints) { memset (&hint, 0, sizeof hint); hint.ai_family = PF_UNSPEC; hints = &hint; } - if (servname == NULL) + if (!servname) port = 0; else { /* check for tcp or udp sockets only */ @@ -135,16 +135,16 @@ xgetaddrinfo (const char *nodename, const char *servname, /* Note: maintain port in host byte order to make debugging easier */ if (isdigit (*servname)) - port = strtol (servname, NULL, 10); - else if ((servent = getservbyname (servname, socktype)) != NULL) + port = strtol (servname, nullptr, 10); + else if ((servent = getservbyname (servname, socktype))) port = ntohs (servent->s_port); else return EAI_NONAME; } - /* if nodename == NULL refer to the local host for a client or any + /* if !nodename, refer to the local host for a client or any for a server */ - if (nodename == NULL) { + if (!nodename) { struct sockaddr_in sin; /* check protocol family is PF_UNSPEC or PF_INET - could try harder @@ -162,7 +162,7 @@ xgetaddrinfo (const char *nodename, const char *servname, sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); /* Duplicate result and addr and return */ *res = dup_addrinfo (&result, &sin, sizeof sin); - return (*res == NULL) ? EAI_MEMORY : 0; + return (!*res) ? EAI_MEMORY : 0; } /* If AI_NUMERIC is specified, use inet_pton to translate numbers and @@ -183,7 +183,7 @@ xgetaddrinfo (const char *nodename, const char *servname, sin.sin_addr.s_addr = inet_addr (nodename); /* Duplicate result and addr and return */ *res = dup_addrinfo (&result, &sin, sizeof sin); - return (*res == NULL) ? EAI_MEMORY : 0; + return (!*res) ? EAI_MEMORY : 0; } #if HAVE_H_ERRNO @@ -191,7 +191,7 @@ xgetaddrinfo (const char *nodename, const char *servname, #endif errno = 0; hp = gethostbyname(nodename); - if (hp == NULL) { + if (!hp) { #ifdef EAI_SYSTEM if (errno != 0) { return EAI_SYSTEM; @@ -233,8 +233,8 @@ xgetaddrinfo (const char *nodename, const char *servname, /* For each element pointed to by hp, create an element in the result linked list. */ - sai = eai = NULL; - for (addrs = hp->h_addr_list; *addrs != NULL; addrs++) { + sai = eai = nullptr; + for (addrs = hp->h_addr_list; *addrs; addrs++) { struct sockaddr sa; size_t addrlen; @@ -263,24 +263,24 @@ xgetaddrinfo (const char *nodename, const char *servname, result.ai_family = hp->h_addrtype; ai = dup_addrinfo (&result, &sa, addrlen); - if (ai == NULL) { + if (!ai) { xfreeaddrinfo (sai); return EAI_MEMORY; } - if (sai == NULL) + if (!sai) sai = ai; else eai->ai_next = ai; eai = ai; } - if (sai == NULL) { + if (!sai) { return EAI_NODATA; } if (hints->ai_flags & AI_CANONNAME) { sai->ai_canonname = (char *)malloc(strlen(hp->h_name) + 1); - if (sai->ai_canonname == NULL) { + if (!sai->ai_canonname) { xfreeaddrinfo (sai); return EAI_MEMORY; } @@ -296,11 +296,11 @@ xfreeaddrinfo (struct addrinfo *ai) { struct addrinfo *next; - while (ai != NULL) { + while (ai) { next = ai->ai_next; - if (ai->ai_canonname != NULL) + if (ai->ai_canonname) free (ai->ai_canonname); - if (ai->ai_addr != NULL) + if (ai->ai_addr) free (ai->ai_addr); free (ai); ai = next; diff --git a/compat/getnameinfo.cc b/compat/getnameinfo.cc index a3c8f5ff57..e7c97cb634 100644 --- a/compat/getnameinfo.cc +++ b/compat/getnameinfo.cc @@ -162,7 +162,7 @@ xgetnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t host uint32_t v4a; char numserv[512]; - if (sa == NULL) + if (!sa) return EAI_FAIL; #if HAVE_SA_LEN /*XXX*/ @@ -186,16 +186,16 @@ found: memcpy(&port, (const char *)sa + afd->a_portoff, sizeof(port)); addr = (const char *)sa + afd->a_off; - if (serv == NULL || servlen == 0) { + if (!serv || servlen == 0) { /* * do nothing in this case. * in case you are wondering if "&&" is more correct than - * "||" here: RFC3493 says that serv == NULL OR servlen == 0 + * "||" here: RFC3493 says that !serv OR servlen == 0 * means that the caller does not want the result. */ } else { if (flags & NI_NUMERICSERV) - sp = NULL; + sp = nullptr; else { sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp"); @@ -246,11 +246,11 @@ found: break; #endif } - if (host == NULL || hostlen == 0) { + if (!host || hostlen == 0) { /* * do nothing in this case. * in case you are wondering if "&&" is more correct than - * "||" here: RFC3493 says that host == NULL or hostlen == 0 + * "||" here: RFC3493 says that !host or hostlen == 0 * means that the caller does not want the result. */ } else if (flags & NI_NUMERICHOST) { @@ -296,8 +296,7 @@ numeric: } #endif default: - if (inet_ntop(afd->a_af, addr, host, - hostlen) == NULL) + if (!inet_ntop(afd->a_af, addr, host, hostlen)) return EAI_SYSTEM; break; } @@ -318,7 +317,7 @@ int flags; int numaddrlen; char numaddr[512]; - if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL) + if (!inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr))) return EAI_SYSTEM; numaddrlen = strlen(numaddr); diff --git a/compat/inet_ntop.cc b/compat/inet_ntop.cc index 5ff864c86b..183a2ffae8 100644 --- a/compat/inet_ntop.cc +++ b/compat/inet_ntop.cc @@ -103,7 +103,7 @@ static const char *inet_ntop6 (const u_char *src, char *dst, size_t size); * inet_ntop(af, src, dst, size) * convert a network format address to presentation format. * return: - * pointer to presentation format address (`dst'), or NULL (see errno). + * pointer to presentation format address (`dst'), or nullptr (see errno). * author: * Paul Vixie, 1996. */ @@ -117,7 +117,7 @@ xinet_ntop(int af, const void *src, char *dst, size_t size) return (inet_ntop6((const u_char*)src, dst, size)); default: errno = EAFNOSUPPORT; - return (NULL); + return nullptr; } /* NOTREACHED */ } @@ -141,7 +141,7 @@ inet_ntop4(const u_char *src, char *dst, size_t size) if ((size_t)snprintf(tmp, min(sizeof(tmp),size), fmt, src[0], src[1], src[2], src[3]) >= size) { errno = ENOSPC; - return (NULL); + return nullptr; } strcpy(dst, tmp); return (dst); @@ -221,7 +221,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size) (best.len == 7 && words[7] != 0x0001) || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) - return (NULL); + return nullptr; tp += strlen(tp); break; } @@ -238,7 +238,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size) */ if ((size_t)(tp - tmp) > size) { errno = ENOSPC; - return (NULL); + return nullptr; } strcpy(dst, tmp); return (dst); diff --git a/compat/inet_pton.cc b/compat/inet_pton.cc index 2ec56d7173..e95ee8e7b7 100644 --- a/compat/inet_pton.cc +++ b/compat/inet_pton.cc @@ -143,7 +143,7 @@ inet_pton4(const char *src, u_char *dst) while ((ch = *src++) != '\0') { const char *pch; - if ((pch = strchr(digits, ch)) != NULL) { + if ((pch = strchr(digits, ch))) { u_int nw = *tp * 10 + (pch - digits); if (saw_digit && *tp == 0) @@ -195,7 +195,7 @@ inet_pton6(const char *src, u_char *dst) memset((tp = tmp), '\0', NS_IN6ADDRSZ); endp = tp + NS_IN6ADDRSZ; - colonp = NULL; + colonp = nullptr; /* Leading :: requires some special handling. */ if (*src == ':') if (*++src != ':') @@ -206,9 +206,9 @@ inet_pton6(const char *src, u_char *dst) while ((ch = *src++) != '\0') { const char *pch; - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + if (!(pch = strchr((xdigits = xdigits_l), ch))) pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { + if (pch) { val <<= 4; val |= (pch - xdigits); if (++seen_xdigits > 4) @@ -247,7 +247,7 @@ inet_pton6(const char *src, u_char *dst) *tp++ = (u_char) (val >> 8) & 0xff; *tp++ = (u_char) val & 0xff; } - if (colonp != NULL) { + if (colonp) { /* * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. diff --git a/compat/mswindows.cc b/compat/mswindows.cc index fa0ec3fcd6..987f4199c3 100644 --- a/compat/mswindows.cc +++ b/compat/mswindows.cc @@ -31,7 +31,7 @@ #endif THREADLOCAL int ws32_result; -LPCRITICAL_SECTION dbg_mutex = NULL; +LPCRITICAL_SECTION dbg_mutex = nullptr; void GetProcessName(pid_t, char *); @@ -66,7 +66,7 @@ GetProcessName(pid_t pid, char *ProcessName) /* Get a handle to the process. */ HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); /* Get the process name. */ - if (NULL != hProcess) { + if (hProcess) { HMODULE hMod; DWORD cbNeeded; @@ -90,9 +90,7 @@ kill(pid_t pid, int sig) char ProcessNameToCheck[MAX_PATH]; if (sig == 0) { - if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | - PROCESS_VM_READ, - FALSE, pid)) == NULL) + if (!(hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid))) return -1; else { CloseHandle(hProcess); @@ -136,9 +134,9 @@ WIN32_ftruncate(int fd, off_t size) return -1; hfile = (HANDLE) _get_osfhandle(fd); - curpos = SetFilePointer(hfile, 0, NULL, FILE_CURRENT); + curpos = SetFilePointer(hfile, 0, nullptr, FILE_CURRENT); if (curpos == 0xFFFFFFFF - || SetFilePointer(hfile, size, NULL, FILE_BEGIN) == 0xFFFFFFFF + || SetFilePointer(hfile, size, nullptr, FILE_BEGIN) == 0xFFFFFFFF || !SetEndOfFile(hfile)) { int error = GetLastError(); @@ -177,13 +175,13 @@ WIN32_truncate(const char *pathname, off_t length) struct passwd * getpwnam(char *unused) { - static struct passwd pwd = {NULL, NULL, 100, 100, NULL, NULL, NULL}; + static struct passwd pwd = {nullptr, nullptr, 100, 100, nullptr, nullptr, nullptr}; return &pwd; } struct group * getgrnam(char *unused) { - static struct group grp = {NULL, NULL, 100, NULL}; + static struct group grp = {nullptr, nullptr, 100, nullptr}; return &grp; } @@ -196,13 +194,13 @@ _free_osfhnd(int filehandle) (_osfhnd(filehandle) != (long) INVALID_HANDLE_VALUE)) { switch (filehandle) { case 0: - SetStdHandle(STD_INPUT_HANDLE, NULL); + SetStdHandle(STD_INPUT_HANDLE, nullptr); break; case 1: - SetStdHandle(STD_OUTPUT_HANDLE, NULL); + SetStdHandle(STD_OUTPUT_HANDLE, nullptr); break; case 2: - SetStdHandle(STD_ERROR_HANDLE, NULL); + SetStdHandle(STD_ERROR_HANDLE, nullptr); break; } _osfhnd(filehandle) = (long) INVALID_HANDLE_VALUE; @@ -301,9 +299,9 @@ openlog(const char *ident, int logopt, int facility) if (ms_eventlog) return; - ms_eventlog = RegisterEventSourceA(NULL, ident); + ms_eventlog = RegisterEventSourceA(nullptr, ident); - // note: RegisterEventAtSourceA may fail and return NULL. + // note: RegisterEventAtSourceA may fail and return nullptr. // in that case we'll just retry at the next message or not log } #define SYSLOG_MAX_MSG_SIZE 1024 @@ -349,8 +347,8 @@ syslog(int priority, const char *fmt, ...) } //Windows API suck. They are overengineered - ReportEventA(ms_eventlog, logtype, 0, 0, NULL, 1, 0, - const_cast(&str), NULL); + ReportEventA(ms_eventlog, logtype, 0, 0, nullptr, 1, 0, + const_cast(&str), nullptr); } /* note: this is all MSWindows-specific code; all of it should be conditional */ diff --git a/compat/shm.cc b/compat/shm.cc index 186939967d..976a1a89d2 100644 --- a/compat/shm.cc +++ b/compat/shm.cc @@ -27,7 +27,7 @@ shm_portable_segment_name_is_path() #elif _SQUID_FREEBSD_ int jailed = 0; size_t len = sizeof(jailed); - ::sysctlbyname("security.jail.jailed", &jailed, &len, NULL, 0); + ::sysctlbyname("security.jail.jailed", &jailed, &len, nullptr, 0); return !jailed; #else return false; diff --git a/compat/statvfs.cc b/compat/statvfs.cc index 5cad769174..bff7ea2b16 100644 --- a/compat/statvfs.cc +++ b/compat/statvfs.cc @@ -38,7 +38,7 @@ xstatvfs(const char *path, struct statvfs *sfs) errno = ENOENT; return -1; } - if (!GetVolumeInformation(drive, NULL, 0, &vsn, &maxlen, &flags, NULL, 0)) { + if (!GetVolumeInformation(drive, nullptr, 0, &vsn, &maxlen, &flags, nullptr, 0)) { errno = ENOENT; return -1; } diff --git a/compat/strnstr.cc b/compat/strnstr.cc index fee92c0448..295722a7f9 100644 --- a/compat/strnstr.cc +++ b/compat/strnstr.cc @@ -84,12 +84,12 @@ squid_strnstr(const char *s, const char *find, size_t slen) do { do { if (slen < 1 || (sc = *s) == '\0') - return (NULL); + return nullptr; --slen; ++s; } while (sc != c); if (len > slen) - return (NULL); + return nullptr; } while (strncmp(s, find, len) != 0); --s; } diff --git a/compat/xalloc.cc b/compat/xalloc.cc index b2f087cd61..d48608443a 100644 --- a/compat/xalloc.cc +++ b/compat/xalloc.cc @@ -78,7 +78,7 @@ xcalloc(size_t n, size_t sz) void *p = calloc(n, sz); - if (p == NULL) { + if (!p) { if (failure_notify) { static char msg[128]; snprintf(msg, 128, "xcalloc: Unable to allocate %" PRIuSIZE " blocks of %" PRIuSIZE " bytes!\n", n, sz); @@ -104,7 +104,7 @@ xmalloc(size_t sz) void *p = malloc(sz); - if (p == NULL) { + if (!p) { if (failure_notify) { static char msg[128]; snprintf(msg, 128, "xmalloc: Unable to allocate %" PRIuSIZE " bytes!\n", sz); @@ -130,7 +130,7 @@ xrealloc(void *s, size_t sz) void *p= realloc(s, sz); - if (p == NULL) { + if (!p) { if (failure_notify) { static char msg[128]; snprintf(msg, 128, "xrealloc: Unable to reallocate %" PRIuSIZE " bytes!\n", sz); diff --git a/compat/xalloc.h b/compat/xalloc.h index acd3f5293a..4d03a4bc15 100644 --- a/compat/xalloc.h +++ b/compat/xalloc.h @@ -15,7 +15,7 @@ extern "C" { /** * xcalloc() - same as calloc(3). Used for portability. - * Never returns NULL; fatal on error. + * Never returns nullptr; fatal on error. * * Define failure_notify to receive error message. * otherwise perror() is used to display it. @@ -24,7 +24,7 @@ void *xcalloc(size_t n, size_t sz); /** * xmalloc() - same as malloc(3). Used for portability. - * Never returns NULL; fatal on error. + * Never returns nullptr; fatal on error. * * Define failure_notify to receive error message. * otherwise perror() is used to display it. @@ -33,7 +33,7 @@ void *xmalloc(size_t sz); /** * xrealloc() - same as realloc(3). Used for portability. - * Never returns NULL; fatal on error. + * Never returns nullptr; fatal on error. */ void *xrealloc(void *s, size_t sz); @@ -49,10 +49,10 @@ void free_const(const void *s); /** * xfree() - same as free(3). Used for portability. * Accepts pointers to dynamically allocated const data. - * Will not call free(3) if the pointer is NULL. + * Will not call free(3) if the pointer is nullptr. * * Pointer is left with a value on completion. - * Use safe_free() if the pointer needs to be set to NULL afterward. + * Use safe_free() if the pointer needs to be set to nullptr afterward. * * Define failure_notify to receive error message. * otherwise perror() is used to display it. @@ -62,15 +62,15 @@ static inline void xfree(const void *p) { if (p) free_const(p); } /** * safe_free() - same as free(3). Used for portability. * Accepts pointers to dynamically allocated const data. - * Will not call free(3) if the pointer is NULL. - * Sets the pointer to NULL on completion. + * Will not call free(3) if the pointer is nullptr. + * Sets the pointer to nullptr on completion. * * Use xfree() if the pointer does not need to be set afterward. * * Define failure_notify to receive error message. * otherwise perror() is used to display it. */ -#define safe_free(x) while ((x)) { free_const((x)); (x) = NULL; } +#define safe_free(x) while ((x)) { free_const((x)); (x) = nullptr; } #ifdef __cplusplus } diff --git a/compat/xstrerror.h b/compat/xstrerror.h index 8eedefa7cf..d73e45890d 100644 --- a/compat/xstrerror.h +++ b/compat/xstrerror.h @@ -15,7 +15,7 @@ /** Provide the textual display of a system error number. * A string is always returned. - * Where strerror() would have provided NULL this will report the error as unknown. + * Where strerror() would have provided nullptr this will report the error as unknown. * On MS Windows the native Win32 errors are also translated. */ extern const char * xstrerr(int error); diff --git a/compat/xstring.cc b/compat/xstring.cc index 75295573da..27945527ad 100644 --- a/compat/xstring.cc +++ b/compat/xstring.cc @@ -17,10 +17,10 @@ xstrdup(const char *s) { if (!s) { if (failure_notify) { - (*failure_notify) ("xstrdup: tried to dup a NULL pointer!\n"); + (*failure_notify) ("xstrdup: tried to dup a nullptr!\n"); } else { errno = EINVAL; - perror("xstrdup: tried to dup a NULL pointer!"); + perror("xstrdup: tried to dup a nullptr!"); } exit(1); } @@ -58,9 +58,9 @@ xstrndup(const char *s, size_t n) if (!s) { errno = EINVAL; if (failure_notify) { - (*failure_notify) ("xstrndup: tried to dup a NULL pointer!\n"); + (*failure_notify) ("xstrndup: tried to dup a nullptr!\n"); } else { - perror("xstrndup: tried to dup a NULL pointer!"); + perror("xstrndup: tried to dup a nullptr!"); } exit(1); } diff --git a/compat/xstring.h b/compat/xstring.h index decdd829e9..131a353c9b 100644 --- a/compat/xstring.h +++ b/compat/xstring.h @@ -19,9 +19,9 @@ extern "C" { /** * xstrdup() - same as strdup(3). Used for portability. - * Never returns NULL; fatal on error. + * Never returns nullptr; fatal on error. * - * Sets errno to EINVAL if a NULL pointer is passed. + * Sets errno to EINVAL if a nullptr pointer is passed. * * Define failure_notify to receive error message. * otherwise perror() is used to display it. @@ -35,7 +35,7 @@ char *xstrdup(const char *s); /* * xstrncpy() - similar to strncpy(3) but terminates string - * always with '\0' if (n != 0 and dst != NULL), + * always with '\0' if (n != 0 and dst != nullptr), * and doesn't do padding */ char *xstrncpy(char *dst, const char *src, size_t n); @@ -45,9 +45,9 @@ char *xstrncpy(char *dst, const char *src, size_t n); * while strndup(3) copies up to n bytes and allocates up to n+1 bytes * to fit the terminating character. Assumes s is 0-terminated (another XXX). * - * Never returns NULL; fatal on error. + * Never returns nullptr; fatal on error. * - * Sets errno to EINVAL if a NULL pointer or negative + * Sets errno to EINVAL if a nullptr pointer or negative * length is passed. * * Define failure_notify to receive error message. diff --git a/compat/xstrto.cc b/compat/xstrto.cc index d6b8a6e4e2..aca00c638d 100644 --- a/compat/xstrto.cc +++ b/compat/xstrto.cc @@ -61,20 +61,20 @@ bool xstrtoul(const char *s, char **end, unsigned long *value, unsigned long min, unsigned long max) { - char *my_end = NULL; + char *my_end = nullptr; errno = 0; unsigned long v = strtoul(s, &my_end, 0); if (my_end == s) return false; - if (end != NULL) + if (end) *end = my_end; if (errno != ERANGE && min <= v && (max == 0 || v <= max)) { - if (value != NULL) + if (value) *value = v; - if (end == NULL) + if (!end) return *my_end == '\0'; return true; } @@ -88,7 +88,7 @@ xstrtoui(const char *s, char **end, unsigned int *value, { unsigned long v = 0; bool ret = xstrtoul(s, end, &v, min, max); - if (value != NULL) { + if (value) { *value = v; if (v != static_cast(*value)) { diff --git a/compat/xstrto.h b/compat/xstrto.h index ca8c0d3f28..f34165a859 100644 --- a/compat/xstrto.h +++ b/compat/xstrto.h @@ -20,7 +20,7 @@ * \param min minimum accepted value * \param max maximum accepted value * - * If @end is NULL, we assume the caller wants a "strict strtoul", and hence + * If @end is nullptr, we assume the caller wants a "strict strtoul", and hence * "15a" is rejected. * In either case, the value obtained is compared for min-max compliance. * Base is always 0, i.e. autodetect depending on @s.