This is in preparation of implementing all logic from the server in kernelbase, which is needed because Nt*Key ignores KEY_WOW64_32KEY. Unfortunately this requires a lot of server calls.
The full branch can be found here
https://gitlab.winehq.org/sbaars/wine/-/tree/shared-classes-new
The old approach that doesn't duplicate code to kernelbase can be found here
https://gitlab.winehq.org/sbaars/wine/-/tree/shared-classes-old
I ran make_requests by the way, not sure if we should still leave that out with the gitlab workflow.
-- v14: kernelbase: Restructure the create_key() loop. kernelbase: Add a fast path to create_key(). kernelbase: Move create_key() below open_key(). kernelbase: Factor opening a subkey out of open_key(). kernelbase: Always try to open the Wow6432Node in open_key(). kernelbase: Restructure the open_key() loop.
From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 51 +++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 0137cbe6cad..0f629ab2d36 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -100,7 +100,8 @@ static inline BOOL is_version_nt(void)
static BOOL is_wow6432node( const UNICODE_STRING *name ) { - return (name->Length == 11 * sizeof(WCHAR) && !wcsnicmp( name->Buffer, L"Wow6432Node", 11 )); + DWORD len = name->Length / sizeof(WCHAR); + return (len >= 11 && !wcsnicmp( name->Buffer, L"Wow6432Node\", min( len, 12 ) )); }
/* open the Wow6432Node subkey of the specified key */ @@ -220,7 +221,7 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC BOOL force_wow32 = is_win64 && (access & KEY_WOW64_32KEY); HANDLE subkey, root = attr->RootDirectory; WCHAR *buffer = attr->ObjectName->Buffer; - DWORD pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); + DWORD i, len = attr->ObjectName->Length / sizeof(WCHAR); UNICODE_STRING str;
*retkey = NULL; @@ -237,24 +238,17 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC return status; }
- if (len && buffer[0] == '\') return STATUS_OBJECT_PATH_INVALID; - while (i < len && buffer[i] != '\') i++; attr->ObjectName = &str;
- for (;;) + while (len) { - str.Buffer = buffer + pos; - str.Length = (i - pos) * sizeof(WCHAR); - if (force_wow32 && pos) - { - if (is_wow6432node( &str )) force_wow32 = FALSE; - else if ((subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - force_wow32 = FALSE; - } - } + i = 0; + if (buffer[0] == '\') return STATUS_OBJECT_PATH_INVALID; + while (i < len && buffer[i] != '\') i++; + + str.Buffer = buffer; + str.Length = i * sizeof(WCHAR); + if (i == len) { if (options & REG_OPTION_OPEN_LINK) attr->Attributes |= OBJ_OPENLINK; @@ -268,15 +262,22 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); if (status) return status; attr->RootDirectory = subkey; - if (i == len) break; while (i < len && buffer[i] == '\') i++; - pos = i; - while (i < len && buffer[i] != '\') i++; - } - if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; + buffer += i; + len -= i; + + if (force_wow32) + { + str.Buffer = buffer; + str.Length = len * sizeof(WCHAR); + if (is_wow6432node( &str )) force_wow32 = FALSE; + else if ((subkey = open_wow6432node( attr->RootDirectory ))) + { + NtClose( attr->RootDirectory ); + attr->RootDirectory = subkey; + force_wow32 = FALSE; + } + } } if (status == STATUS_PREDEFINED_HANDLE) {
From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 0f629ab2d36..531a0bbea1e 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -218,7 +218,6 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr ) { NTSTATUS status; - BOOL force_wow32 = is_win64 && (access & KEY_WOW64_32KEY); HANDLE subkey, root = attr->RootDirectory; WCHAR *buffer = attr->ObjectName->Buffer; DWORD i, len = attr->ObjectName->Length / sizeof(WCHAR); @@ -226,7 +225,7 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC
*retkey = NULL;
- if (!force_wow32) + if (!(is_win64 && (access & KEY_WOW64_32KEY))) { if (options & REG_OPTION_OPEN_LINK) attr->Attributes |= OBJ_OPENLINK; status = NtOpenKeyEx( (HANDLE *)retkey, access, attr, options ); @@ -266,16 +265,14 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC buffer += i; len -= i;
- if (force_wow32) + str.Buffer = buffer; + str.Length = len * sizeof(WCHAR); + if (!is_wow6432node( &str )) { - str.Buffer = buffer; - str.Length = len * sizeof(WCHAR); - if (is_wow6432node( &str )) force_wow32 = FALSE; - else if ((subkey = open_wow6432node( attr->RootDirectory ))) + if ((subkey = open_wow6432node( attr->RootDirectory ))) { NtClose( attr->RootDirectory ); attr->RootDirectory = subkey; - force_wow32 = FALSE; } } }
From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 117 ++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 46 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 531a0bbea1e..926159de768 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -214,14 +214,71 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES return status; }
+static NTSTATUS open_subkey( HKEY *subkey, HKEY root, UNICODE_STRING *name, DWORD options, ACCESS_MASK access ) +{ + DWORD i = 0, len = name->Length / sizeof(WCHAR); + WCHAR *buffer = name->Buffer; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING str; + NTSTATUS status = 0; + + attr.Length = sizeof(attr); + attr.RootDirectory = (HANDLE)root; + attr.ObjectName = &str; + attr.Attributes = 0; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + + if (buffer[0] == '\') return STATUS_OBJECT_PATH_INVALID; + while (i < len && buffer[i] != '\') i++; + + str.Buffer = name->Buffer; + str.Length = i * sizeof(WCHAR); + + if (i == len) + { + if (options & REG_OPTION_OPEN_LINK) attr.Attributes |= OBJ_OPENLINK; + } + else + { + if (!(options & REG_OPTION_OPEN_LINK)) attr.Attributes &= ~OBJ_OPENLINK; + options &= ~REG_OPTION_OPEN_LINK; + } + + status = NtOpenKeyEx( (HANDLE *)subkey, access, &attr, options ); + if (status == STATUS_PREDEFINED_HANDLE) + { + *subkey = get_perflib_key( *subkey ); + status = STATUS_SUCCESS; + } + + if (!status) + { + while (i < len && buffer[i] == '\') i++; + + name->Buffer += i; + name->Length -= i * sizeof(WCHAR); + + if (!is_wow6432node( name )) + { + HKEY wow6432node = open_wow6432node( *subkey ); + if (wow6432node) + { + NtClose( *subkey ); + *subkey = wow6432node; + } + } + } + + return status; +} + /* wrapper for NtOpenKeyEx to handle Wow6432 nodes */ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr ) { - NTSTATUS status; - HANDLE subkey, root = attr->RootDirectory; - WCHAR *buffer = attr->ObjectName->Buffer; - DWORD i, len = attr->ObjectName->Length / sizeof(WCHAR); - UNICODE_STRING str; + HKEY root = attr->RootDirectory, subkey, subkey_root = root; + UNICODE_STRING name; + NTSTATUS status = 0;
*retkey = NULL;
@@ -237,51 +294,19 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC return status; }
- attr->ObjectName = &str; + name.Buffer = attr->ObjectName->Buffer; + name.Length = attr->ObjectName->Length;
- while (len) + while (!status && name.Length) { - i = 0; - if (buffer[0] == '\') return STATUS_OBJECT_PATH_INVALID; - while (i < len && buffer[i] != '\') i++; - - str.Buffer = buffer; - str.Length = i * sizeof(WCHAR); + status = open_subkey( &subkey, subkey_root, &name, options, access ); + if (subkey_root && subkey_root != root) NtClose( subkey_root ); + subkey_root = subkey; + }
- if (i == len) - { - if (options & REG_OPTION_OPEN_LINK) attr->Attributes |= OBJ_OPENLINK; - status = NtOpenKeyEx( &subkey, access, attr, options ); - } - else - { - if (!(options & REG_OPTION_OPEN_LINK)) attr->Attributes &= ~OBJ_OPENLINK; - status = NtOpenKeyEx( &subkey, access, attr, options & ~REG_OPTION_OPEN_LINK ); - } - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - if (status) return status; - attr->RootDirectory = subkey; - while (i < len && buffer[i] == '\') i++; - buffer += i; - len -= i; + if (!status) + *retkey = subkey_root;
- str.Buffer = buffer; - str.Length = len * sizeof(WCHAR); - if (!is_wow6432node( &str )) - { - if ((subkey = open_wow6432node( attr->RootDirectory ))) - { - NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - } - } - } - if (status == STATUS_PREDEFINED_HANDLE) - { - attr->RootDirectory = get_perflib_key( attr->RootDirectory ); - status = STATUS_SUCCESS; - } - *retkey = attr->RootDirectory; return status; }
From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 148 ++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 74 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 926159de768..3418742c8bd 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -140,80 +140,6 @@ static HKEY get_perflib_key( HANDLE key ) return key; }
-/* wrapper for NtCreateKey that creates the key recursively if necessary */ -static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr, - const UNICODE_STRING *class, ULONG options, PULONG dispos ) -{ - BOOL force_wow32 = is_win64 && (access & KEY_WOW64_32KEY); - NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND; - HANDLE subkey, root = attr->RootDirectory; - - if (!force_wow32) status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos ); - - if (status == STATUS_OBJECT_NAME_NOT_FOUND) - { - WCHAR *buffer = attr->ObjectName->Buffer; - DWORD attrs, pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); - UNICODE_STRING str; - - /* don't try to create registry root */ - if (!attr->RootDirectory && len > 10 && !wcsnicmp( buffer, L"\Registry\", 10 )) i += 10; - - while (i < len && buffer[i] != '\') i++; - if (i == len && !force_wow32) return status; - - attrs = attr->Attributes; - attr->ObjectName = &str; - - for (;;) - { - str.Buffer = buffer + pos; - str.Length = (i - pos) * sizeof(WCHAR); - if (force_wow32 && pos) - { - if (is_wow6432node( &str )) force_wow32 = FALSE; - else if ((subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - force_wow32 = FALSE; - } - } - if (i == len) - { - attr->Attributes = attrs; - status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos ); - } - else - { - attr->Attributes = attrs & ~OBJ_OPENLINK; - status = NtCreateKey( &subkey, access, attr, 0, class, - options & ~REG_OPTION_CREATE_LINK, dispos ); - } - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - if (!NT_SUCCESS(status)) return status; - if (i == len) break; - attr->RootDirectory = subkey; - while (i < len && buffer[i] == '\') i++; - pos = i; - while (i < len && buffer[i] != '\') i++; - } - } - attr->RootDirectory = subkey; - if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - } - if (status == STATUS_PREDEFINED_HANDLE) - { - attr->RootDirectory = get_perflib_key( attr->RootDirectory ); - status = STATUS_SUCCESS; - } - *retkey = attr->RootDirectory; - return status; -} - static NTSTATUS open_subkey( HKEY *subkey, HKEY root, UNICODE_STRING *name, DWORD options, ACCESS_MASK access ) { DWORD i = 0, len = name->Length / sizeof(WCHAR); @@ -310,6 +236,80 @@ static NTSTATUS open_key( HKEY *retkey, DWORD options, ACCESS_MASK access, OBJEC return status; }
+/* wrapper for NtCreateKey that creates the key recursively if necessary */ +static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr, + const UNICODE_STRING *class, ULONG options, PULONG dispos ) +{ + BOOL force_wow32 = is_win64 && (access & KEY_WOW64_32KEY); + NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND; + HANDLE subkey, root = attr->RootDirectory; + + if (!force_wow32) status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos ); + + if (status == STATUS_OBJECT_NAME_NOT_FOUND) + { + WCHAR *buffer = attr->ObjectName->Buffer; + DWORD attrs, pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); + UNICODE_STRING str; + + /* don't try to create registry root */ + if (!attr->RootDirectory && len > 10 && !wcsnicmp( buffer, L"\Registry\", 10 )) i += 10; + + while (i < len && buffer[i] != '\') i++; + if (i == len && !force_wow32) return status; + + attrs = attr->Attributes; + attr->ObjectName = &str; + + for (;;) + { + str.Buffer = buffer + pos; + str.Length = (i - pos) * sizeof(WCHAR); + if (force_wow32 && pos) + { + if (is_wow6432node( &str )) force_wow32 = FALSE; + else if ((subkey = open_wow6432node( attr->RootDirectory ))) + { + if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); + attr->RootDirectory = subkey; + force_wow32 = FALSE; + } + } + if (i == len) + { + attr->Attributes = attrs; + status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos ); + } + else + { + attr->Attributes = attrs & ~OBJ_OPENLINK; + status = NtCreateKey( &subkey, access, attr, 0, class, + options & ~REG_OPTION_CREATE_LINK, dispos ); + } + if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); + if (!NT_SUCCESS(status)) return status; + if (i == len) break; + attr->RootDirectory = subkey; + while (i < len && buffer[i] == '\') i++; + pos = i; + while (i < len && buffer[i] != '\') i++; + } + } + attr->RootDirectory = subkey; + if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory ))) + { + if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); + attr->RootDirectory = subkey; + } + if (status == STATUS_PREDEFINED_HANDLE) + { + attr->RootDirectory = get_perflib_key( attr->RootDirectory ); + status = STATUS_SUCCESS; + } + *retkey = attr->RootDirectory; + return status; +} + /* create one of the HKEY_* special root keys */ static HKEY create_special_root_hkey( HKEY hkey, DWORD access ) {
From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 3418742c8bd..f96a18a9599 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -244,7 +244,19 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND; HANDLE subkey, root = attr->RootDirectory;
- if (!force_wow32) status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos ); + if (!force_wow32) + { + if (options & REG_OPTION_OPEN_LINK) attr->Attributes |= OBJ_OPENLINK; + status = NtCreateKey( (HANDLE *)retkey, access, attr, 0, class, options, dispos ); + if (status == STATUS_PREDEFINED_HANDLE) + { + *retkey = get_perflib_key( *retkey ); + status = STATUS_SUCCESS; + } + + if (!status || status != STATUS_OBJECT_NAME_NOT_FOUND) + return status; + }
if (status == STATUS_OBJECT_NAME_NOT_FOUND) {
From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 55 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 29 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index f96a18a9599..5c8b82423c1 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -261,32 +261,23 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES if (status == STATUS_OBJECT_NAME_NOT_FOUND) { WCHAR *buffer = attr->ObjectName->Buffer; - DWORD attrs, pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); + DWORD attrs, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); UNICODE_STRING str;
- /* don't try to create registry root */ - if (!attr->RootDirectory && len > 10 && !wcsnicmp( buffer, L"\Registry\", 10 )) i += 10; - - while (i < len && buffer[i] != '\') i++; - if (i == len && !force_wow32) return status; - attrs = attr->Attributes; attr->ObjectName = &str;
- for (;;) + while (len) { - str.Buffer = buffer + pos; - str.Length = (i - pos) * sizeof(WCHAR); - if (force_wow32 && pos) - { - if (is_wow6432node( &str )) force_wow32 = FALSE; - else if ((subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - force_wow32 = FALSE; - } - } + i = 0; + + /* don't try to create registry root */ + if (!attr->RootDirectory && len > 10 && !wcsnicmp( buffer, L"\Registry\", 10 )) i += 10; + while (i < len && buffer[i] != '\') i++; + + str.Buffer = buffer; + str.Length = i * sizeof(WCHAR); + if (i == len) { attr->Attributes = attrs; @@ -300,19 +291,25 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES } if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); if (!NT_SUCCESS(status)) return status; - if (i == len) break; attr->RootDirectory = subkey; while (i < len && buffer[i] == '\') i++; - pos = i; - while (i < len && buffer[i] != '\') i++; + buffer += i; + len -= i; + + if (force_wow32) + { + str.Buffer = buffer; + str.Length = len * sizeof(WCHAR); + if (is_wow6432node( &str )) force_wow32 = FALSE; + else if ((subkey = open_wow6432node( attr->RootDirectory ))) + { + NtClose( attr->RootDirectory ); + attr->RootDirectory = subkey; + force_wow32 = FALSE; + } + } } } - attr->RootDirectory = subkey; - if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - } if (status == STATUS_PREDEFINED_HANDLE) { attr->RootDirectory = get_perflib_key( attr->RootDirectory );
On Fri Feb 24 10:41:01 2023 +0000, Sven Baars wrote:
changed this line in [version 14 of the diff](/wine/wine/-/merge_requests/1445/diffs?diff_id=34350&start_sha=1b2eacf240c410f9e128d83369e43da020ae214c#f66e6edc06b5ee9e6073759e1274284fb43d3be2_103_103)
I pushed a new version where I changed it such that it includes a \ if the remaining string is longer. Later it will be used in many edge cases where we have to detect if the next node that we will parse is a wow6432node, not the current one. This is also what I already start doing this refactor, which is why it is needed here.
On Fri Feb 24 10:44:42 2023 +0000, Sven Baars wrote:
I pushed a new version where I changed it such that it includes a \ if the remaining string is longer. Later it will be used in many edge cases where we have to detect if the next node that we will parse is a wow6432node, not the current one. This is also what I already start doing this refactor, which is why it is needed here.
I could also introduce `get_path_element` as it is implemented in the server, but it is not clear to me that that actually makes the code more readable. It still means mixing `get_path_element` and while loops over trailing `\` as is done in the server.
The last patch is introducing a warning:
``` i686-w64-mingw32-gcc -c -o dlls/kernelbase/i386-windows/registry.o dlls/kernelbase/registry.c -Idlls/kernelbase -Iinclude \ -Iinclude/msvcrt -D_MSVCR_VER=0 -D__WINESRC__ -DWINBASEAPI= -DWINADVAPI= -DWINUSERAPI= \ -DWINSHLWAPI= -D__WINE_PE_BUILD -Wall -fno-strict-aliasing -Wdeclaration-after-statement \ -Wempty-body -Wignored-qualifiers -Winit-self -Wno-packed-not-aligned -Wshift-overflow=2 \ -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith \ -Wlogical-op -Wabsolute-value -fno-omit-frame-pointer -gdwarf-4 -Werror -g -O2 -fno-diagnostics-show-caret dlls/kernelbase/registry.c: In function ‘create_key’: dlls/kernelbase/registry.c:262:26: error: storing the address of local variable ‘str’ in ‘*attr.ObjectName’ [-Werror=dangling-pointer=] dlls/kernelbase/registry.c:259:24: note: ‘str’ declared here dlls/kernelbase/registry.c:259:24: note: ‘attr’ declared here cc1: all warnings being treated as errors make: *** [Makefile:68674: dlls/kernelbase/i386-windows/registry.o] Error 1 ```
On Thu Mar 9 09:30:49 2023 +0000, Alexandre Julliard wrote:
The last patch is introducing a warning:
i686-w64-mingw32-gcc -c -o dlls/kernelbase/i386-windows/registry.o dlls/kernelbase/registry.c -Idlls/kernelbase -Iinclude \ -Iinclude/msvcrt -D_MSVCR_VER=0 -D__WINESRC__ -DWINBASEAPI= -DWINADVAPI= -DWINUSERAPI= \ -DWINSHLWAPI= -D__WINE_PE_BUILD -Wall -fno-strict-aliasing -Wdeclaration-after-statement \ -Wempty-body -Wignored-qualifiers -Winit-self -Wno-packed-not-aligned -Wshift-overflow=2 \ -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith \ -Wlogical-op -Wabsolute-value -fno-omit-frame-pointer -gdwarf-4 -Werror -g -O2 -fno-diagnostics-show-caret dlls/kernelbase/registry.c: In function ‘create_key’: dlls/kernelbase/registry.c:262:26: error: storing the address of local variable ‘str’ in ‘*attr.ObjectName’ [-Werror=dangling-pointer=] dlls/kernelbase/registry.c:259:24: note: ‘str’ declared here dlls/kernelbase/registry.c:259:24: note: ‘attr’ declared here cc1: all warnings being treated as errors make: *** [Makefile:68674: dlls/kernelbase/i386-windows/registry.o] Error 1
That's very strange since I didn't modify these lines of code, so I'd expect the warning to also be there before any of my patches. I also don't see the warning locally.
I do get rid of this code later in my patch series. Fixing it earlier will create a mess since attr is currently used everywhere, but I guess it could be done. Since I don't see the warning it may be difficult to do without introducing it again in intermediate commits.