diff --git a/c/validation/adbc_validation_util.h b/c/validation/adbc_validation_util.h index d4f7e2d834..08401f2b46 100644 --- a/c/validation/adbc_validation_util.h +++ b/c/validation/adbc_validation_util.h @@ -273,54 +273,38 @@ int MakeArray(struct ArrowArray* parent, struct ArrowArray* array, if constexpr (std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value) { - if (int errno_res = ArrowArrayAppendInt(array, *v); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendInt(array, *v)); // XXX: cpplint gets weird here and thinks this is an unbraced if } else if constexpr (std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value) { - if (int errno_res = ArrowArrayAppendUInt(array, *v); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendUInt(array, *v)); } else if constexpr (std::is_same::value || // NOLINT(readability/braces) std::is_same::value) { - if (int errno_res = ArrowArrayAppendDouble(array, *v); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendDouble(array, *v)); } else if constexpr (std::is_same::value) { struct ArrowBufferView view; view.data.as_char = v->c_str(); view.size_bytes = v->size(); - if (int errno_res = ArrowArrayAppendBytes(array, view); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendBytes(array, view)); } else if constexpr (std::is_same>::value) { static_assert(std::is_same_v); struct ArrowBufferView view; view.data.as_uint8 = reinterpret_cast(v->data()); view.size_bytes = v->size(); - if (int errno_res = ArrowArrayAppendBytes(array, view); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendBytes(array, view)); } else if constexpr (std::is_same::value) { - if (int errno_res = ArrowArrayAppendInterval(array, *v); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendInterval(array, *v)); } else if constexpr (std::is_same::value) { - if (int errno_res = ArrowArrayAppendDecimal(array, *v); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendDecimal(array, *v)); } else { static_assert(!sizeof(T), "Not yet implemented"); return ENOTSUP; } } else { - if (int errno_res = ArrowArrayAppendNull(array, 1); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayAppendNull(array, 1)); } } return 0; @@ -336,10 +320,7 @@ template int MakeBatchImpl(struct ArrowArray* batch, size_t i, struct ArrowError* error, const std::vector>& first, const std::vector>&... rest) { - if (int errno_res = MakeArray(batch, batch->children[i], first); - errno_res != 0) { - return errno_res; - } + CHECK_OK(MakeArray(batch, batch->children[i], first)); return MakeBatchImpl(batch, i + 1, error, rest...); } @@ -347,12 +328,8 @@ int MakeBatchImpl(struct ArrowArray* batch, size_t i, struct ArrowError* error, template int MakeBatch(struct ArrowArray* batch, struct ArrowError* error, const std::vector>&... columns) { - if (int errno_res = ArrowArrayStartAppending(batch); errno_res != 0) { - return errno_res; - } - if (int errno_res = MakeBatchImpl(batch, 0, error, columns...); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayStartAppending(batch)); + CHECK_OK(MakeBatchImpl(batch, 0, error, columns...)); for (size_t i = 0; i < static_cast(batch->n_children); i++) { if (batch->length > 0 && batch->children[i]->length != batch->length) { ADD_FAILURE() << "Column lengths are inconsistent: column " << i << " has length " @@ -367,9 +344,7 @@ int MakeBatch(struct ArrowArray* batch, struct ArrowError* error, template int MakeBatch(struct ArrowSchema* schema, struct ArrowArray* batch, struct ArrowError* error, const std::vector>&... columns) { - if (int errno_res = ArrowArrayInitFromSchema(batch, schema, error); errno_res != 0) { - return errno_res; - } + CHECK_OK(ArrowArrayInitFromSchema(batch, schema, error)); return MakeBatch(batch, error, columns...); }