| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ceda8c5 commit 1e34a0e
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -501,13 +501,13 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); | |||
| 501 | 501 | { \ | |
| 502 | 502 | NODE_MODULE_VERSION, \ | |
| 503 | 503 | flags, \ | |
| 504 | - NULL, \ | ||
| 504 | + NULL, /* NOLINT (readability/null_usage) */ \ | ||
| 505 | 505 | __FILE__, \ | |
| 506 | 506 | (node::addon_register_func) (regfunc), \ | |
| 507 | - NULL, \ | ||
| 507 | + NULL, /* NOLINT (readability/null_usage) */ \ | ||
| 508 | 508 | NODE_STRINGIFY(modname), \ | |
| 509 | 509 | priv, \ | |
| 510 | - NULL \ | ||
| 510 | + NULL /* NOLINT (readability/null_usage) */ \ | ||
| 511 | 511 | }; \ | |
| 512 | 512 | NODE_C_CTOR(_register_ ## modname) { \ | |
| 513 | 513 | node_module_register(&_module); \ | |
@@ -520,23 +520,24 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); | |||
| 520 | 520 | { \ | |
| 521 | 521 | NODE_MODULE_VERSION, \ | |
| 522 | 522 | flags, \ | |
| 523 | - NULL, \ | ||
| 523 | + NULL, /* NOLINT (readability/null_usage) */ \ | ||
| 524 | 524 | __FILE__, \ | |
| 525 | - NULL, \ | ||
| 525 | + NULL, /* NOLINT (readability/null_usage) */ \ | ||
| 526 | 526 | (node::addon_context_register_func) (regfunc), \ | |
| 527 | 527 | NODE_STRINGIFY(modname), \ | |
| 528 | 528 | priv, \ | |
| 529 | - NULL \ | ||
| 529 | + NULL /* NOLINT (readability/null_usage) */ \ | ||
| 530 | 530 | }; \ | |
| 531 | 531 | NODE_C_CTOR(_register_ ## modname) { \ | |
| 532 | 532 | node_module_register(&_module); \ | |
| 533 | 533 | } \ | |
| 534 | 534 | } | |
| 535 | 535 | ||
| 536 | 536 | #define NODE_MODULE(modname, regfunc) \ | |
| 537 | - NODE_MODULE_X(modname, regfunc, NULL, 0) | ||
| 537 | + NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) | ||
| 538 | 538 | ||
| 539 | 539 | #define NODE_MODULE_CONTEXT_AWARE(modname, regfunc) \ | |
| 540 | + /* NOLINTNEXTLINE (readability/null_usage) */ \ | ||
| 540 | 541 | NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0) | |
| 541 | 542 | ||
| 542 | 543 | /* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,7 +100,7 @@ typedef struct { | |||
| 100 | 100 | EXTERN_C_END | |
| 101 | 101 | ||
| 102 | 102 | #define NAPI_MODULE(modname, regfunc) \ | |
| 103 | - NAPI_MODULE_X(modname, regfunc, NULL, 0) | ||
| 103 | + NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) | ||
| 104 | 104 | ||
| 105 | 105 | #define NAPI_AUTO_LENGTH SIZE_MAX | |
| 106 | 106 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -115,7 +115,7 @@ extern int events_enabled; | |||
| 115 | 115 | DWORD status = event_write(node_provider, \ | |
| 116 | 116 | &eventDescriptor, \ | |
| 117 | 117 | 0, \ | |
| 118 | - NULL); \ | ||
| 118 | + NULL); // NOLINT (readability/null_usage) \ | ||
| 119 | 119 | CHECK_EQ(status, ERROR_SUCCESS); | |
| 120 | 120 | ||
| 121 | 121 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ napi_value Init(napi_env env, napi_value exports) { | |||
| 16 | 16 | NAPI_CALL(env, MyObject::Init(env)); | |
| 17 | 17 | ||
| 18 | 18 | NAPI_CALL(env, | |
| 19 | + // NOLINTNEXTLINE (readability/null_usage) | ||
| 19 | 20 | napi_create_function(env, "exports", -1, CreateObject, NULL, &exports)); | |
| 20 | 21 | return exports; | |
| 21 | 22 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { | |||
| 8 | 8 | const int kMaxArgs = 10; | |
| 9 | 9 | size_t argc = kMaxArgs; | |
| 10 | 10 | napi_value args[kMaxArgs]; | |
| 11 | + // NOLINTNEXTLINE (readability/null_usage) | ||
| 11 | 12 | NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); | |
| 12 | 13 | ||
| 13 | 14 | NAPI_ASSERT(env, argc > 0, "Wrong number of arguments"); | |
@@ -47,6 +48,7 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { | |||
| 47 | 48 | napi_value Init(napi_env env, napi_value exports) { | |
| 48 | 49 | napi_value fn; | |
| 49 | 50 | NAPI_CALL(env, napi_create_function( | |
| 51 | + // NOLINTNEXTLINE (readability/null_usage) | ||
| 50 | 52 | env, NULL, NAPI_AUTO_LENGTH, MakeCallback, NULL, &fn)); | |
| 51 | 53 | NAPI_CALL(env, napi_set_named_property(env, exports, "makeCallback", fn)); | |
| 52 | 54 | return exports; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ namespace { | |||
| 7 | 7 | napi_value MakeCallback(napi_env env, napi_callback_info info) { | |
| 8 | 8 | size_t argc = 2; | |
| 9 | 9 | napi_value args[2]; | |
| 10 | + // NOLINTNEXTLINE (readability/null_usage) | ||
| 10 | 11 | NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); | |
| 11 | 12 | ||
| 12 | 13 | napi_value recv = args[0]; | |
@@ -21,6 +22,7 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { | |||
| 21 | 22 | napi_value Init(napi_env env, napi_value exports) { | |
| 22 | 23 | napi_value fn; | |
| 23 | 24 | NAPI_CALL(env, napi_create_function( | |
| 25 | + // NOLINTNEXTLINE (readability/null_usage) | ||
| 24 | 26 | env, NULL, NAPI_AUTO_LENGTH, MakeCallback, NULL, &fn)); | |
| 25 | 27 | NAPI_CALL(env, napi_set_named_property(env, exports, "makeCallback", fn)); | |
| 26 | 28 | return exports; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -499,7 +499,6 @@ | |||
| 499 | 499 | _ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( | |
| 500 | 500 | r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') | |
| 501 | 501 | ||
| 502 | - | ||
| 503 | 502 | # These constants define types of headers for use with | |
| 504 | 503 | # _IncludeState.CheckNextIncludeOrder(). | |
| 505 | 504 | _C_SYS_HEADER = 1 | |
@@ -526,6 +525,8 @@ | |||
| 526 | 525 | # Match string that indicates we're working on a Linux Kernel file. | |
| 527 | 526 | _SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)') | |
| 528 | 527 | ||
| 528 | + _NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b') | ||
| 529 | + | ||
| 529 | 530 | _regexp_compile_cache = {} | |
| 530 | 531 | ||
| 531 | 532 | # {str, set(int)}: a map from error categories to sets of linenumbers | |
@@ -4156,6 +4157,27 @@ def CheckAltTokens(filename, clean_lines, linenum, error): | |||
| 4156 | 4157 | 'Use operator %s instead of %s' % ( | |
| 4157 | 4158 | _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) | |
| 4158 | 4159 | ||
| 4160 | + def CheckNullTokens(filename, clean_lines, linenum, error): | ||
| 4161 | + """Check NULL usage. | ||
| 4162 | + | ||
| 4163 | + Args: | ||
| 4164 | + filename: The name of the current file. | ||
| 4165 | + clean_lines: A CleansedLines instance containing the file. | ||
| 4166 | + linenum: The number of the line to check. | ||
| 4167 | + error: The function to call with any errors found. | ||
| 4168 | + """ | ||
| 4169 | + line = clean_lines.elided[linenum] | ||
| 4170 | + | ||
| 4171 | + # Avoid preprocessor lines | ||
| 4172 | + if Match(r'^\s*#', line): | ||
| 4173 | + return | ||
| 4174 | + | ||
| 4175 | + if line.find('/*') >= 0 or line.find('*/') >= 0: | ||
| 4176 | + return | ||
| 4177 | + | ||
| 4178 | + for match in _NULL_TOKEN_PATTERN.finditer(line): | ||
| 4179 | + error(filename, linenum, 'readability/null_usage', 2, | ||
| 4180 | + 'Use nullptr instead of NULL') | ||
| 4159 | 4181 | ||
| 4160 | 4182 | def GetLineWidth(line): | |
| 4161 | 4183 | """Determines the width of the line in column positions. | |
@@ -4294,6 +4316,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, | |||
| 4294 | 4316 | CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) | |
| 4295 | 4317 | CheckCheck(filename, clean_lines, linenum, error) | |
| 4296 | 4318 | CheckAltTokens(filename, clean_lines, linenum, error) | |
| 4319 | + CheckNullTokens(filename, clean_lines, linenum, error) | ||
| 4297 | 4320 | classinfo = nesting_state.InnermostClass() | |
| 4298 | 4321 | if classinfo: | |
| 4299 | 4322 | CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -231,14 +231,14 @@ int dumpAllButInstalledLocales(int lev, | |||
| 231 | 231 | int list(const char* toBundle) { | |
| 232 | 232 | UErrorCode status = U_ZERO_ERROR; | |
| 233 | 233 | ||
| 234 | - FILE* bf = NULL; | ||
| 234 | + FILE* bf = NULL; // NOLINT (readability/null_usage) | ||
| 235 | 235 | ||
| 236 | - if (toBundle != NULL) { | ||
| 236 | + if (toBundle != NULL) { // NOLINT (readability/null_usage) | ||
| 237 | 237 | if (VERBOSE) { | |
| 238 | 238 | printf("writing to bundle %s\n", toBundle); | |
| 239 | 239 | } | |
| 240 | 240 | bf = fopen(toBundle, "wb"); | |
| 241 | - if (bf == NULL) { | ||
| 241 | + if (bf == NULL) { // NOLINT (readability/null_usage) | ||
| 242 | 242 | printf("ERROR: Could not open '%s' for writing.\n", toBundle); | |
| 243 | 243 | return 1; | |
| 244 | 244 | } | |
@@ -258,6 +258,7 @@ int list(const char* toBundle) { | |||
| 258 | 258 | ures_openDirect(packageName.data(), locale, &status)); | |
| 259 | 259 | ASSERT_SUCCESS(&status, "while opening the bundle"); | |
| 260 | 260 | LocalUResourceBundlePointer installedLocales( | |
| 261 | + // NOLINTNEXTLINE (readability/null_usage) | ||
| 261 | 262 | ures_getByKey(bund.getAlias(), INSTALLEDLOCALES, NULL, &status)); | |
| 262 | 263 | ASSERT_SUCCESS(&status, "while fetching installed locales"); | |
| 263 | 264 | ||
@@ -266,7 +267,7 @@ int list(const char* toBundle) { | |||
| 266 | 267 | printf("Locales: %d\n", count); | |
| 267 | 268 | } | |
| 268 | 269 | ||
| 269 | - if (bf != NULL) { | ||
| 270 | + if (bf != NULL) { // NOLINT (readability/null_usage) | ||
| 270 | 271 | // write the HEADER | |
| 271 | 272 | fprintf(bf, | |
| 272 | 273 | "// Warning this file is automatically generated\n" | |
@@ -310,17 +311,17 @@ int list(const char* toBundle) { | |||
| 310 | 311 | ||
| 311 | 312 | UBool exists; | |
| 312 | 313 | if (localeExists(key, &exists)) { | |
| 313 | - if (bf != NULL) fclose(bf); | ||
| 314 | + if (bf != NULL) fclose(bf); // NOLINT (readability/null_usage) | ||
| 314 | 315 | return 1; // get out. | |
| 315 | 316 | } | |
| 316 | 317 | if (exists) { | |
| 317 | 318 | validCount++; | |
| 318 | 319 | printf("%s\n", key); | |
| 319 | - if (bf != NULL) { | ||
| 320 | + if (bf != NULL) { // NOLINT (readability/null_usage) | ||
| 320 | 321 | fprintf(bf, " %s {\"\"}\n", key); | |
| 321 | 322 | } | |
| 322 | 323 | } else { | |
| 323 | - if (bf != NULL) { | ||
| 324 | + if (bf != NULL) { // NOLINT (readability/null_usage) | ||
| 324 | 325 | fprintf(bf, "// %s {\"\"}\n", key); | |
| 325 | 326 | } | |
| 326 | 327 | if (VERBOSE) { | |
@@ -329,7 +330,7 @@ int list(const char* toBundle) { | |||
| 329 | 330 | } | |
| 330 | 331 | } | |
| 331 | 332 | ||
| 332 | - if (bf != NULL) { | ||
| 333 | + if (bf != NULL) { // NOLINT (readability/null_usage) | ||
| 333 | 334 | fprintf(bf, " } // %d/%d valid\n", validCount, count); | |
| 334 | 335 | // write the HEADER | |
| 335 | 336 | fprintf(bf, "}\n"); | |
@@ -371,7 +372,7 @@ int main(int argc, const char* argv[]) { | |||
| 371 | 372 | usage(); | |
| 372 | 373 | return 0; | |
| 373 | 374 | } else if (!strcmp(arg, "-l")) { | |
| 374 | - if (list(NULL)) { | ||
| 375 | + if (list(NULL)) { // NOLINT (readability/null_usage) | ||
| 375 | 376 | return 1; | |
| 376 | 377 | } | |
| 377 | 378 | } else if (!strcmp(arg, "-b") && (argsLeft >= 1)) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments