Re: [3/7] msi: Don't create a temporary copy of the package. (try 2)

2011-08-23 Thread Joris Huizer

Just an implementation detail I noticed:

On 08/23/2011 11:45 AM, Hans Leidekker wrote:

+
+static UINT get_registered_local_package( const WCHAR *product, const WCHAR 
*package, WCHAR *localfile )
+{
+MSIINSTALLCONTEXT context;
+HKEY product_key, props_key;
+WCHAR *registered_package = NULL, unsquashed[GUID_SIZE];
+UINT r = ERROR_FUNCTION_FAILED;
+
+r = msi_locate_product( product,context );
+if (r != ERROR_SUCCESS)
+return r;
+
+r = MSIREG_OpenProductKey( product, NULL, context,product_key, FALSE );
+if (r != ERROR_SUCCESS)
+return r;
+
+r = MSIREG_OpenInstallProps( product, context, NULL,props_key, FALSE );
+if (r != ERROR_SUCCESS)
+{
+RegCloseKey( product_key );
+return r;
+}
+registered_package = msi_reg_get_val_str( product_key, 
INSTALLPROPERTY_PACKAGECODEW );
+if (!registered_package)
+goto done;
+
+unsquash_guid( registered_package, unsquashed );
+if (!strcmpiW( package, unsquashed ))
+{
+WCHAR *filename = msi_reg_get_val_str( props_key, 
INSTALLPROPERTY_LOCALPACKAGEW );
+strcpyW( localfile, filename );
+msi_free( filename );
+r = ERROR_SUCCESS;
+}
+done:
+msi_free( registered_package );
+RegCloseKey( props_key );
+RegCloseKey( product_key );
+return r;
+}
+



I'm confused about the last part of the function.
I think if the comparison between 'package' and 'unsquashed' fails, you 
want to return an error,
but the return value 'r' will be ERROR_SUCCESS at that point, and isn't 
updated.


HTH,
Joris




Re: [3/7] msi: Don't create a temporary copy of the package. (try 2)

2011-08-23 Thread Octavian Voicu
On Tue, Aug 23, 2011 at 3:13 PM, Joris Huizer joris_hui...@yahoo.comwrote:

 On 08/23/2011 11:45 AM, Hans Leidekker wrote:

 +if (!strcmpiW( package, unsquashed ))


 I'm confused about the last part of the function.
 I think if the comparison between 'package' and 'unsquashed' fails, you
 want to return an error,
 but the return value 'r' will be ERROR_SUCCESS at that point, and isn't
 updated.


Hello,

The function strcmpiW returns 0 when the strings are equal, and non-zero
when they are different ( 0 if first is smaller,  0 if first is larger,
lexicographically speaking). The condition checks if the strings match, not
if the function failed (string comparison cannot fail).

Cheers,
Octavian