Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common: pmem2_badblock_next is replaced by pmem2_badblock_next_internal #6133

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Before contributing please remember to run:
```

This will check all C/C++ files in the tree for style issues. To check C++
files you have to have clang-format version 9.0, otherwise they will be
files you have to have clang-format version 14.0, otherwise they will be
skipped. If you want to run this target automatically at build time, you can
pass CSTYLEON=1 to make. If you want cstyle to be run, but not fail the build,
pass CSTYLEON=2 to make.
Expand Down
5 changes: 3 additions & 2 deletions src/common.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2023, Intel Corporation
# Copyright 2025, Hewlett Packard Enterprise Development LP
#
# src/common.inc -- common Makefile rules for PMDK
#
Expand Down Expand Up @@ -39,8 +40,8 @@ $(error Cannot evaluate version)
endif

ifeq ($(CLANG_FORMAT),)
ifeq ($(shell command -v clang-format-9 > /dev/null && echo y || echo n), y)
export CLANG_FORMAT ?= clang-format-9
ifeq ($(shell command -v clang-format-14 > /dev/null && echo y || echo n), y)
export CLANG_FORMAT ?= clang-format-14
else
export CLANG_FORMAT ?= clang-format
endif
Expand Down
12 changes: 12 additions & 0 deletions src/core/util.h
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 */
/*
* Copyright (c) 2016-2020, Microsoft Corporation. All rights reserved.
*
Expand Down Expand Up @@ -331,6 +332,17 @@ char *util_concat_str(const char *s1, const char *s2);
#define SUPPRESS_ARG_8(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_7(__VA_ARGS__)
#define SUPPRESS_ARG_9(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_8(__VA_ARGS__)

/* tell clang to ignore the "cast-function-type-strict" warning */
#if __clang__
#define CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(exp) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wcast-function-type-strict\"") \
exp; \
_Pragma("clang diagnostic pop")
#else
#define CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(exp) exp
#endif

#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 4 additions & 1 deletion 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,8 @@ pmem_log_get_threshold(enum pmem_log_threshold threshold,
int
pmem_log_set_function(pmem_log_function *log_function)
{
int ret = core_log_set_function((core_log_function *)log_function);
int ret = EFAULT;
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
ret = core_log_set_function((core_log_function *)log_function));
return core_log_error_translate(ret);
}
17 changes: 9 additions & 8 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,17 @@ lane_init(PMEMobjpool *pop, struct lane *lane, struct lane_layout *layout)
if (lane->internal == NULL)
goto error_internal_new;

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);
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
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));
if (lane->external == NULL)
goto error_external_new;

lane->undo = operation_new((struct ulog *)&layout->undo,
LANE_UNDO_SIZE,
lane_undo_extend, (ulog_free_fn)pfree, &pop->p_ops,
LOG_TYPE_UNDO);
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
lane->undo = operation_new((struct ulog *)&layout->undo,
LANE_UNDO_SIZE, lane_undo_extend, (ulog_free_fn)pfree,
&pop->p_ops, LOG_TYPE_UNDO));
if (lane->undo == NULL)
goto error_undo_new;

Expand Down
5 changes: 4 additions & 1 deletion 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,8 @@ pmemobj_log_get_threshold(enum pmemobj_log_threshold threshold,
int
pmemobj_log_set_function(pmemobj_log_function *log_function)
{
int ret = core_log_set_function((core_log_function *)log_function);
int ret = EFAULT;
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
ret = core_log_set_function((core_log_function *)log_function));
return core_log_error_translate(ret);
}
5 changes: 4 additions & 1 deletion 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,9 @@ main(int argc, char *argv[])
int prefault = atoi(argv[2]);
int open = atoi(argv[3]);

prefault_fun(prefault, (fun)pmemobj_ctl_get, (fun)pmemobj_ctl_set);
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
prefault_fun(prefault, (fun)pmemobj_ctl_get,
(fun)pmemobj_ctl_set));
test_obj(path, open);

DONE(NULL);
Expand Down
28 changes: 16 additions & 12 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,11 @@ test_same_twice(struct operation_context *ctx, struct test_object *object)
static void
test_redo(PMEMobjpool *pop, struct test_object *object)
{
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);
struct operation_context *ctx = NULL;
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
ctx = operation_new((struct ulog *)&object->redo, TEST_ENTRIES,
pmalloc_redo_extend, (ulog_free_fn)pfree, &pop->p_ops,
LOG_TYPE_REDO));

/*
* Keep this test first.
Expand Down Expand Up @@ -620,10 +622,11 @@ static void
test_redo_cleanup_same_size(PMEMobjpool *pop, struct test_object *object)
{
#define ULOG_SIZE 1024
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);
struct operation_context *ctx = NULL;
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
ctx = operation_new((struct ulog *)&object->redo, TEST_ENTRIES,
pmalloc_redo_extend, (ulog_free_fn)pfree, &pop->p_ops,
LOG_TYPE_REDO));

int ret = pmalloc(pop, &object->redo.next, ULOG_SIZE, 0, 0);
UT_ASSERTeq(ret, 0);
Expand All @@ -648,10 +651,11 @@ test_redo_cleanup_same_size(PMEMobjpool *pop, struct test_object *object)
static void
test_undo(PMEMobjpool *pop, struct test_object *object)
{
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);
struct operation_context *ctx = NULL;
CLANG_IGNORE_CAST_FUNCTION_TYPE_STRICT_WARNING(
ctx = operation_new((struct ulog *)&object->undo, TEST_ENTRIES,
pmalloc_redo_extend, (ulog_free_fn)pfree, &pop->p_ops,
LOG_TYPE_UNDO));

test_undo_small_single_copy(ctx, object);
test_undo_small_single_set(ctx, object);
Expand Down
1 change: 1 addition & 0 deletions utils/call_stacks_analysis/white_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"stats_enabled_parser",

"__comment: libpmem2 only",
"pmem2_badblock_next",
"pmem2_config_delete",
"pmem2_config_init",
"pmem2_config_new",
Expand Down
5 changes: 3 additions & 2 deletions utils/style_check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2023, Intel Corporation
# Copyright 2025, Hewlett Packard Enterprise Development LP
#
# utils/style_check.sh -- common style checking script
#
Expand All @@ -15,8 +16,8 @@ CHECK_TYPE=$1
# When updating, please search for all references to "clang-format" and update
# them as well; at this time these are CONTRIBUTING.md src/common.inc and
# docker images.
[ -z "$clang_format_bin" ] && which clang-format-9 >/dev/null &&
clang_format_bin=clang-format-9
[ -z "$clang_format_bin" ] && which clang-format-14 >/dev/null &&
clang_format_bin=clang-format-14
[ -z "$clang_format_bin" ] && which clang-format >/dev/null &&
clang_format_bin=clang-format
[ -z "$clang_format_bin" ] && clang_format_bin=clang-format
Expand Down
Loading