Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index 17e4372..7a67868 100644
--- a/libc/stdio/vfprintf.cpp
+++ b/libc/stdio/vfprintf.cpp
@@ -64,7 +64,7 @@
* D: expchar holds this character; '\0' if no exponent, e.g. %f
* F: at least two digits for decimal, at least one digit for hex
*/
- char* decimal_point = NULL;
+ char* decimal_point = nullptr;
int signflag; /* true if float is negative */
union { /* floating point arguments %[aAeEfFgG] */
double dbl;
@@ -77,7 +77,7 @@
int lead; /* sig figs before decimal or group sep */
int ndig; /* actual number of digits returned by dtoa */
CHAR_TYPE expstr[MAXEXPDIG + 2]; /* buffer for exponent string: e+ZZZ */
- char* dtoaresult = NULL;
+ char* dtoaresult = nullptr;
uintmax_t _umax; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */
@@ -146,14 +146,14 @@
}
CHAR_TYPE* fmt = const_cast<CHAR_TYPE*>(fmt0);
- argtable = NULL;
+ argtable = nullptr;
nextarg = 1;
va_copy(orgap, ap);
uio.uio_iov = iovp = iov;
uio.uio_resid = 0;
uio.uio_iovcnt = 0;
ret = 0;
- convbuf = NULL;
+ convbuf = nullptr;
/*
* Scan the format for conversions (`%' character).
@@ -226,7 +226,7 @@
}
if (ch == '$') {
nextarg = n;
- if (argtable == NULL) {
+ if (argtable == nullptr) {
argtable = statargtable;
if (__find_arguments(fmt0, orgap, &argtable, &argtablesiz) == -1) {
ret = -1;
@@ -261,7 +261,7 @@
} while (is_digit(ch));
if (ch == '$') {
nextarg = n;
- if (argtable == NULL) {
+ if (argtable == nullptr) {
argtable = statargtable;
if (__find_arguments(fmt0, orgap, &argtable, &argtablesiz) == -1) {
ret = -1;
@@ -353,14 +353,14 @@
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult = cp = __hldtoa(fparg.ldbl, xdigs, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
} else {
fparg.dbl = GETARG(double);
dtoaresult = cp = __hdtoa(fparg.dbl, xdigs, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
@@ -390,14 +390,14 @@
if (flags & LONGDBL) {
fparg.ldbl = GETARG(long double);
dtoaresult = cp = __ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
} else {
fparg.dbl = GETARG(double);
dtoaresult = cp = __dtoa(fparg.dbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend);
- if (dtoaresult == NULL) {
+ if (dtoaresult == nullptr) {
errno = ENOMEM;
goto error;
}
@@ -479,18 +479,18 @@
wchar_t* wcp;
free(convbuf);
- convbuf = NULL;
- if ((wcp = GETARG(wchar_t*)) == NULL) {
+ convbuf = nullptr;
+ if ((wcp = GETARG(wchar_t*)) == nullptr) {
cp = const_cast<char*>("(null)");
} else {
convbuf = helpers::wcsconv(wcp, prec);
- if (convbuf == NULL) {
+ if (convbuf == nullptr) {
ret = -1;
goto error;
}
cp = convbuf;
}
- } else if ((cp = GETARG(char*)) == NULL) {
+ } else if ((cp = GETARG(char*)) == nullptr) {
cp = const_cast<char*>("(null)");
}
if (prec >= 0) {
@@ -625,7 +625,7 @@
if ((flags & FPT) == 0) {
PRINT(cp, size);
} else { /* glue together f_p fragments */
- if (decimal_point == NULL) decimal_point = nl_langinfo(RADIXCHAR);
+ if (decimal_point == nullptr) decimal_point = nl_langinfo(RADIXCHAR);
if (!expchar) { /* %[fF] or sufficiently short %[gG] */
if (expt <= 0) {
PRINT(zeroes, 1);
@@ -676,9 +676,9 @@
finish:
free(convbuf);
if (dtoaresult) __freedtoa(dtoaresult);
- if (argtable != NULL && argtable != statargtable) {
+ if (argtable != nullptr && argtable != statargtable) {
munmap(argtable, argtablesiz);
- argtable = NULL;
+ argtable = nullptr;
}
return (ret);
}