From e5d85536d26577653ab2fbe97fe913b1df564890 Mon Sep 17 00:00:00 2001 From: Tilen Majerle Date: Mon, 20 Nov 2023 21:20:25 +0100 Subject: [PATCH] Apply clang-tidy --- .clang-tidy | 19 +++++++++++++++++++ .vscode/settings.json | 3 ++- lwbtn/src/include/lwbtn/lwbtn_opt.h | 18 ++++++++++++++++++ lwbtn/src/lwbtn/lwbtn.c | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..1aaa846 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,19 @@ +--- +Checks: "*, + -abseil-*, + -altera-*, + -android-*, + -fuchsia-*, + -google-*, + -llvm*, + -modernize-use-trailing-return-type, + -zircon-*, + -readability-else-after-return, + -readability-static-accessed-through-instance, + -readability-avoid-const-params-in-decls, + -cppcoreguidelines-non-private-member-variables-in-classes, + -misc-non-private-member-variables-in-classes, +" +WarningsAsErrors: '' +HeaderFilterRegex: '' +FormatStyle: none \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index acffdcd..afe1028 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,6 @@ "bitset": "c", "stdio.h": "c" }, - "esbonio.sphinx.confDir": "" + "esbonio.sphinx.confDir": "", + "C_Cpp.codeAnalysis.clangTidy.useBuildPath": true } \ No newline at end of file diff --git a/lwbtn/src/include/lwbtn/lwbtn_opt.h b/lwbtn/src/include/lwbtn/lwbtn_opt.h index 5b8b6a7..1a898b3 100644 --- a/lwbtn/src/include/lwbtn/lwbtn_opt.h +++ b/lwbtn/src/include/lwbtn/lwbtn_opt.h @@ -52,6 +52,24 @@ extern "C" { * \{ */ +/** + * \brief Memory set function + * + * \note Function footprint is the same as \ref memset + */ +#ifndef LWBTN_MEMSET +#define LWBTN_MEMSET(dst, val, len) memset((dst), (val), (len)) +#endif + +/** + * \brief Memory copy function + * + * \note Function footprint is the same as \ref memcpy + */ +#ifndef LWBTN_MEMCPY +#define LWBTN_MEMCPY(dst, src, len) memcpy((dst), (src), (len)) +#endif + /** * \brief Enables `1` or disables `0` periodic keep alive events. * diff --git a/lwbtn/src/lwbtn/lwbtn.c b/lwbtn/src/lwbtn/lwbtn.c index 2199aa0..e338598 100644 --- a/lwbtn/src/lwbtn/lwbtn.c +++ b/lwbtn/src/lwbtn/lwbtn.c @@ -292,7 +292,7 @@ lwbtn_init_ex(lwbtn_t* lwobj, lwbtn_btn_t* btns, uint16_t btns_cnt, lwbtn_get_st return 0; } - memset(lwobj, 0x00, sizeof(*lwobj)); + LWBTN_MEMSET(lwobj, 0x00, sizeof(*lwobj)); lwobj->btns = btns; lwobj->btns_cnt = btns_cnt; lwobj->evt_fn = evt_fn;