Francois Gouget : regedit: Modify getRegClass()
to avoid dubious comparisons and casts between HKEYs and error codes.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jun 14 07:47:07 CDT 2007
Module: wine
Branch: master
Commit: 8e362cb65ac1aea1c0733cbb3202ed2ba327940b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8e362cb65ac1aea1c0733cbb3202ed2ba327940b
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Thu Jun 14 11:53:41 2007 +0200
regedit: Modify getRegClass() to avoid dubious comparisons and casts between HKEYs and error codes.
---
programs/regedit/regproc.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index a973ad0..d1d757d 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -279,7 +279,7 @@ static LONG setValue(LPSTR val_name, LPSTR val_data)
* Extracts from [HKEY\some\key\path] or HKEY\some\key\path types of line
* the key class (what ends before the first '\')
*/
-static HKEY getRegClass(LPSTR lpClass)
+static BOOL getRegClass(LPSTR lpClass, HKEY* hkey)
{
LPSTR classNameEnd;
LPSTR classNameBeg;
@@ -288,7 +288,7 @@ static HKEY getRegClass(LPSTR lpClass)
char lpClassCopy[KEY_MAX_LEN];
if (lpClass == NULL)
- return (HKEY)ERROR_INVALID_PARAMETER;
+ return FALSE;
lstrcpynA(lpClassCopy, lpClass, KEY_MAX_LEN);
@@ -310,10 +310,11 @@ static HKEY getRegClass(LPSTR lpClass)
for (i = 0; i < REG_CLASS_NUMBER; i++) {
if (!strcmp(classNameBeg, reg_class_names[i])) {
- return reg_class_keys[i];
+ *hkey = reg_class_keys[i];
+ return TRUE;
}
}
- return (HKEY)ERROR_INVALID_PARAMETER;
+ return FALSE;
}
/******************************************************************************
@@ -365,8 +366,7 @@ static LONG openKey( LPSTR stdInput)
return ERROR_INVALID_PARAMETER;
/* Get the registry class */
- currentKeyClass = getRegClass(stdInput); /* Sets global variable */
- if (currentKeyClass == (HKEY)ERROR_INVALID_PARAMETER)
+ if (!getRegClass(stdInput, ¤tKeyClass)) /* Sets global variable */
return ERROR_INVALID_PARAMETER;
/* Get the key name */
@@ -918,8 +918,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
strcpy(reg_key_name_buf, reg_key_name);
/* open the specified key */
- reg_key_class = getRegClass(reg_key_name);
- if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) {
+ if (!getRegClass(reg_key_name, ®_key_class)) {
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
getAppName(), reg_key_name);
exit(1);
@@ -1052,8 +1051,7 @@ void delete_registry_key(CHAR *reg_key_name)
if (!reg_key_name || !reg_key_name[0])
return;
/* open the specified key */
- reg_key_class = getRegClass(reg_key_name);
- if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) {
+ if (!getRegClass(reg_key_name, ®_key_class)) {
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
getAppName(), reg_key_name);
exit(1);
More information about the wine-cvs
mailing list