| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,3 @@ | |||
| 1 | 1 | set noparent | |
| 2 | - filter=-build/include_alpha,-build/include_subdir,-build/include_what_you_use,-legal/copyright,-readability/nolint | ||
| 2 | + filter=-build/include_alpha,-build/include_subdir,-build/include_what_you_use,-legal/copyright,-readability/nolint,-readability/braces | ||
| 3 | 3 | linelength=80 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, | |||
| 74 | 74 | // We first check `env->context() != current_context` because the contexts | |
| 75 | 75 | // likely *are* the same, in which case we can skip the slightly more | |
| 76 | 76 | // expensive Environment::GetCurrent() call. | |
| 77 | - if (UNLIKELY(env->context() != current_context)) { | ||
| 77 | + if (env->context() != current_context) [[unlikely]] { | ||
| 78 | 78 | CHECK_EQ(Environment::GetCurrent(isolate), env); | |
| 79 | 79 | } | |
| 80 | 80 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,15 +108,17 @@ void* NodeArrayBufferAllocator::Allocate(size_t size) { | |||
| 108 | 108 | ret = allocator_->Allocate(size); | |
| 109 | 109 | else | |
| 110 | 110 | ret = allocator_->AllocateUninitialized(size); | |
| 111 | - if (LIKELY(ret != nullptr)) | ||
| 111 | + if (ret != nullptr) [[likely]] { | ||
| 112 | 112 | total_mem_usage_.fetch_add(size, std::memory_order_relaxed); | |
| 113 | + } | ||
| 113 | 114 | return ret; | |
| 114 | 115 | } | |
| 115 | 116 | ||
| 116 | 117 | void* NodeArrayBufferAllocator::AllocateUninitialized(size_t size) { | |
| 117 | 118 | void* ret = allocator_->AllocateUninitialized(size); | |
| 118 | - if (LIKELY(ret != nullptr)) | ||
| 119 | + if (ret != nullptr) [[likely]] { | ||
| 119 | 120 | total_mem_usage_.fetch_add(size, std::memory_order_relaxed); | |
| 121 | + } | ||
| 120 | 122 | return ret; | |
| 121 | 123 | } | |
| 122 | 124 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ BaseObject::~BaseObject() { | |||
| 32 | 32 | realm()->modify_base_object_count(-1); | |
| 33 | 33 | realm()->RemoveCleanupHook(DeleteMe, static_cast<void*>(this)); | |
| 34 | 34 | ||
| 35 | - if (UNLIKELY(has_pointer_data())) { | ||
| 35 | + if (has_pointer_data()) [[unlikely]] { | ||
| 36 | 36 | PointerData* metadata = pointer_data(); | |
| 37 | 37 | CHECK_EQ(metadata->strong_ptr_count, 0); | |
| 38 | 38 | metadata->self = nullptr; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -892,8 +892,9 @@ int SoaTraits::Send(QueryWrap<SoaTraits>* wrap, const char* name) { | |||
| 892 | 892 | int AnyTraits::Parse( | |
| 893 | 893 | QueryAnyWrap* wrap, | |
| 894 | 894 | const std::unique_ptr<ResponseData>& response) { | |
| 895 | - if (UNLIKELY(response->is_host)) | ||
| 895 | + if (response->is_host) [[unlikely]] { | ||
| 896 | 896 | return ARES_EBADRESP; | |
| 897 | + } | ||
| 897 | 898 | ||
| 898 | 899 | unsigned char* buf = response->buf.data; | |
| 899 | 900 | int len = response->buf.size; | |
@@ -1059,8 +1060,9 @@ int AnyTraits::Parse( | |||
| 1059 | 1060 | int ATraits::Parse( | |
| 1060 | 1061 | QueryAWrap* wrap, | |
| 1061 | 1062 | const std::unique_ptr<ResponseData>& response) { | |
| 1062 | - if (UNLIKELY(response->is_host)) | ||
| 1063 | + if (response->is_host) [[unlikely]] { | ||
| 1063 | 1064 | return ARES_EBADRESP; | |
| 1065 | + } | ||
| 1064 | 1066 | ||
| 1065 | 1067 | unsigned char* buf = response->buf.data; | |
| 1066 | 1068 | int len = response->buf.size; | |
@@ -1093,8 +1095,9 @@ int ATraits::Parse( | |||
| 1093 | 1095 | int AaaaTraits::Parse( | |
| 1094 | 1096 | QueryAaaaWrap* wrap, | |
| 1095 | 1097 | const std::unique_ptr<ResponseData>& response) { | |
| 1096 | - if (UNLIKELY(response->is_host)) | ||
| 1098 | + if (response->is_host) [[unlikely]] { | ||
| 1097 | 1099 | return ARES_EBADRESP; | |
| 1100 | + } | ||
| 1098 | 1101 | ||
| 1099 | 1102 | unsigned char* buf = response->buf.data; | |
| 1100 | 1103 | int len = response->buf.size; | |
@@ -1127,8 +1130,9 @@ int AaaaTraits::Parse( | |||
| 1127 | 1130 | int CaaTraits::Parse( | |
| 1128 | 1131 | QueryCaaWrap* wrap, | |
| 1129 | 1132 | const std::unique_ptr<ResponseData>& response) { | |
| 1130 | - if (UNLIKELY(response->is_host)) | ||
| 1133 | + if (response->is_host) [[unlikely]] { | ||
| 1131 | 1134 | return ARES_EBADRESP; | |
| 1135 | + } | ||
| 1132 | 1136 | ||
| 1133 | 1137 | unsigned char* buf = response->buf.data; | |
| 1134 | 1138 | int len = response->buf.size; | |
@@ -1149,8 +1153,9 @@ int CaaTraits::Parse( | |||
| 1149 | 1153 | int CnameTraits::Parse( | |
| 1150 | 1154 | QueryCnameWrap* wrap, | |
| 1151 | 1155 | const std::unique_ptr<ResponseData>& response) { | |
| 1152 | - if (UNLIKELY(response->is_host)) | ||
| 1156 | + if (response->is_host) [[unlikely]] { | ||
| 1153 | 1157 | return ARES_EBADRESP; | |
| 1158 | + } | ||
| 1154 | 1159 | ||
| 1155 | 1160 | unsigned char* buf = response->buf.data; | |
| 1156 | 1161 | int len = response->buf.size; | |
@@ -1172,8 +1177,9 @@ int CnameTraits::Parse( | |||
| 1172 | 1177 | int MxTraits::Parse( | |
| 1173 | 1178 | QueryMxWrap* wrap, | |
| 1174 | 1179 | const std::unique_ptr<ResponseData>& response) { | |
| 1175 | - if (UNLIKELY(response->is_host)) | ||
| 1180 | + if (response->is_host) [[unlikely]] { | ||
| 1176 | 1181 | return ARES_EBADRESP; | |
| 1182 | + } | ||
| 1177 | 1183 | ||
| 1178 | 1184 | unsigned char* buf = response->buf.data; | |
| 1179 | 1185 | int len = response->buf.size; | |
@@ -1195,8 +1201,9 @@ int MxTraits::Parse( | |||
| 1195 | 1201 | int NsTraits::Parse( | |
| 1196 | 1202 | QueryNsWrap* wrap, | |
| 1197 | 1203 | const std::unique_ptr<ResponseData>& response) { | |
| 1198 | - if (UNLIKELY(response->is_host)) | ||
| 1204 | + if (response->is_host) [[unlikely]] { | ||
| 1199 | 1205 | return ARES_EBADRESP; | |
| 1206 | + } | ||
| 1200 | 1207 | ||
| 1201 | 1208 | unsigned char* buf = response->buf.data; | |
| 1202 | 1209 | int len = response->buf.size; | |
@@ -1218,8 +1225,9 @@ int NsTraits::Parse( | |||
| 1218 | 1225 | int TxtTraits::Parse( | |
| 1219 | 1226 | QueryTxtWrap* wrap, | |
| 1220 | 1227 | const std::unique_ptr<ResponseData>& response) { | |
| 1221 | - if (UNLIKELY(response->is_host)) | ||
| 1228 | + if (response->is_host) [[unlikely]] { | ||
| 1222 | 1229 | return ARES_EBADRESP; | |
| 1230 | + } | ||
| 1223 | 1231 | ||
| 1224 | 1232 | unsigned char* buf = response->buf.data; | |
| 1225 | 1233 | int len = response->buf.size; | |
@@ -1240,8 +1248,9 @@ int TxtTraits::Parse( | |||
| 1240 | 1248 | int SrvTraits::Parse( | |
| 1241 | 1249 | QuerySrvWrap* wrap, | |
| 1242 | 1250 | const std::unique_ptr<ResponseData>& response) { | |
| 1243 | - if (UNLIKELY(response->is_host)) | ||
| 1251 | + if (response->is_host) [[unlikely]] { | ||
| 1244 | 1252 | return ARES_EBADRESP; | |
| 1253 | + } | ||
| 1245 | 1254 | ||
| 1246 | 1255 | unsigned char* buf = response->buf.data; | |
| 1247 | 1256 | int len = response->buf.size; | |
@@ -1262,9 +1271,9 @@ int SrvTraits::Parse( | |||
| 1262 | 1271 | int PtrTraits::Parse( | |
| 1263 | 1272 | QueryPtrWrap* wrap, | |
| 1264 | 1273 | const std::unique_ptr<ResponseData>& response) { | |
| 1265 | - if (UNLIKELY(response->is_host)) | ||
| 1274 | + if (response->is_host) [[unlikely]] { | ||
| 1266 | 1275 | return ARES_EBADRESP; | |
| 1267 | - | ||
| 1276 | + } | ||
| 1268 | 1277 | unsigned char* buf = response->buf.data; | |
| 1269 | 1278 | int len = response->buf.size; | |
| 1270 | 1279 | ||
@@ -1286,9 +1295,9 @@ int PtrTraits::Parse( | |||
| 1286 | 1295 | int NaptrTraits::Parse( | |
| 1287 | 1296 | QueryNaptrWrap* wrap, | |
| 1288 | 1297 | const std::unique_ptr<ResponseData>& response) { | |
| 1289 | - if (UNLIKELY(response->is_host)) | ||
| 1298 | + if (response->is_host) [[unlikely]] { | ||
| 1290 | 1299 | return ARES_EBADRESP; | |
| 1291 | - | ||
| 1300 | + } | ||
| 1292 | 1301 | unsigned char* buf = response->buf.data; | |
| 1293 | 1302 | int len = response->buf.size; | |
| 1294 | 1303 | ||
@@ -1308,9 +1317,9 @@ int NaptrTraits::Parse( | |||
| 1308 | 1317 | int SoaTraits::Parse( | |
| 1309 | 1318 | QuerySoaWrap* wrap, | |
| 1310 | 1319 | const std::unique_ptr<ResponseData>& response) { | |
| 1311 | - if (UNLIKELY(response->is_host)) | ||
| 1320 | + if (response->is_host) [[unlikely]] { | ||
| 1312 | 1321 | return ARES_EBADRESP; | |
| 1313 | - | ||
| 1322 | + } | ||
| 1314 | 1323 | unsigned char* buf = response->buf.data; | |
| 1315 | 1324 | int len = response->buf.size; | |
| 1316 | 1325 | ||
@@ -1388,9 +1397,9 @@ int ReverseTraits::Send(GetHostByAddrWrap* wrap, const char* name) { | |||
| 1388 | 1397 | int ReverseTraits::Parse( | |
| 1389 | 1398 | GetHostByAddrWrap* wrap, | |
| 1390 | 1399 | const std::unique_ptr<ResponseData>& response) { | |
| 1391 | - if (UNLIKELY(!response->is_host)) | ||
| 1400 | + if (!response->is_host) [[unlikely]] { | ||
| 1392 | 1401 | return ARES_EBADRESP; | |
| 1393 | - | ||
| 1402 | + } | ||
| 1394 | 1403 | struct hostent* host = response->host.get(); | |
| 1395 | 1404 | ||
| 1396 | 1405 | Environment* env = wrap->env(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,7 @@ uint32_t GetCacheKey(std::string_view filename, CachedCodeType type) { | |||
| 59 | 59 | template <typename... Args> | |
| 60 | 60 | inline void CompileCacheHandler::Debug(const char* format, | |
| 61 | 61 | Args&&... args) const { | |
| 62 | - if (UNLIKELY(is_debug_)) { | ||
| 62 | + if (is_debug_) [[unlikely]] { | ||
| 63 | 63 | FPrintF(stderr, format, std::forward<Args>(args)...); | |
| 64 | 64 | } | |
| 65 | 65 | } | |
@@ -458,20 +458,20 @@ CompileCacheEnableResult CompileCacheHandler::Enable(Environment* env, | |||
| 458 | 458 | cache_tag, | |
| 459 | 459 | cache_dir_with_tag); | |
| 460 | 460 | ||
| 461 | - if (UNLIKELY(!env->permission()->is_granted( | ||
| 461 | + if (!env->permission()->is_granted( | ||
| 462 | 462 | env, | |
| 463 | 463 | permission::PermissionScope::kFileSystemWrite, | |
| 464 | - cache_dir_with_tag))) { | ||
| 464 | + cache_dir_with_tag)) [[unlikely]] { | ||
| 465 | 465 | result.message = "Skipping compile cache because write permission for " + | |
| 466 | 466 | cache_dir_with_tag + " is not granted"; | |
| 467 | 467 | result.status = CompileCacheEnableStatus::FAILED; | |
| 468 | 468 | return result; | |
| 469 | 469 | } | |
| 470 | 470 | ||
| 471 | - if (UNLIKELY(!env->permission()->is_granted( | ||
| 471 | + if (!env->permission()->is_granted( | ||
| 472 | 472 | env, | |
| 473 | 473 | permission::PermissionScope::kFileSystemRead, | |
| 474 | - cache_dir_with_tag))) { | ||
| 474 | + cache_dir_with_tag)) [[unlikely]] { | ||
| 475 | 475 | result.message = "Skipping compile cache because read permission for " + | |
| 476 | 476 | cache_dir_with_tag + " is not granted"; | |
| 477 | 477 | result.status = CompileCacheEnableStatus::FAILED; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -339,7 +339,7 @@ bool ValidateIV( | |||
| 339 | 339 | Local<Value> value, | |
| 340 | 340 | AESCipherConfig* params) { | |
| 341 | 341 | ArrayBufferOrViewContents<char> iv(value); | |
| 342 | - if (UNLIKELY(!iv.CheckSizeInt32())) { | ||
| 342 | + if (!iv.CheckSizeInt32()) [[unlikely]] { | ||
| 343 | 343 | THROW_ERR_OUT_OF_RANGE(env, "iv is too big"); | |
| 344 | 344 | return false; | |
| 345 | 345 | } | |
@@ -377,7 +377,7 @@ bool ValidateAuthTag( | |||
| 377 | 377 | return false; | |
| 378 | 378 | } | |
| 379 | 379 | ArrayBufferOrViewContents<char> tag_contents(value); | |
| 380 | - if (UNLIKELY(!tag_contents.CheckSizeInt32())) { | ||
| 380 | + if (!tag_contents.CheckSizeInt32()) [[unlikely]] { | ||
| 381 | 381 | THROW_ERR_OUT_OF_RANGE(env, "tagLength is too big"); | |
| 382 | 382 | return false; | |
| 383 | 383 | } | |
@@ -412,7 +412,7 @@ bool ValidateAdditionalData( | |||
| 412 | 412 | // Additional Data | |
| 413 | 413 | if (IsAnyBufferSource(value)) { | |
| 414 | 414 | ArrayBufferOrViewContents<char> additional(value); | |
| 415 | - if (UNLIKELY(!additional.CheckSizeInt32())) { | ||
| 415 | + if (!additional.CheckSizeInt32()) [[unlikely]] { | ||
| 416 | 416 | THROW_ERR_OUT_OF_RANGE(env, "additionalData is too big"); | |
| 417 | 417 | return false; | |
| 418 | 418 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -522,15 +522,16 @@ void CipherBase::InitIv(const FunctionCallbackInfo<Value>& args) { | |||
| 522 | 522 | // raw bytes and proceed... | |
| 523 | 523 | const ByteSource key_buf = ByteSource::FromSecretKeyBytes(env, args[1]); | |
| 524 | 524 | ||
| 525 | - if (UNLIKELY(key_buf.size() > INT_MAX)) | ||
| 525 | + if (key_buf.size() > INT_MAX) [[unlikely]] { | ||
| 526 | 526 | return THROW_ERR_OUT_OF_RANGE(env, "key is too big"); | |
| 527 | + } | ||
| 527 | 528 | ||
| 528 | 529 | ArrayBufferOrViewContents<unsigned char> iv_buf( | |
| 529 | 530 | !args[2]->IsNull() ? args[2] : Local<Value>()); | |
| 530 | 531 | ||
| 531 | - if (UNLIKELY(!iv_buf.CheckSizeInt32())) | ||
| 532 | + if (!iv_buf.CheckSizeInt32()) [[unlikely]] { | ||
| 532 | 533 | return THROW_ERR_OUT_OF_RANGE(env, "iv is too big"); | |
| 533 | - | ||
| 534 | + } | ||
| 534 | 535 | // Don't assign to cipher->auth_tag_len_ directly; the value might not | |
| 535 | 536 | // represent a valid length at this point. | |
| 536 | 537 | unsigned int auth_tag_len; | |
@@ -672,9 +673,9 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) { | |||
| 672 | 673 | } | |
| 673 | 674 | ||
| 674 | 675 | ArrayBufferOrViewContents<char> auth_tag(args[0]); | |
| 675 | - if (UNLIKELY(!auth_tag.CheckSizeInt32())) | ||
| 676 | + if (!auth_tag.CheckSizeInt32()) [[unlikely]] { | ||
| 676 | 677 | return THROW_ERR_OUT_OF_RANGE(env, "buffer is too big"); | |
| 677 | - | ||
| 678 | + } | ||
| 678 | 679 | unsigned int tag_len = auth_tag.size(); | |
| 679 | 680 | ||
| 680 | 681 | const int mode = EVP_CIPHER_CTX_mode(cipher->ctx_.get()); | |
@@ -782,8 +783,9 @@ void CipherBase::SetAAD(const FunctionCallbackInfo<Value>& args) { | |||
| 782 | 783 | int plaintext_len = args[1].As<Int32>()->Value(); | |
| 783 | 784 | ArrayBufferOrViewContents<unsigned char> buf(args[0]); | |
| 784 | 785 | ||
| 785 | - if (UNLIKELY(!buf.CheckSizeInt32())) | ||
| 786 | + if (!buf.CheckSizeInt32()) [[unlikely]] { | ||
| 786 | 787 | return THROW_ERR_OUT_OF_RANGE(env, "buffer is too big"); | |
| 788 | + } | ||
| 787 | 789 | args.GetReturnValue().Set(cipher->SetAAD(buf, plaintext_len)); | |
| 788 | 790 | } | |
| 789 | 791 | ||
@@ -859,9 +861,9 @@ void CipherBase::Update(const FunctionCallbackInfo<Value>& args) { | |||
| 859 | 861 | std::unique_ptr<BackingStore> out; | |
| 860 | 862 | Environment* env = Environment::GetCurrent(args); | |
| 861 | 863 | ||
| 862 | - if (UNLIKELY(size > INT_MAX)) | ||
| 864 | + if (size > INT_MAX) [[unlikely]] { | ||
| 863 | 865 | return THROW_ERR_OUT_OF_RANGE(env, "data is too long"); | |
| 864 | - | ||
| 866 | + } | ||
| 865 | 867 | UpdateResult r = cipher->Update(data, size, &out); | |
| 866 | 868 | ||
| 867 | 869 | if (r != kSuccess) { | |
@@ -1064,9 +1066,9 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) { | |||
| 1064 | 1066 | return; | |
| 1065 | 1067 | ||
| 1066 | 1068 | ArrayBufferOrViewContents<unsigned char> buf(args[offset]); | |
| 1067 | - if (UNLIKELY(!buf.CheckSizeInt32())) | ||
| 1069 | + if (!buf.CheckSizeInt32()) [[unlikely]] { | ||
| 1068 | 1070 | return THROW_ERR_OUT_OF_RANGE(env, "buffer is too long"); | |
| 1069 | - | ||
| 1071 | + } | ||
| 1070 | 1072 | uint32_t padding; | |
| 1071 | 1073 | if (!args[offset + 1]->Uint32Value(env->context()).To(&padding)) return; | |
| 1072 | 1074 | ||
@@ -1106,9 +1108,9 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) { | |||
| 1106 | 1108 | ||
| 1107 | 1109 | ArrayBufferOrViewContents<unsigned char> oaep_label( | |
| 1108 | 1110 | !args[offset + 3]->IsUndefined() ? args[offset + 3] : Local<Value>()); | |
| 1109 | - if (UNLIKELY(!oaep_label.CheckSizeInt32())) | ||
| 1111 | + if (!oaep_label.CheckSizeInt32()) [[unlikely]] { | ||
| 1110 | 1112 | return THROW_ERR_OUT_OF_RANGE(env, "oaepLabel is too big"); | |
| 1111 | - | ||
| 1113 | + } | ||
| 1112 | 1114 | std::unique_ptr<BackingStore> out; | |
| 1113 | 1115 | if (!Cipher<operation, EVP_PKEY_cipher_init, EVP_PKEY_cipher>( | |
| 1114 | 1116 | env, pkey, padding, digest, oaep_label, buf, &out)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -685,7 +685,7 @@ void SecureContext::SetEngineKey(const FunctionCallbackInfo<Value>& args) { | |||
| 685 | 685 | ||
| 686 | 686 | CHECK_EQ(args.Length(), 2); | |
| 687 | 687 | ||
| 688 | - if (UNLIKELY(env->permission()->enabled())) { | ||
| 688 | + if (env->permission()->enabled()) [[unlikely]] { | ||
| 689 | 689 | return THROW_ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED( | |
| 690 | 690 | env, | |
| 691 | 691 | "Programmatic selection of OpenSSL engines is unsupported while the " | |
@@ -1198,7 +1198,7 @@ void SecureContext::SetClientCertEngine( | |||
| 1198 | 1198 | // support multiple calls to SetClientCertEngine. | |
| 1199 | 1199 | CHECK(!sc->client_cert_engine_provided_); | |
| 1200 | 1200 | ||
| 1201 | - if (UNLIKELY(env->permission()->enabled())) { | ||
| 1201 | + if (env->permission()->enabled()) [[unlikely]] { | ||
| 1202 | 1202 | return THROW_ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED( | |
| 1203 | 1203 | env, | |
| 1204 | 1204 | "Programmatic selection of OpenSSL engines is unsupported while the " | |
| Back | FazBrowse Home | New Git URL |
0 commit comments