mirror of
https://github.com/nodejs/node.git
synced 2026-12-06 01:48:46 -05:00
src: avoid silent coercion to signed/unsigned int
Be accurate about signedness and bit widths. PR-URL: https://github.com/nodejs/node/pull/50663 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
c253e39b56
commit
3d43fd359c
2 files changed
+10
-10
No files matched your search
@@ -56,7 +56,7 @@ bool is_tree_granted(node::permission::FSPermission::RadixTree* granted_tree,
|
||||
// is UNC file path
|
||||
if (param.rfind("\\\\", 0) == 0) {
|
||||
// return lookup with normalized param
|
||||
int starting_pos = 4; // "\\?\"
|
||||
size_t starting_pos = 4; // "\\?\"
|
||||
if (param.rfind("\\\\?\\UNC\\") == 0) {
|
||||
starting_pos += 4; // "UNC\"
|
||||
}
|
||||
@@ -176,7 +176,7 @@ bool FSPermission::RadixTree::Lookup(const std::string_view& s,
|
||||
if (current_node->children.size() == 0) {
|
||||
return when_empty_return;
|
||||
}
|
||||
unsigned int parent_node_prefix_len = current_node->prefix.length();
|
||||
size_t parent_node_prefix_len = current_node->prefix.length();
|
||||
const std::string path(s);
|
||||
auto path_len = path.length();
|
||||
|
||||
@@ -202,10 +202,10 @@ bool FSPermission::RadixTree::Lookup(const std::string_view& s,
|
||||
void FSPermission::RadixTree::Insert(const std::string& path) {
|
||||
FSPermission::RadixTree::Node* current_node = root_node_;
|
||||
|
||||
unsigned int parent_node_prefix_len = current_node->prefix.length();
|
||||
int path_len = path.length();
|
||||
size_t parent_node_prefix_len = current_node->prefix.length();
|
||||
size_t path_len = path.length();
|
||||
|
||||
for (int i = 1; i <= path_len; ++i) {
|
||||
for (size_t i = 1; i <= path_len; ++i) {
|
||||
bool is_wildcard_node = path[i - 1] == '*';
|
||||
bool is_last_char = i == path_len;
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ class FSPermission final : public PermissionBase {
|
||||
}
|
||||
|
||||
// swap prefix
|
||||
unsigned int i = 0;
|
||||
unsigned int prefix_len = prefix.length();
|
||||
size_t i = 0;
|
||||
size_t prefix_len = prefix.length();
|
||||
for (; i < child->prefix.length(); ++i) {
|
||||
if (i > prefix_len || prefix[i] != child->prefix[i]) {
|
||||
std::string parent_prefix = child->prefix.substr(0, i);
|
||||
@@ -72,7 +72,7 @@ class FSPermission final : public PermissionBase {
|
||||
return wildcard_child;
|
||||
}
|
||||
|
||||
Node* NextNode(const std::string& path, unsigned int idx) {
|
||||
Node* NextNode(const std::string& path, size_t idx) {
|
||||
if (idx >= path.length()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -83,8 +83,8 @@ class FSPermission final : public PermissionBase {
|
||||
}
|
||||
auto child = it->second;
|
||||
// match prefix
|
||||
unsigned int prefix_len = child->prefix.length();
|
||||
for (unsigned int i = 0; i < path.length(); ++i) {
|
||||
size_t prefix_len = child->prefix.length();
|
||||
for (size_t i = 0; i < path.length(); ++i) {
|
||||
if (i >= prefix_len || child->prefix[i] == '*') {
|
||||
return child;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user