From 5a9787b4247c6735cc3213944945e8983002edf9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 4 Feb 2023 19:25:22 -0500 Subject: Suppress/fix clang-tidy warnings on Windows --- src/path.c | 4 ++++ src/win32/.clang-tidy | 8 ++++++++ src/win32/filesystem_win32.c | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/win32/.clang-tidy (limited to 'src') diff --git a/src/path.c b/src/path.c index aedf059..7568100 100644 --- a/src/path.c +++ b/src/path.c @@ -182,6 +182,10 @@ ZIX_PURE_FUNC static ZixIndexRange zix_path_filename_range(const ZixStringView path) { + if (!path.length) { + return zix_make_range(0, 0); + } + // Find the first filename character (skip leading root path if any) const size_t begin = zix_path_root_path_range(path.data).end; if (begin == path.length || is_dir_sep(path.data[path.length - 1U])) { diff --git a/src/win32/.clang-tidy b/src/win32/.clang-tidy new file mode 100644 index 0000000..386137b --- /dev/null +++ b/src/win32/.clang-tidy @@ -0,0 +1,8 @@ +# Copyright 2021-2022 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +Checks: > + -hicpp-signed-bitwise, + -misc-misplaced-const, + -performance-no-int-to-ptr, +InheritParentConfig: true diff --git a/src/win32/filesystem_win32.c b/src/win32/filesystem_win32.c index 0484684..0038189 100644 --- a/src/win32/filesystem_win32.c +++ b/src/win32/filesystem_win32.c @@ -90,7 +90,7 @@ zix_create_temporary_directory(ZixAllocator* const allocator, // Ensure that the pattern ends with "XXXXXX" const size_t length = strlen(path_pattern); - if (length < 7 || strcmp(path_pattern + length - 6, "XXXXXX")) { + if (length < 7 || !!strcmp(path_pattern + length - 6, "XXXXXX")) { errno = EINVAL; return NULL; } @@ -206,7 +206,7 @@ zix_canonical_path(ZixAllocator* const allocator, const char* const path) } char* const final = (char*)zix_calloc(allocator, final_size + 1U, 1U); - if (final && !GetFinalPathNameByHandle(h, final, final_size + 1U, flags)) { + if (!final || !GetFinalPathNameByHandle(h, final, final_size + 1U, flags)) { zix_free(allocator, final); CloseHandle(h); return NULL; -- cgit v1.2.1