From 22ae1070bcc4b65bd07be0f73940ef18b02b0f91 Mon Sep 17 00:00:00 2001 From: Martin Kedmenec Date: Sat, 16 Nov 2024 23:26:01 +0100 Subject: [PATCH] Add minor changes --- .github/workflows/clang-format.yml | 4 ++-- .github/workflows/clang-tidy.yml | 4 ++-- .idea/misc.xml | 4 ---- src/main.c | 17 ++++++++++------- src/main.h | 15 +++++++++++---- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index ca26c75..044edbc 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -5,6 +5,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: DoozyX/clang-format-lint-action@v0.16.2 + - uses: DoozyX/clang-format-lint-action@v0.18.2 with: - clangFormatVersion: 16 + clangFormatVersion: 18 diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index d747192..e9e06ba 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -5,10 +5,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ZedThree/clang-tidy-review@v0.14.0 + - uses: ZedThree/clang-tidy-review@v0.20.0 id: review with: config_file: '.clang-tidy' - cmake_command: cmake . -D CMAKE_C_COMPILER=clang-16 + cmake_command: cmake . -D CMAKE_C_COMPILER=clang-18 - if: steps.review.outputs.total_comments > 0 run: exit 1 diff --git a/.idea/misc.xml b/.idea/misc.xml index d2e15db..5ebbd37 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,9 +1,5 @@ - - diff --git a/src/main.c b/src/main.c index aca2de2..6498c24 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,9 @@ #include "main.h" #include <_xlocale.h> +#ifdef __linux__ +#include +#endif #include #include #include @@ -15,7 +18,7 @@ void AddNode(Head** head, long data) { } node->data = data; - node->next_node = NULL; + node->next_node = nullptr; if ((*head) == NULL) { (*head) = malloc(sizeof(Head)); @@ -70,7 +73,7 @@ bool RemoveNode(Head** head, long data) { if (current_node == previous_node && current_node->next_node == NULL) { free(current_node); free((*head)); - (*head) = NULL; + (*head) = nullptr; return true; } @@ -139,11 +142,11 @@ void PrintList(Head** head) { while (current_node != NULL) { if (current_node->next_node == NULL) { - wprintf(L"%lc %d %lc %p %lc %lc NULL", kVerticalLine, current_node->data, + wprintf(L"%lc %ld %lc %p %lc %lc NULL", kVerticalLine, current_node->data, kVerticalLineDashed, current_node->next_node, kVerticalLine, kArrow); } else { - wprintf(L"%lc %d %lc %p %lc %lc ", kVerticalLine, current_node->data, + wprintf(L"%lc %ld %lc %p %lc %lc ", kVerticalLine, current_node->data, kVerticalLineDashed, current_node->next_node, kVerticalLine, kArrow); } @@ -184,10 +187,10 @@ bool IsScanfInputValid(int input) { void PrintOperationFailedMessage() { printf("Operation failed.\n"); } int main() { - locale_t locale = newlocale(LC_CTYPE, "en_US", NULL); + locale_t locale = newlocale(LC_CTYPE, "en_US", nullptr); uselocale(locale); - Head* head = NULL; + Head* head = nullptr; char* option_id_input = malloc(sizeof(char)); long option_id = -1; char* input_one_string = malloc(sizeof(char)); @@ -197,7 +200,7 @@ int main() { while (option_id != kQuit) { int number_of_assigned_input_items = 0; - char* end = NULL; + char* end = nullptr; long input_one_long = 0; long input_two_long = 0; bool success = false; diff --git a/src/main.h b/src/main.h index dd2d4fb..c1d782a 100644 --- a/src/main.h +++ b/src/main.h @@ -1,9 +1,14 @@ +#ifndef MAIN_H +#define MAIN_H + #include -const wchar_t kVerticalLine = 0x2503; -const wchar_t kVerticalLineDashed = 0x2506; -const wchar_t kArrow = 0x2B95; -const int kBase = 10; +// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables,readability-identifier-naming) +constexpr wchar_t kVerticalLine = 0x2503; +constexpr wchar_t kVerticalLineDashed = 0x2506; +constexpr wchar_t kArrow = 0x2B95; +constexpr int kBase = 10; +// NOLINTEND enum Commands { kAdd = 1, kRemove, kInsert, kPrint, kQuit }; @@ -22,3 +27,5 @@ struct Node { long data; Node* next_node; }; + +#endif // MAIN_H