From 25b1675a244d02788dcdc6c80e7839ca4fd7018f Mon Sep 17 00:00:00 2001 From: Gautham Banasandra Date: Mon, 18 Jul 2022 10:59:09 +0530 Subject: [PATCH 1/5] HDFS-16667. Use malloc for buffer allocation in uriparser2 * Windows doesn't support variables for specifying the array size. * This PR uses malloc to fix this issue. --- .../third_party/uriparser2/uriparser2/uriparser2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c index ab6209c864a31..f8f9b57151e81 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c @@ -71,9 +71,11 @@ static const char *copy_path(const UriPathSegmentA *ps, char **buffer) { static int parse_int(const char *first, const char *after_last) { const int size = after_last - first; if (size) { - char buffer[size + 1]; + char* buffer = (char*) malloc(size + 1); memcpyz(buffer, first, size); - return atoi(buffer); + const int value = atoi(buffer); + free(buffer); + return value; } return 0; } From c5b46f1be2cc3c41cc1db8e6758e0f2bc04917f7 Mon Sep 17 00:00:00 2001 From: Gautham Banasandra Date: Mon, 18 Jul 2022 11:01:28 +0530 Subject: [PATCH 2/5] Run CI --- .../src/main/native/libhdfspp/tests/hdfs_builder_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc index 1de925fc97794..1152003eec3f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc @@ -129,6 +129,7 @@ TEST(HdfsBuilderTest, TestSet) } } + int main(int argc, char *argv[]) { /* * The following line must be executed to initialize Google Mock From 4f43c44c5769365eb34c3f40c877bdaef5ee1e27 Mon Sep 17 00:00:00 2001 From: Gautham Banasandra Date: Mon, 18 Jul 2022 11:01:38 +0530 Subject: [PATCH 3/5] Revert "Run CI" This reverts commit c5b46f1be2cc3c41cc1db8e6758e0f2bc04917f7. --- .../src/main/native/libhdfspp/tests/hdfs_builder_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc index 1152003eec3f3..1de925fc97794 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_builder_test.cc @@ -129,7 +129,6 @@ TEST(HdfsBuilderTest, TestSet) } } - int main(int argc, char *argv[]) { /* * The following line must be executed to initialize Google Mock From 25b1da9796b6c9ad4e6986839890a50d8478c310 Mon Sep 17 00:00:00 2001 From: Gautham Banasandra Date: Tue, 19 Jul 2022 10:31:55 +0530 Subject: [PATCH 4/5] Use spaces instead of tabs --- .../third_party/uriparser2/uriparser2/uriparser2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c index f8f9b57151e81..c525e6f2e002d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c @@ -71,11 +71,11 @@ static const char *copy_path(const UriPathSegmentA *ps, char **buffer) { static int parse_int(const char *first, const char *after_last) { const int size = after_last - first; if (size) { - char* buffer = (char*) malloc(size + 1); + char* buffer = (char*) malloc(size + 1); memcpyz(buffer, first, size); - const int value = atoi(buffer); - free(buffer); - return value; + const int value = atoi(buffer); + free(buffer); + return value; } return 0; } From df2323ca40fb4579c6be56bee9b8a780c20243d5 Mon Sep 17 00:00:00 2001 From: Gautham Banasandra Date: Tue, 19 Jul 2022 10:44:28 +0530 Subject: [PATCH 5/5] Use proper indentation --- .../third_party/uriparser2/uriparser2/uriparser2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c index c525e6f2e002d..3036acfd353c1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c @@ -71,11 +71,11 @@ static const char *copy_path(const UriPathSegmentA *ps, char **buffer) { static int parse_int(const char *first, const char *after_last) { const int size = after_last - first; if (size) { - char* buffer = (char*) malloc(size + 1); + char* buffer = (char*) malloc(size + 1); memcpyz(buffer, first, size); - const int value = atoi(buffer); - free(buffer); - return value; + const int value = atoi(buffer); + free(buffer); + return value; } return 0; }