refactor: use CLEAR_FIELD and CLEAR_POINTER macros (#19709)

vim-patch:8.2.0559: clearing a struct is verbose

Problem:    Clearing a struct is verbose.
Solution:   Define and use CLEAR_FIELD() and CLEAR_POINTER().
a80faa8930
This commit is contained in:
zeertzjq
2022-08-11 15:44:55 +08:00
committed by GitHub
parent 252dea5927
commit 94c3176478
45 changed files with 144 additions and 142 deletions

View File

@@ -1051,7 +1051,7 @@ int os_remove(const char *path)
bool os_fileinfo(const char *path, FileInfo *file_info)
FUNC_ATTR_NONNULL_ARG(2)
{
memset(file_info, 0, sizeof(*file_info));
CLEAR_POINTER(file_info);
return os_stat(path, &(file_info->stat)) == kLibuvSuccess;
}
@@ -1063,7 +1063,7 @@ bool os_fileinfo(const char *path, FileInfo *file_info)
bool os_fileinfo_link(const char *path, FileInfo *file_info)
FUNC_ATTR_NONNULL_ARG(2)
{
memset(file_info, 0, sizeof(*file_info));
CLEAR_POINTER(file_info);
if (path == NULL) {
return false;
}
@@ -1087,7 +1087,7 @@ bool os_fileinfo_fd(int file_descriptor, FileInfo *file_info)
FUNC_ATTR_NONNULL_ALL
{
uv_fs_t request;
memset(file_info, 0, sizeof(*file_info));
CLEAR_POINTER(file_info);
fs_loop_lock();
bool ok = uv_fs_fstat(&fs_loop,
&request,