[PATCH] advapi32: remove deadcode (Coverity)
Marcus Meissner
marcus at jet.franken.de
Sun Jul 19 04:30:38 CDT 2015
1248384 Logically dead code
1311598 Logically dead code
value is non-NULL as checked before, so further checks are not needed,
in both cases
---
dlls/advapi32/registry.c | 46 ++++++++++++++++++++--------------------------
1 file changed, 20 insertions(+), 26 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 256c514..2b22f5c 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -1929,7 +1929,7 @@ LSTATUS WINAPI RegEnumValueW( HKEY hkey, DWORD index, LPWSTR value, LPDWORD val_
buffer, total_size, &total_size );
if (status && status != STATUS_BUFFER_OVERFLOW) goto done;
- if (value || data)
+ if (data)
{
/* retry with a dynamically allocated buffer */
while (status == STATUS_BUFFER_OVERFLOW)
@@ -1944,33 +1944,27 @@ LSTATUS WINAPI RegEnumValueW( HKEY hkey, DWORD index, LPWSTR value, LPDWORD val_
if (status) goto done;
- if (value)
+ if (info->NameLength/sizeof(WCHAR) >= *val_count)
{
- if (info->NameLength/sizeof(WCHAR) >= *val_count)
- {
- status = STATUS_BUFFER_OVERFLOW;
- goto overflow;
- }
- memcpy( value, info->Name, info->NameLength );
- *val_count = info->NameLength / sizeof(WCHAR);
- value[*val_count] = 0;
+ status = STATUS_BUFFER_OVERFLOW;
+ goto overflow;
}
+ memcpy( value, info->Name, info->NameLength );
+ *val_count = info->NameLength / sizeof(WCHAR);
+ value[*val_count] = 0;
- if (data)
+ if (total_size - info->DataOffset > *count)
{
- if (total_size - info->DataOffset > *count)
- {
- status = STATUS_BUFFER_OVERFLOW;
- goto overflow;
- }
- memcpy( data, buf_ptr + info->DataOffset, total_size - info->DataOffset );
- if (total_size - info->DataOffset <= *count-sizeof(WCHAR) && is_string(info->Type))
- {
- /* if the type is REG_SZ and data is not 0-terminated
- * and there is enough space in the buffer NT appends a \0 */
- WCHAR *ptr = (WCHAR *)(data + total_size - info->DataOffset);
- if (ptr > (WCHAR *)data && ptr[-1]) *ptr = 0;
- }
+ status = STATUS_BUFFER_OVERFLOW;
+ goto overflow;
+ }
+ memcpy( data, buf_ptr + info->DataOffset, total_size - info->DataOffset );
+ if (total_size - info->DataOffset <= *count-sizeof(WCHAR) && is_string(info->Type))
+ {
+ /* if the type is REG_SZ and data is not 0-terminated
+ * and there is enough space in the buffer NT appends a \0 */
+ WCHAR *ptr = (WCHAR *)(data + total_size - info->DataOffset);
+ if (ptr > (WCHAR *)data && ptr[-1]) *ptr = 0;
}
}
else status = STATUS_SUCCESS;
@@ -2017,7 +2011,7 @@ LSTATUS WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_c
/* we need to fetch the contents for a string type even if not requested,
* because we need to compute the length of the ASCII string. */
- if (value || data || is_string(info->Type))
+ if (data || is_string(info->Type))
{
/* retry with a dynamically allocated buffer */
while (status == STATUS_BUFFER_OVERFLOW)
@@ -2057,7 +2051,7 @@ LSTATUS WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_c
else memcpy( data, buf_ptr + info->DataOffset, total_size - info->DataOffset );
}
- if (value && !status)
+ if (!status)
{
DWORD len;
--
2.4.5
More information about the wine-patches
mailing list