You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pa...@apache.org on 2023/06/08 15:53:17 UTC
[arrow-nanoarrow] branch main updated: chore: Initialize variable causing problems with `-Wmaybe-uninitialized` (#217)
This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new da28e2d chore: Initialize variable causing problems with `-Wmaybe-uninitialized` (#217)
da28e2d is described below
commit da28e2d56c9067185e534675b646cd56d61233c1
Author: Dewey Dunnington <de...@dunnington.ca>
AuthorDate: Thu Jun 8 11:53:10 2023 -0400
chore: Initialize variable causing problems with `-Wmaybe-uninitialized` (#217)
Closes #216.
---
CMakeLists.txt | 1 +
src/nanoarrow/array.c | 9 +++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6849fd..fbb2694 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -120,6 +120,7 @@ else()
-Wextra
-Wno-type-limits
-Wno-unused-parameter
+ -Wmaybe-uninitialized
-Wpedantic
-Wunused-result)
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR
diff --git a/src/nanoarrow/array.c b/src/nanoarrow/array.c
index fe202b1..b30f3be 100644
--- a/src/nanoarrow/array.c
+++ b/src/nanoarrow/array.c
@@ -665,7 +665,8 @@ static int ArrowArrayViewValidateMinimal(struct ArrowArrayView* array_view,
// is always data dependent for all current Arrow types.
for (int i = 0; i < 2; i++) {
int64_t element_size_bytes = array_view->layout.element_size_bits[i] / 8;
- int64_t min_buffer_size_bytes;
+ // Initialize with a value that will cause an error if accidentally used uninitialized
+ int64_t min_buffer_size_bytes = array_view->buffer_views[i].size_bytes + 1;
switch (array_view->layout.buffer_type[i]) {
case NANOARROW_BUFFER_TYPE_VALIDITY:
@@ -1016,9 +1017,9 @@ static int ArrowArrayViewValidateFull(struct ArrowArrayView* array_view,
ArrowErrorSet(error,
"Insufficient information provided for validation of union array");
return EINVAL;
- } else if (_ArrowParsedUnionTypeIdsWillEqualChildIndices(array_view->union_type_id_map,
- array_view->n_children,
- array_view->n_children)) {
+ } else if (_ArrowParsedUnionTypeIdsWillEqualChildIndices(
+ array_view->union_type_id_map, array_view->n_children,
+ array_view->n_children)) {
NANOARROW_RETURN_NOT_OK(ArrowAssertRangeInt8(
array_view->buffer_views[0], 0, (int8_t)(array_view->n_children - 1), error));
} else {