From d8204ca7482a9a5184cdd99f16f9d47b0cbe1c22 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 22 Jun 2024 19:20:02 -0400 Subject: Avoid cppcheck warning about self-assignment --- src/filesystem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/filesystem.c') diff --git a/src/filesystem.c b/src/filesystem.c index 95005ae..61487e9 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -49,17 +49,18 @@ zix_create_directories(ZixAllocator* const allocator, // Create each directory down the path while (p.state != ZIX_PATH_END) { - const char old_end = path[p.range.end]; + char* const end = &path[p.range.end]; + const char old_last = *end; - path[p.range.end] = '\0'; + *end = '\0'; if (zix_file_type(path) != ZIX_FILE_TYPE_DIRECTORY) { if ((st = zix_create_directory(path))) { break; } } - path[p.range.end] = old_end; - p = zix_path_next(path, p); + *end = old_last; + p = zix_path_next(path, p); } zix_free(allocator, path); -- cgit v1.2.1