Skip to content

Commit

Permalink
common: fix clang '-Wcast-function-type-strict' issue
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gromadzki <[email protected]>
  • Loading branch information
grom72 committed Jan 29, 2025
1 parent 64bd519 commit cb474ec
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libpmem/libpmem.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2024, Intel Corporation */
/* Copyright 2025 Hewlett Packard Enterprise Development LP */

/*
* libpmem.c -- pmem entry points for libpmem
Expand Down Expand Up @@ -128,6 +129,10 @@ pmem_log_get_threshold(enum pmem_log_threshold threshold,
int
pmem_log_set_function(pmem_log_function *log_function)
{

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
int ret = core_log_set_function((core_log_function *)log_function);
#pragma GCC diagnostic pop
return core_log_error_translate(ret);
}
7 changes: 7 additions & 0 deletions src/libpmemobj/lane.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2024, Intel Corporation */
/* Copyright 2025 Hewlett Packard Enterprise Development LP */

/*
* lane.c -- lane implementation
Expand Down Expand Up @@ -215,17 +216,23 @@ lane_init(PMEMobjpool *pop, struct lane *lane, struct lane_layout *layout)
if (lane->internal == NULL)
goto error_internal_new;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
lane->external = operation_new((struct ulog *)&layout->external,
LANE_REDO_EXTERNAL_SIZE,
lane_redo_extend, (ulog_free_fn)pfree, &pop->p_ops,
LOG_TYPE_REDO);
#pragma GCC diagnostic pop
if (lane->external == NULL)
goto error_external_new;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
lane->undo = operation_new((struct ulog *)&layout->undo,
LANE_UNDO_SIZE,
lane_undo_extend, (ulog_free_fn)pfree, &pop->p_ops,
LOG_TYPE_UNDO);
#pragma GCC diagnostic pop
if (lane->undo == NULL)
goto error_undo_new;

Expand Down
4 changes: 4 additions & 0 deletions src/libpmemobj/obj_log.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2024, Intel Corporation */
/* Copyright 2025 Hewlett Packard Enterprise Development LP */

/*
* obj_log.c -- the public interface to control the logging output
Expand Down Expand Up @@ -40,6 +41,9 @@ pmemobj_log_get_threshold(enum pmemobj_log_threshold threshold,
int
pmemobj_log_set_function(pmemobj_log_function *log_function)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
int ret = core_log_set_function((core_log_function *)log_function);
#pragma GCC diagnostic pop
return core_log_error_translate(ret);
}
4 changes: 4 additions & 0 deletions src/test/ctl_prefault/ctl_prefault.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018-2023, Intel Corporation */
/* Copyright 2025 Hewlett Packard Enterprise Development LP */

/*
* ctl_prefault.c -- tests for the ctl entry points: prefault
Expand Down Expand Up @@ -119,7 +120,10 @@ main(int argc, char *argv[])
int prefault = atoi(argv[2]);
int open = atoi(argv[3]);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
prefault_fun(prefault, (fun)pmemobj_ctl_get, (fun)pmemobj_ctl_set);
#pragma GCC diagnostic pop
test_obj(path, open);

DONE(NULL);
Expand Down
10 changes: 10 additions & 0 deletions src/test/obj_memops/obj_memops.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018-2023, Intel Corporation */
/* Copyright 2025 Hewlett Packard Enterprise Development LP */

/*
* obj_memops.c -- basic memory operations tests
Expand Down Expand Up @@ -161,10 +162,13 @@ test_same_twice(struct operation_context *ctx, struct test_object *object)
static void
test_redo(PMEMobjpool *pop, struct test_object *object)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
struct operation_context *ctx = operation_new(
(struct ulog *)&object->redo, TEST_ENTRIES,
pmalloc_redo_extend, (ulog_free_fn)pfree,
&pop->p_ops, LOG_TYPE_REDO);
#pragma GCC diagnostic pop

/*
* Keep this test first.
Expand Down Expand Up @@ -620,10 +624,13 @@ static void
test_redo_cleanup_same_size(PMEMobjpool *pop, struct test_object *object)
{
#define ULOG_SIZE 1024
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
struct operation_context *ctx = operation_new(
(struct ulog *)&object->redo, TEST_ENTRIES,
pmalloc_redo_extend, (ulog_free_fn)pfree,
&pop->p_ops, LOG_TYPE_REDO);
#pragma GCC diagnostic pop

int ret = pmalloc(pop, &object->redo.next, ULOG_SIZE, 0, 0);
UT_ASSERTeq(ret, 0);
Expand All @@ -648,10 +655,13 @@ test_redo_cleanup_same_size(PMEMobjpool *pop, struct test_object *object)
static void
test_undo(PMEMobjpool *pop, struct test_object *object)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
struct operation_context *ctx = operation_new(
(struct ulog *)&object->undo, TEST_ENTRIES,
pmalloc_redo_extend, (ulog_free_fn)pfree,
&pop->p_ops, LOG_TYPE_UNDO);
#pragma GCC diagnostic pop

test_undo_small_single_copy(ctx, object);
test_undo_small_single_set(ctx, object);
Expand Down

0 comments on commit cb474ec

Please sign in to comment.