Skip to content

Commit

Permalink
test(c/driver): fix clang-tidy warnings (#1928)
Browse files Browse the repository at this point in the history
Fixes #1927.
  • Loading branch information
lidavidm authored Jun 25, 2024
1 parent ad753b4 commit c1ad8df
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 74 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
---
# Only defaults for now, slowly enable more as desired
# Disable clang-analyzer-core, it fires on nanoarrow (I think it doesn't see that ArrowBufferReserve won't leave buffer->data NULL)
# Disable NewDeleteLeaks, it seems to trigger a lot on Googletest
# Disable the warning about memset, etc. since it suggests C11 functions
# Disable valist, it's buggy: https://github.com/llvm/llvm-project/issues/40656
Checks: '-clang-analyzer-core.*,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-valist.Uninitialized'
Checks: '-clang-analyzer-core.*,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-valist.Uninitialized'
FormatStyle: google
UseColor: true
2 changes: 1 addition & 1 deletion .github/workflows/dev_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
python .github/workflows/dev_pr/body_check.py $(pwd)/pr_checkout "$PR_BODY"
python .github/workflows/dev_pr/body_check.py "$PR_BODY"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
- id: trailing-whitespace
exclude: "^r/.*?/_snaps/.*?.md$"
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v18.1.5"
rev: "v18.1.7"
hooks:
- id: clang-format
types_or: [c, c++]
Expand Down
2 changes: 1 addition & 1 deletion c/driver/common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void AppendErrorDetail(struct AdbcError* error, const char* key, const uint8_t*
return;
}

size_t* new_lengths = calloc(new_capacity, sizeof(size_t*));
size_t* new_lengths = calloc(new_capacity, sizeof(size_t));
if (!new_lengths) {
free(new_keys);
free(new_values);
Expand Down
17 changes: 11 additions & 6 deletions c/driver/flightsql/dremio_flightsql_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ class DremioFlightSqlQuirks : public adbc_validation::DriverQuirks {
public:
AdbcStatusCode SetupDatabase(struct AdbcDatabase* database,
struct AdbcError* error) const override {
const char* uri = std::getenv("ADBC_DREMIO_FLIGHTSQL_URI");
const char* user = std::getenv("ADBC_DREMIO_FLIGHTSQL_USER");
const char* pass = std::getenv("ADBC_DREMIO_FLIGHTSQL_PASS");
EXPECT_THAT(AdbcDatabaseSetOption(database, "uri", uri, error), IsOkStatus(error));
EXPECT_THAT(AdbcDatabaseSetOption(database, "username", user, error),
const char* uri_raw = std::getenv("ADBC_DREMIO_FLIGHTSQL_URI");
const char* user_raw = std::getenv("ADBC_DREMIO_FLIGHTSQL_USER");
const char* pass_raw = std::getenv("ADBC_DREMIO_FLIGHTSQL_PASS");
if (!uri_raw || !user_raw || !pass_raw) {
SetError(error, "Missing required environment variables");
return ADBC_STATUS_INVALID_ARGUMENT;
}
EXPECT_THAT(AdbcDatabaseSetOption(database, "uri", uri_raw, error),
IsOkStatus(error));
EXPECT_THAT(AdbcDatabaseSetOption(database, "password", pass, error),
EXPECT_THAT(AdbcDatabaseSetOption(database, "username", user_raw, error),
IsOkStatus(error));
EXPECT_THAT(AdbcDatabaseSetOption(database, "password", pass_raw, error),
IsOkStatus(error));
return ADBC_STATUS_OK;
}
Expand Down
54 changes: 27 additions & 27 deletions c/driver/framework/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,34 +319,34 @@ struct GetObjectsBuilder {
std::optional<std::string_view> table_filter;
std::optional<std::string_view> column_filter;
const std::vector<std::string_view>& table_types;
struct ArrowSchema* schema;
struct ArrowArray* array;
struct ArrowSchema* schema = nullptr;
struct ArrowArray* array = nullptr;
struct ArrowError na_error;
struct ArrowArray* catalog_name_col;
struct ArrowArray* catalog_db_schemas_col;
struct ArrowArray* catalog_db_schemas_items;
struct ArrowArray* db_schema_name_col;
struct ArrowArray* db_schema_tables_col;
struct ArrowArray* schema_table_items;
struct ArrowArray* table_name_col;
struct ArrowArray* table_type_col;
struct ArrowArray* table_columns_col;
struct ArrowArray* table_columns_items;
struct ArrowArray* column_name_col;
struct ArrowArray* column_position_col;
struct ArrowArray* column_remarks_col;
struct ArrowArray* table_constraints_col;
struct ArrowArray* table_constraints_items;
struct ArrowArray* constraint_name_col;
struct ArrowArray* constraint_type_col;
struct ArrowArray* constraint_column_names_col;
struct ArrowArray* constraint_column_name_col;
struct ArrowArray* constraint_column_usages_col;
struct ArrowArray* constraint_column_usage_items;
struct ArrowArray* fk_catalog_col;
struct ArrowArray* fk_db_schema_col;
struct ArrowArray* fk_table_col;
struct ArrowArray* fk_column_name_col;
struct ArrowArray* catalog_name_col = nullptr;
struct ArrowArray* catalog_db_schemas_col = nullptr;
struct ArrowArray* catalog_db_schemas_items = nullptr;
struct ArrowArray* db_schema_name_col = nullptr;
struct ArrowArray* db_schema_tables_col = nullptr;
struct ArrowArray* schema_table_items = nullptr;
struct ArrowArray* table_name_col = nullptr;
struct ArrowArray* table_type_col = nullptr;
struct ArrowArray* table_columns_col = nullptr;
struct ArrowArray* table_columns_items = nullptr;
struct ArrowArray* column_name_col = nullptr;
struct ArrowArray* column_position_col = nullptr;
struct ArrowArray* column_remarks_col = nullptr;
struct ArrowArray* table_constraints_col = nullptr;
struct ArrowArray* table_constraints_items = nullptr;
struct ArrowArray* constraint_name_col = nullptr;
struct ArrowArray* constraint_type_col = nullptr;
struct ArrowArray* constraint_column_names_col = nullptr;
struct ArrowArray* constraint_column_name_col = nullptr;
struct ArrowArray* constraint_column_usages_col = nullptr;
struct ArrowArray* constraint_column_usage_items = nullptr;
struct ArrowArray* fk_catalog_col = nullptr;
struct ArrowArray* fk_db_schema_col = nullptr;
struct ArrowArray* fk_table_col = nullptr;
struct ArrowArray* fk_column_name_col = nullptr;
};
} // namespace

Expand Down
68 changes: 34 additions & 34 deletions c/driver/postgresql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,42 +566,42 @@ class PqGetObjectsHelper {
return ADBC_STATUS_OK;
}

PGconn* conn_;
PGconn* conn_ = nullptr;
int depth_;
const char* catalog_;
const char* db_schema_;
const char* table_name_;
const char** table_types_;
const char* column_name_;
struct ArrowSchema* schema_;
struct ArrowArray* array_;
struct AdbcError* error_;
const char* catalog_ = nullptr;
const char* db_schema_ = nullptr;
const char* table_name_ = nullptr;
const char** table_types_ = nullptr;
const char* column_name_ = nullptr;
struct ArrowSchema* schema_ = nullptr;
struct ArrowArray* array_ = nullptr;
struct AdbcError* error_ = nullptr;
struct ArrowError na_error_;
struct ArrowArray* catalog_name_col_;
struct ArrowArray* catalog_db_schemas_col_;
struct ArrowArray* catalog_db_schemas_items_;
struct ArrowArray* db_schema_name_col_;
struct ArrowArray* db_schema_tables_col_;
struct ArrowArray* schema_table_items_;
struct ArrowArray* table_name_col_;
struct ArrowArray* table_type_col_;
struct ArrowArray* table_columns_col_;
struct ArrowArray* table_columns_items_;
struct ArrowArray* column_name_col_;
struct ArrowArray* column_position_col_;
struct ArrowArray* column_remarks_col_;
struct ArrowArray* table_constraints_col_;
struct ArrowArray* table_constraints_items_;
struct ArrowArray* constraint_name_col_;
struct ArrowArray* constraint_type_col_;
struct ArrowArray* constraint_column_names_col_;
struct ArrowArray* constraint_column_name_col_;
struct ArrowArray* constraint_column_usages_col_;
struct ArrowArray* constraint_column_usage_items_;
struct ArrowArray* fk_catalog_col_;
struct ArrowArray* fk_db_schema_col_;
struct ArrowArray* fk_table_col_;
struct ArrowArray* fk_column_name_col_;
struct ArrowArray* catalog_name_col_ = nullptr;
struct ArrowArray* catalog_db_schemas_col_ = nullptr;
struct ArrowArray* catalog_db_schemas_items_ = nullptr;
struct ArrowArray* db_schema_name_col_ = nullptr;
struct ArrowArray* db_schema_tables_col_ = nullptr;
struct ArrowArray* schema_table_items_ = nullptr;
struct ArrowArray* table_name_col_ = nullptr;
struct ArrowArray* table_type_col_ = nullptr;
struct ArrowArray* table_columns_col_ = nullptr;
struct ArrowArray* table_columns_items_ = nullptr;
struct ArrowArray* column_name_col_ = nullptr;
struct ArrowArray* column_position_col_ = nullptr;
struct ArrowArray* column_remarks_col_ = nullptr;
struct ArrowArray* table_constraints_col_ = nullptr;
struct ArrowArray* table_constraints_items_ = nullptr;
struct ArrowArray* constraint_name_col_ = nullptr;
struct ArrowArray* constraint_type_col_ = nullptr;
struct ArrowArray* constraint_column_names_col_ = nullptr;
struct ArrowArray* constraint_column_name_col_ = nullptr;
struct ArrowArray* constraint_column_usages_col_ = nullptr;
struct ArrowArray* constraint_column_usage_items_ = nullptr;
struct ArrowArray* fk_catalog_col_ = nullptr;
struct ArrowArray* fk_db_schema_col_ = nullptr;
struct ArrowArray* fk_table_col_ = nullptr;
struct ArrowArray* fk_column_name_col_ = nullptr;
};

// A notice processor that does nothing with notices. In the future we can log
Expand Down
4 changes: 2 additions & 2 deletions ci/conda_env_cpp_lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.

clang=14.*
clang-tools=14.*
clang=18.*
clang-tools=18.*
3 changes: 2 additions & 1 deletion ci/scripts/cpp_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ build_subproject() {

run-clang-tidy \
-extra-arg=-Wno-unknown-warning-option \
-extra-arg=-Wno-unused-command-line-argument \
-j $(nproc) \
-p "${build_dir}" \
-fix \
-quiet \
$(jq -r ".[] | .file" "${build_dir}/compile_commands.json")
$(jq -r ".[] | .file | select(contains(\"c/vendor\") | not)" "${build_dir}/compile_commands.json")

set +x
popd
Expand Down

0 comments on commit c1ad8df

Please sign in to comment.