This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 3aa24e36c fix(c/driver/sqlite): Make SQLite driver C99 compliant
(#1946)
3aa24e36c is described below
commit 3aa24e36c85bc9e2802895ca3d09480c6f0fb9e1
Author: William Ayd <[email protected]>
AuthorDate: Thu Jun 27 19:42:17 2024 -0400
fix(c/driver/sqlite): Make SQLite driver C99 compliant (#1946)
closes https://github.com/apache/arrow-adbc/issues/1944
---
c/CMakeLists.txt | 1 +
c/driver/common/utils.c | 4 +++-
c/driver/sqlite/statement_reader.c | 4 ++++
c/meson.build | 5 ++++-
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt
index 06be81426..2aa7fabf9 100644
--- a/c/CMakeLists.txt
+++ b/c/CMakeLists.txt
@@ -23,6 +23,7 @@ include(BuildUtils)
project(adbc
VERSION "${ADBC_BASE_VERSION}"
LANGUAGES C CXX)
+set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
diff --git a/c/driver/common/utils.c b/c/driver/common/utils.c
index a806166b2..2fee02a70 100644
--- a/c/driver/common/utils.c
+++ b/c/driver/common/utils.c
@@ -193,8 +193,10 @@ void AppendErrorDetail(struct AdbcError* error, const
char* key, const uint8_t*
details->capacity = new_capacity;
}
- char* key_data = strdup(key);
+ char* key_data = malloc(strlen(key) + 1);
if (!key_data) return;
+ memcpy(key_data, key, strlen(key) + 1);
+
uint8_t* value_data = malloc(detail_length);
if (!value_data) {
free(key_data);
diff --git a/c/driver/sqlite/statement_reader.c
b/c/driver/sqlite/statement_reader.c
index a58fa5d49..8e8fa72c5 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -15,6 +15,10 @@
// specific language governing permissions and limitations
// under the License.
+#if !defined(_WIN32)
+#define _POSIX_C_SOURCE 200112L
+#endif
+
#include "statement_reader.h"
#include <assert.h>
diff --git a/c/meson.build b/c/meson.build
index df77e5f34..e1ea5361b 100644
--- a/c/meson.build
+++ b/c/meson.build
@@ -23,12 +23,15 @@ project(
meson_version: '>=1.3.0',
default_options: [
'buildtype=release',
- 'c_std=gnu99', # TODO: gmtime_r is gnu99 - likely unintentional std
+ 'c_std=c99',
'warning_level=2',
'cpp_std=c++17',
]
)
+add_project_arguments('-Wno-int-conversion', '-Wno-unused-parameter',
language: 'c')
+add_project_arguments('-Wno-unused-parameter', '-Wno-reorder', language: 'cpp')
+
root_dir = include_directories('..')
driver_dir = include_directories('driver')
nanoarrow_dep = dependency('nanoarrow')