[PATCH v2 0/1] MR2976: msvcrt: Use 'else if' in _wgetcwd.
Fixes a scan-build warning. -- v2: msvcrt: Use 'else if' in _wgetcwd. https://gitlab.winehq.org/wine/wine/-/merge_requests/2976
From: Alex Henrie <alexhenrie24(a)gmail.com> Fixes a scan-build warning. --- dlls/msvcrt/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c index 72c8018a74b..546e8d49a7b 100644 --- a/dlls/msvcrt/dir.c +++ b/dlls/msvcrt/dir.c @@ -824,7 +824,7 @@ wchar_t* CDECL _wgetcwd(wchar_t * buf, int size) if (size <= dir_len) size = dir_len + 1; if (!(buf = malloc( size * sizeof(WCHAR) ))) return NULL; } - if (dir_len >= size) + else if (dir_len >= size) { *_errno() = ERANGE; return NULL; /* buf too small */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2976
On Mon Jun 5 12:12:41 2023 +0000, Piotr Caban wrote:
There's no leak here. In case !buf we're updating size if it's to small. The code can be changed to: ```suggestion:-0+0 else if (dir_len >= size) ``` to make it easier to read. My apologies for not reading the code closely enough. I like your idea of using `else if` to suppress the warning, and I've pushed a new patch that does exactly that.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/2976#note_34747
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2976
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Piotr Caban (@piotr)