diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 6d16cce2c87f10..3fb98c293c23d7 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -798,7 +798,7 @@ int ParseGeneralReply(Environment* env, status = ares_parse_ns_reply(buf, len, &host); break; case ns_t_ptr: - status = ares_parse_ptr_reply(buf, len, NULL, 0, AF_INET, &host); + status = ares_parse_ptr_reply(buf, len, nullptr, 0, AF_INET, &host); break; default: CHECK(0 && "Bad NS type"); @@ -830,7 +830,7 @@ int ParseGeneralReply(Environment* env, HostentToNames(env, host, ret); } else if (*type == ns_t_ptr) { uint32_t offset = ret->Length(); - for (uint32_t i = 0; host->h_aliases[i] != NULL; i++) { + for (uint32_t i = 0; host->h_aliases[i] != nullptr; i++) { ret->Set(context, i + offset, OneByteString(env->isolate(), host->h_aliases[i])).FromJust(); diff --git a/src/inspector_socket.cc b/src/inspector_socket.cc index 265b37616138dc..49d337b70b1198 100644 --- a/src/inspector_socket.cc +++ b/src/inspector_socket.cc @@ -577,7 +577,7 @@ int inspector_accept(uv_stream_t* server, InspectorSocket* socket, data_received_cb); } if (err != 0) { - uv_close(reinterpret_cast(tcp), NULL); + uv_close(reinterpret_cast(tcp), nullptr); } return err; } diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc index cdc907ee9b263b..958c41a654adff 100644 --- a/src/inspector_socket_server.cc +++ b/src/inspector_socket_server.cc @@ -94,7 +94,7 @@ void PrintDebuggerReadyMessage(const std::string& host, int port, const std::vector& ids, FILE* out) { - if (out == NULL) { + if (out == nullptr) { return; } for (const std::string& id : ids) { @@ -398,7 +398,7 @@ bool InspectorSocketServer::Start() { int err = uv_getaddrinfo(loop_, &req, nullptr, host_.c_str(), port_string.c_str(), &hints); if (err < 0) { - if (out_ != NULL) { + if (out_ != nullptr) { fprintf(out_, "Unable to resolve \"%s\": %s\n", host_.c_str(), uv_strerror(err)); } @@ -416,7 +416,7 @@ bool InspectorSocketServer::Start() { // We only show error if we failed to start server on all addresses. We only // show one error, for the last address. if (server_sockets_.empty()) { - if (out_ != NULL) { + if (out_ != nullptr) { fprintf(out_, "Starting inspector on %s:%d failed: %s\n", host_.c_str(), port_, uv_strerror(err)); fflush(out_); diff --git a/src/node.h b/src/node.h index 583e58cea47383..e6f47aa30075c4 100644 --- a/src/node.h +++ b/src/node.h @@ -108,14 +108,14 @@ namespace node { NODE_EXTERN v8::Local ErrnoException(v8::Isolate* isolate, int errorno, - const char* syscall = NULL, - const char* message = NULL, - const char* path = NULL); + const char* syscall = nullptr, + const char* message = nullptr, + const char* path = nullptr); NODE_EXTERN v8::Local UVException(v8::Isolate* isolate, int errorno, - const char* syscall = NULL, - const char* message = NULL, - const char* path = NULL); + const char* syscall = nullptr, + const char* message = nullptr, + const char* path = nullptr); NODE_EXTERN v8::Local UVException(v8::Isolate* isolate, int errorno, const char* syscall, @@ -126,9 +126,9 @@ NODE_EXTERN v8::Local UVException(v8::Isolate* isolate, NODE_DEPRECATED("Use ErrnoException(isolate, ...)", inline v8::Local ErrnoException( int errorno, - const char* syscall = NULL, - const char* message = NULL, - const char* path = NULL) { + const char* syscall = nullptr, + const char* message = nullptr, + const char* path = nullptr) { return ErrnoException(v8::Isolate::GetCurrent(), errorno, syscall, @@ -137,9 +137,9 @@ NODE_DEPRECATED("Use ErrnoException(isolate, ...)", }) inline v8::Local UVException(int errorno, - const char* syscall = NULL, - const char* message = NULL, - const char* path = NULL) { + const char* syscall = nullptr, + const char* message = nullptr, + const char* path = nullptr) { return UVException(v8::Isolate::GetCurrent(), errorno, syscall, @@ -426,14 +426,14 @@ NODE_DEPRECATED("Use DecodeWrite(isolate, ...)", NODE_EXTERN v8::Local WinapiErrnoException( v8::Isolate* isolate, int errorno, - const char *syscall = NULL, + const char *syscall = nullptr, const char *msg = "", - const char *path = NULL); + const char *path = nullptr); NODE_DEPRECATED("Use WinapiErrnoException(isolate, ...)", inline v8::Local WinapiErrnoException(int errorno, - const char *syscall = NULL, const char *msg = "", - const char *path = NULL) { + const char *syscall = nullptr, const char *msg = "", + const char *path = nullptr) { return WinapiErrnoException(v8::Isolate::GetCurrent(), errorno, syscall, @@ -501,13 +501,13 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); { \ NODE_MODULE_VERSION, \ flags, \ - NULL, \ + NULL, /* NOLINT (readability/null_usage) */ \ __FILE__, \ (node::addon_register_func) (regfunc), \ - NULL, \ + NULL, /* NOLINT (readability/null_usage) */ \ NODE_STRINGIFY(modname), \ priv, \ - NULL \ + NULL /* NOLINT (readability/null_usage) */ \ }; \ NODE_C_CTOR(_register_ ## modname) { \ node_module_register(&_module); \ @@ -520,13 +520,13 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); { \ NODE_MODULE_VERSION, \ flags, \ - NULL, \ + NULL, /* NOLINT (readability/null_usage) */ \ __FILE__, \ - NULL, \ + NULL, /* NOLINT (readability/null_usage) */ \ (node::addon_context_register_func) (regfunc), \ NODE_STRINGIFY(modname), \ priv, \ - NULL \ + NULL /* NOLINT (readability/null_usage) */ \ }; \ NODE_C_CTOR(_register_ ## modname) { \ node_module_register(&_module); \ @@ -534,9 +534,10 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); } #define NODE_MODULE(modname, regfunc) \ - NODE_MODULE_X(modname, regfunc, NULL, 0) + NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) #define NODE_MODULE_CONTEXT_AWARE(modname, regfunc) \ + /* NOLINTNEXTLINE (readability/null_usage) */ \ NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0) /* diff --git a/src/node_api.h b/src/node_api.h index 8e5eef8a47728f..ee0ad3518e13aa 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -100,7 +100,7 @@ typedef struct { EXTERN_C_END #define NAPI_MODULE(modname, regfunc) \ - NAPI_MODULE_X(modname, regfunc, NULL, 0) + NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) #define NAPI_AUTO_LENGTH SIZE_MAX diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 008ac469185b55..138c26685fcffc 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -1210,7 +1210,7 @@ static void EncodeUtf8String(const FunctionCallbackInfo& args) { char* data = node::UncheckedMalloc(length); str->WriteUtf8(data, -1, // We are certain that `data` is sufficiently large - NULL, + nullptr, String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8); auto array_buf = ArrayBuffer::New(env->isolate(), data, length, ArrayBufferCreationMode::kInternalized); diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 1b3e5004f71056..741fd466681196 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1775,7 +1775,7 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) { return false; GENERAL_NAMES* names = static_cast(X509V3_EXT_d2i(ext)); - if (names == NULL) + if (names == nullptr) return false; for (int i = 0; i < sk_GENERAL_NAME_num(names); i++) { @@ -1791,8 +1791,8 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) { BIO_write(out, name->data, name->length); } else { STACK_OF(CONF_VALUE)* nval = i2v_GENERAL_NAME( - const_cast(method), gen, NULL); - if (nval == NULL) + const_cast(method), gen, nullptr); + if (nval == nullptr) return false; X509V3_EXT_val_prn(out, nval, 0, 0); sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); @@ -6094,7 +6094,7 @@ void InitCryptoOnce() { if (0 != err) { fprintf(stderr, "openssl config failed: %s\n", - ERR_error_string(err, NULL)); + ERR_error_string(err, nullptr)); CHECK_NE(err, 0); } } @@ -6117,7 +6117,9 @@ void InitCryptoOnce() { } } if (0 != err) { - fprintf(stderr, "openssl fips failed: %s\n", ERR_error_string(err, NULL)); + fprintf(stderr, + "openssl fips failed: %s\n", + ERR_error_string(err, nullptr)); UNREACHABLE(); } #endif // NODE_FIPS_MODE diff --git a/src/node_http2.cc b/src/node_http2.cc index 465c045c661dad..b763ff0dbe5ab1 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1792,7 +1792,7 @@ void Http2Session::Goaway(const FunctionCallbackInfo& args) { int32_t lastStreamID = args[1]->Int32Value(context).ToChecked(); Local opaqueData = args[2]; - uint8_t* data = NULL; + uint8_t* data = nullptr; size_t length = 0; if (opaqueData->BooleanValue(context).ToChecked()) { diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 101ae4c79e42d2..041eda94f3bdd5 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -114,21 +114,21 @@ MaybeLocal ToBufferEndian(Environment* env, MaybeStackBuffer* buf) { } struct Converter { - explicit Converter(const char* name, const char* sub = NULL) + explicit Converter(const char* name, const char* sub = nullptr) : conv(nullptr) { UErrorCode status = U_ZERO_ERROR; conv = ucnv_open(name, &status); CHECK(U_SUCCESS(status)); - if (sub != NULL) { + if (sub != nullptr) { ucnv_setSubstChars(conv, sub, strlen(sub), &status); } } explicit Converter(UConverter* converter, - const char* sub = NULL) : conv(converter) { + const char* sub = nullptr) : conv(converter) { CHECK_NE(conv, nullptr); UErrorCode status = U_ZERO_ERROR; - if (sub != NULL) { + if (sub != nullptr) { ucnv_setSubstChars(conv, sub, strlen(sub), &status); } } @@ -229,7 +229,7 @@ class ConverterObject : public BaseObject, Converter { ucnv_toUnicode(converter->conv, &target, target + (limit * sizeof(UChar)), &source, source + source_length, - NULL, flush, &status); + nullptr, flush, &status); if (U_SUCCESS(status)) { if (limit > 0) @@ -254,7 +254,7 @@ class ConverterObject : public BaseObject, Converter { v8::Local wrap, UConverter* converter, bool ignoreBOM, - const char* sub = NULL) : + const char* sub = nullptr) : BaseObject(env, wrap), Converter(converter, sub), ignoreBOM_(ignoreBOM) { @@ -427,7 +427,7 @@ const char* EncodingName(const enum encoding encoding) { case LATIN1: return "iso8859-1"; case UCS2: return "utf16le"; case UTF8: return "utf-8"; - default: return NULL; + default: return nullptr; } } diff --git a/src/node_os.cc b/src/node_os.cc index f6dbf76b4c8602..6698531998c852 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -382,7 +382,7 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { &error); MaybeLocal shell; - if (pwd.shell == NULL) + if (pwd.shell == nullptr) shell = Null(env->isolate()); else shell = StringBytes::Encode(env->isolate(), pwd.shell, encoding, &error); diff --git a/src/node_url.cc b/src/node_url.cc index 67c6986da876c8..e26522765b9559 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -752,7 +752,7 @@ static inline int64_t ParseNumber(const char* start, const char* end) { } p++; } - return strtoll(start, NULL, R); + return strtoll(start, nullptr, R); } static url_host_type ParseIPv4Host(url_host* host, diff --git a/src/node_win32_etw_provider-inl.h b/src/node_win32_etw_provider-inl.h index 3c90bee67d26f3..98a28f14f45a15 100644 --- a/src/node_win32_etw_provider-inl.h +++ b/src/node_win32_etw_provider-inl.h @@ -115,7 +115,7 @@ extern int events_enabled; DWORD status = event_write(node_provider, \ &eventDescriptor, \ 0, \ - NULL); \ + NULL); // NOLINT (readability/null_usage) \ CHECK_EQ(status, ERROR_SUCCESS); diff --git a/src/tracing/node_trace_buffer.cc b/src/tracing/node_trace_buffer.cc index c8d71b762ef1de..4c9f7c658fd945 100644 --- a/src/tracing/node_trace_buffer.cc +++ b/src/tracing/node_trace_buffer.cc @@ -32,7 +32,7 @@ TraceObject* InternalTraceBuffer::GetEventByHandle(uint64_t handle) { Mutex::ScopedLock scoped_lock(mutex_); if (handle == 0) { // A handle value of zero never has a trace event associated with it. - return NULL; + return nullptr; } size_t chunk_index, event_index; uint32_t buffer_id, chunk_seq; @@ -41,12 +41,12 @@ TraceObject* InternalTraceBuffer::GetEventByHandle(uint64_t handle) { // Either the chunk belongs to the other buffer, or is outside the current // range of chunks loaded in memory (the latter being true suggests that // the chunk has already been flushed and is no longer in memory.) - return NULL; + return nullptr; } auto& chunk = chunks_[chunk_index]; if (chunk->seq() != chunk_seq) { // Chunk is no longer in memory. - return NULL; + return nullptr; } return chunk->GetEventAt(event_index); } diff --git a/src/tracing/node_trace_writer.cc b/src/tracing/node_trace_writer.cc index ff3c981d103d09..9293e9cb8f7b4a 100644 --- a/src/tracing/node_trace_writer.cc +++ b/src/tracing/node_trace_writer.cc @@ -60,7 +60,7 @@ void NodeTraceWriter::OpenNewFileForStreaming() { std::ostringstream log_file; log_file << "node_trace." << file_num_ << ".log"; fd_ = uv_fs_open(tracing_loop_, &req, log_file.str().c_str(), - O_CREAT | O_WRONLY | O_TRUNC, 0644, NULL); + O_CREAT | O_WRONLY | O_TRUNC, 0644, nullptr); CHECK_NE(fd_, -1); uv_fs_req_cleanup(&req); } diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h index 2b4c1e36cf9156..44a30f38e59394 100644 --- a/src/tracing/trace_event.h +++ b/src/tracing/trace_event.h @@ -518,7 +518,7 @@ static inline uint64_t AddTraceEvent( class ScopedTracer { public: // Note: members of data_ intentionally left uninitialized. See Initialize. - ScopedTracer() : p_data_(NULL) {} + ScopedTracer() : p_data_(nullptr) {} ~ScopedTracer() { if (p_data_ && *data_.category_group_enabled) diff --git a/test/addons-napi/7_factory_wrap/binding.cc b/test/addons-napi/7_factory_wrap/binding.cc index c8fca4d536e74c..d98132457875a1 100644 --- a/test/addons-napi/7_factory_wrap/binding.cc +++ b/test/addons-napi/7_factory_wrap/binding.cc @@ -16,6 +16,7 @@ napi_value Init(napi_env env, napi_value exports) { NAPI_CALL(env, MyObject::Init(env)); NAPI_CALL(env, + // NOLINTNEXTLINE (readability/null_usage) napi_create_function(env, "exports", -1, CreateObject, NULL, &exports)); return exports; } diff --git a/test/addons-napi/test_make_callback/binding.cc b/test/addons-napi/test_make_callback/binding.cc index 4b0537ca07cf17..952dfcc1cb5bec 100644 --- a/test/addons-napi/test_make_callback/binding.cc +++ b/test/addons-napi/test_make_callback/binding.cc @@ -8,6 +8,7 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { const int kMaxArgs = 10; size_t argc = kMaxArgs; napi_value args[kMaxArgs]; + // NOLINTNEXTLINE (readability/null_usage) NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); NAPI_ASSERT(env, argc > 0, "Wrong number of arguments"); @@ -47,6 +48,7 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { napi_value Init(napi_env env, napi_value exports) { napi_value fn; NAPI_CALL(env, napi_create_function( + // NOLINTNEXTLINE (readability/null_usage) env, NULL, NAPI_AUTO_LENGTH, MakeCallback, NULL, &fn)); NAPI_CALL(env, napi_set_named_property(env, exports, "makeCallback", fn)); return exports; diff --git a/test/addons-napi/test_make_callback_recurse/binding.cc b/test/addons-napi/test_make_callback_recurse/binding.cc index 714e44773de623..b99c583d31d9f9 100644 --- a/test/addons-napi/test_make_callback_recurse/binding.cc +++ b/test/addons-napi/test_make_callback_recurse/binding.cc @@ -7,6 +7,7 @@ namespace { napi_value MakeCallback(napi_env env, napi_callback_info info) { size_t argc = 2; napi_value args[2]; + // NOLINTNEXTLINE (readability/null_usage) NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); napi_value recv = args[0]; @@ -21,6 +22,7 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { napi_value Init(napi_env env, napi_value exports) { napi_value fn; NAPI_CALL(env, napi_create_function( + // NOLINTNEXTLINE (readability/null_usage) env, NULL, NAPI_AUTO_LENGTH, MakeCallback, NULL, &fn)); NAPI_CALL(env, napi_set_named_property(env, exports, "makeCallback", fn)); return exports; diff --git a/test/addons/repl-domain-abort/binding.cc b/test/addons/repl-domain-abort/binding.cc index d6a825dfdd5dd8..1b4dbfa84e5054 100644 --- a/test/addons/repl-domain-abort/binding.cc +++ b/test/addons/repl-domain-abort/binding.cc @@ -35,7 +35,7 @@ void Method(const FunctionCallbackInfo& args) { isolate->GetCurrentContext()->Global(), args[0].As(), 0, - NULL); + nullptr); } void init(Local exports) { diff --git a/test/cctest/test_inspector_socket_server.cc b/test/cctest/test_inspector_socket_server.cc index 5eff9d706b2a3a..ab74917234eefb 100644 --- a/test/cctest/test_inspector_socket_server.cc +++ b/test/cctest/test_inspector_socket_server.cc @@ -313,7 +313,7 @@ class ServerHolder { public: template ServerHolder(Delegate* delegate, uv_loop_t* loop, int port) - : ServerHolder(delegate, loop, HOST, port, NULL) { } + : ServerHolder(delegate, loop, HOST, port, nullptr) { } template ServerHolder(Delegate* delegate, uv_loop_t* loop, const std::string host, @@ -617,7 +617,7 @@ TEST_F(InspectorSocketServerTest, BindsToIpV6) { return; } TestInspectorServerDelegate delegate; - ServerHolder server(&delegate, &loop, "::", 0, NULL); + ServerHolder server(&delegate, &loop, "::", 0, nullptr); ASSERT_TRUE(server->Start()); SocketWrapper socket1(&loop); diff --git a/tools/cpplint.py b/tools/cpplint.py index ca42ddeb7bc477..460c1ecbfeb02f 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -499,7 +499,6 @@ _ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') - # These constants define types of headers for use with # _IncludeState.CheckNextIncludeOrder(). _C_SYS_HEADER = 1 @@ -526,6 +525,8 @@ # Match string that indicates we're working on a Linux Kernel file. _SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)') +_NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b') + _regexp_compile_cache = {} # {str, set(int)}: a map from error categories to sets of linenumbers @@ -4156,6 +4157,27 @@ def CheckAltTokens(filename, clean_lines, linenum, error): 'Use operator %s instead of %s' % ( _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) +def CheckNullTokens(filename, clean_lines, linenum, error): + """Check NULL usage. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + # Avoid preprocessor lines + if Match(r'^\s*#', line): + return + + if line.find('/*') >= 0 or line.find('*/') >= 0: + return + + for match in _NULL_TOKEN_PATTERN.finditer(line): + error(filename, linenum, 'readability/null_usage', 2, + 'Use nullptr instead of NULL') def GetLineWidth(line): """Determines the width of the line in column positions. @@ -4294,6 +4316,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) CheckCheck(filename, clean_lines, linenum, error) CheckAltTokens(filename, clean_lines, linenum, error) + CheckNullTokens(filename, clean_lines, linenum, error) classinfo = nesting_state.InnermostClass() if classinfo: CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) diff --git a/tools/icu/iculslocs.cc b/tools/icu/iculslocs.cc index 485a179deb2e04..ca312b783565c4 100644 --- a/tools/icu/iculslocs.cc +++ b/tools/icu/iculslocs.cc @@ -231,14 +231,14 @@ int dumpAllButInstalledLocales(int lev, int list(const char* toBundle) { UErrorCode status = U_ZERO_ERROR; - FILE* bf = NULL; + FILE* bf = NULL; // NOLINT (readability/null_usage) - if (toBundle != NULL) { + if (toBundle != NULL) { // NOLINT (readability/null_usage) if (VERBOSE) { printf("writing to bundle %s\n", toBundle); } bf = fopen(toBundle, "wb"); - if (bf == NULL) { + if (bf == NULL) { // NOLINT (readability/null_usage) printf("ERROR: Could not open '%s' for writing.\n", toBundle); return 1; } @@ -258,6 +258,7 @@ int list(const char* toBundle) { ures_openDirect(packageName.data(), locale, &status)); ASSERT_SUCCESS(&status, "while opening the bundle"); LocalUResourceBundlePointer installedLocales( + // NOLINTNEXTLINE (readability/null_usage) ures_getByKey(bund.getAlias(), INSTALLEDLOCALES, NULL, &status)); ASSERT_SUCCESS(&status, "while fetching installed locales"); @@ -266,7 +267,7 @@ int list(const char* toBundle) { printf("Locales: %d\n", count); } - if (bf != NULL) { + if (bf != NULL) { // NOLINT (readability/null_usage) // write the HEADER fprintf(bf, "// Warning this file is automatically generated\n" @@ -310,17 +311,17 @@ int list(const char* toBundle) { UBool exists; if (localeExists(key, &exists)) { - if (bf != NULL) fclose(bf); + if (bf != NULL) fclose(bf); // NOLINT (readability/null_usage) return 1; // get out. } if (exists) { validCount++; printf("%s\n", key); - if (bf != NULL) { + if (bf != NULL) { // NOLINT (readability/null_usage) fprintf(bf, " %s {\"\"}\n", key); } } else { - if (bf != NULL) { + if (bf != NULL) { // NOLINT (readability/null_usage) fprintf(bf, "// %s {\"\"}\n", key); } if (VERBOSE) { @@ -329,7 +330,7 @@ int list(const char* toBundle) { } } - if (bf != NULL) { + if (bf != NULL) { // NOLINT (readability/null_usage) fprintf(bf, " } // %d/%d valid\n", validCount, count); // write the HEADER fprintf(bf, "}\n"); @@ -371,7 +372,7 @@ int main(int argc, const char* argv[]) { usage(); return 0; } else if (!strcmp(arg, "-l")) { - if (list(NULL)) { + if (list(NULL)) { // NOLINT (readability/null_usage) return 1; } } else if (!strcmp(arg, "-b") && (argsLeft >= 1)) {