Skip to content

Commit 694ec63

Browse files
codebyterezcbenz
authored andcommitted
src: avoid silent coercion to signed/unsigned int
nodejs/node#50663
1 parent 5d3b535 commit 694ec63

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

patches/node/src_avoid_copying_string_in_fs_permission.patch

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ index fadf75968c779d5aee8d9d1ee27e7b4abf241240..d407d440d74c66d9dc8ca4d465309629
1717
+void FSPermission::RadixTree::Insert(const std::string& path_prefix) {
1818
FSPermission::RadixTree::Node* current_node = root_node_;
1919

20-
unsigned int parent_node_prefix_len = current_node->prefix.length();
21-
- int path_len = path.length();
22-
+ int path_len = path_prefix.length();
20+
size_t parent_node_prefix_len = current_node->prefix.length();
21+
- size_t path_len = path.length();
22+
+ size_t path_len = path_prefix.length();
2323

24-
for (int i = 1; i <= path_len; ++i) {
24+
for (size_t i = 1; i <= path_len; ++i) {
2525
- bool is_wildcard_node = path[i - 1] == '*';
2626
+ bool is_wildcard_node = path_prefix[i - 1] == '*';
2727
bool is_last_char = i == path_len;
@@ -49,9 +49,9 @@ index 244e95727ad48757995c6404f457f42a4ba33ccd..4b6aab197333928bfbd5143bea15b3a5
4949

5050
Node() : wildcard_child(nullptr), is_leaf(false) {}
5151

52-
- Node* CreateChild(std::string prefix) {
52+
- Node* CreateChild(const std::string& prefix) {
5353
- if (prefix.empty() && !is_leaf) {
54-
+ Node* CreateChild(std::string path_prefix) {
54+
+ Node* CreateChild(const std::string& path_prefix) {
5555
+ if (path_prefix.empty() && !is_leaf) {
5656
is_leaf = true;
5757
return this;
@@ -65,10 +65,10 @@ index 244e95727ad48757995c6404f457f42a4ba33ccd..4b6aab197333928bfbd5143bea15b3a5
6565
+ children[label] = new Node(path_prefix);
6666
return children[label];
6767
}
68-
69-
@@ -48,7 +48,7 @@ class FSPermission final : public PermissionBase {
70-
unsigned int i = 0;
71-
unsigned int prefix_len = prefix.length();
68+
69+
@@ -49,7 +49,7 @@ class FSPermission final : public PermissionBase {
70+
size_t i = 0;
71+
size_t prefix_len = prefix.length();
7272
for (; i < child->prefix.length(); ++i) {
7373
- if (i > prefix_len || prefix[i] != child->prefix[i]) {
7474
+ if (i > prefix_len || path_prefix[i] != child->prefix[i]) {

0 commit comments

Comments
 (0)