Skip to content

Commit 6567e87

Browse files
committed
fix: address the rest of the comments
1 parent beb88dc commit 6567e87

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

common/rnexecutorch/data_processing/base64.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ std::string base64_encode(BYTE const *buf, unsigned int bufLen) {
2626
((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
2727
char_array_4[3] = char_array_3[2] & 0x3f;
2828

29-
for (i = 0; (i < 4); i++)
29+
for (i = 0; (i < 4); i++) {
3030
ret += base64_chars[char_array_4[i]];
31+
}
3132
i = 0;
3233
}
3334
}
3435

3536
if (i) {
36-
for (j = i; j < 3; j++)
37+
for (j = i; j < 3; j++) {
3738
char_array_3[j] = '\0';
39+
}
3840

3941
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
4042
char_array_4[1] =
@@ -43,11 +45,13 @@ std::string base64_encode(BYTE const *buf, unsigned int bufLen) {
4345
((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
4446
char_array_4[3] = char_array_3[2] & 0x3f;
4547

46-
for (j = 0; (j < i + 1); j++)
48+
for (j = 0; (j < i + 1); j++) {
4749
ret += base64_chars[char_array_4[j]];
50+
}
4851

49-
while ((i++ < 3))
52+
while ((i++ < 3)) {
5053
ret += '=';
54+
}
5155
}
5256

5357
return ret;
@@ -66,35 +70,40 @@ std::vector<BYTE> base64_decode(std::string const &encoded_string) {
6670
char_array_4[i++] = encoded_string[in_];
6771
in_++;
6872
if (i == 4) {
69-
for (i = 0; i < 4; i++)
73+
for (i = 0; i < 4; i++) {
7074
char_array_4[i] = base64_chars.find(char_array_4[i]);
75+
}
7176

7277
char_array_3[0] =
7378
(char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
7479
char_array_3[1] =
7580
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
7681
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
7782

78-
for (i = 0; (i < 3); i++)
83+
for (i = 0; (i < 3); i++) {
7984
ret.push_back(char_array_3[i]);
85+
}
8086
i = 0;
8187
}
8288
}
8389

8490
if (i) {
85-
for (j = i; j < 4; j++)
91+
for (j = i; j < 4; j++) {
8692
char_array_4[j] = 0;
93+
}
8794

88-
for (j = 0; j < 4; j++)
95+
for (j = 0; j < 4; j++) {
8996
char_array_4[j] = base64_chars.find(char_array_4[j]);
97+
}
9098

9199
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
92100
char_array_3[1] =
93101
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
94102
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
95103

96-
for (j = 0; (j < i - 1); j++)
104+
for (j = 0; (j < i - 1); j++) {
97105
ret.push_back(char_array_3[j]);
106+
}
98107
}
99108

100109
return ret;

src/Error.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export enum ETError {
2727
MemoryAllocationFailed = 0x21,
2828
AccessFailed = 0x22,
2929
InvalidProgram = 0x23,
30+
InvalidExternalData = 0x24,
31+
OutOfResources = 0x25,
3032

3133
// Delegate errors
3234
DelegateInvalidCompatibility = 0x30,

0 commit comments

Comments
 (0)