[PATCH 2/5] reg.exe: Add path_get_key() to remove boilerplate

Jonathan Vollebregt jnvsor at gmail.com
Wed Sep 3 06:15:43 CDT 2014


> +    if(path_get_rootkey_name(path))
> +    {
> +        return HKEYs[(path_get_rootkey_name(path) - &long_HKEY_name[0][0]) / 20];
> +    }
> +    else
> +    {
> +        return NULL;
> +    }
>
> Single line code in if/else blocks can be compacted to use less space. E.g.:
>
> if (path_get_rootkey_name(path))
>      return HKEYs[(path_get_rootkey_name(path) - &long_HKEY_name[0][0]) / 20];
> else
>      return NULL;

Isn't it a best practice to always use braces?

> +static const WCHAR type_names[][MAX_TYPE_LENGTH] = {
> +    {'R','E','G','_','N','O','N','E',0},
> +    {'R','E','G','_','S','Z',0},
> +    {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0},
> +    {'R','E','G','_','B','I','N','A','R','Y',0},
> +    {'R','E','G','_','D','W','O','R','D',0},
> +    {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0},
> +    {0},
> +    {'R','E','G','_','M','U','L','T','I','_','S','Z',0},
> +};
> +
> +
> +
>
> Also, what is the purpose of {0}?

REG_LINK isn't supported by anything in wine as far as I can tell, so I 
thought I'd just leave it empty. Would it be better to fill it in anyway?



More information about the wine-devel mailing list