ACK: [PATCH 43/46] uefi: uefidump: reduce scope of variables

IvanHu ivan.hu at canonical.com
Thu Jan 15 07:39:37 UTC 2015


On 01/14/2015 03:05 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/uefi/uefidump/uefidump.c:996]:
> 	(style) The scope of the variable 'path' can be reduced.
> [src/uefi/uefidump/uefidump.c:997]:
> 	(style) The scope of the variable 'tmp' can be reduced.
> [src/uefi/uefidump/uefidump.c:998]:
> 	(style) The scope of the variable 'offset' can be reduced.
> [src/uefi/uefidump/uefidump.c:1105]:
> 	(style) The scope of the variable 'signature_list' can be reduced.
> [src/uefi/uefidump/uefidump.c:1107]:
> 	(style) The scope of the variable 'offset' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 9d1b1cb..15efd7d 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -993,9 +993,7 @@ static void uefidump_info_driverorder(fwts_framework *fw, fwts_uefi_var *var)
>   static void uefidump_info_driverdev(fwts_framework *fw, fwts_uefi_var *var)
>   {
>   	fwts_uefi_load_option *load_option;
> -	char *path;
> -	char *tmp;
> -	size_t len, offset;
> +	size_t len;
>
>   	if (var->datalen < sizeof(fwts_uefi_load_option))
>   		return;
> @@ -1006,7 +1004,7 @@ static void uefidump_info_driverdev(fwts_framework *fw, fwts_uefi_var *var)
>
>   	len = fwts_uefi_str16len(load_option->description);
>   	if (len != 0) {
> -		tmp = malloc(len + 1);
> +		char *tmp = malloc(len + 1);
>   		if (tmp) {
>   			fwts_uefi_str16_to_str(tmp, len + 1, load_option->description);
>   			fwts_log_info_verbatum(fw, "  Info: %s\n", tmp);
> @@ -1015,6 +1013,9 @@ static void uefidump_info_driverdev(fwts_framework *fw, fwts_uefi_var *var)
>   	}
>
>   	if (load_option->file_path_list_length != 0) {
> +		char *path;
> +		size_t offset;
> +
>   		/* Skip over description to get to packed path, unpack path and print */
>   		offset = sizeof(load_option->attributes) +
>   			 sizeof(load_option->file_path_list_length) +
> @@ -1102,9 +1103,8 @@ static void uefidump_info_keyoption(fwts_framework *fw, fwts_uefi_var *var)
>
>   static void uefidump_info_signaturedatabase(fwts_framework *fw, fwts_uefi_var *var)
>   {
> -	fwts_uefi_signature_list *signature_list;
>   	char guid_str[37];
> -	size_t offset = 0, list_start = 0;
> +	size_t list_start = 0;
>   	size_t i;
>
>   	typedef struct {
> @@ -1132,8 +1132,11 @@ static void uefidump_info_signaturedatabase(fwts_framework *fw, fwts_uefi_var *v
>   		return;
>
>   	do {
> -		signature_list = (fwts_uefi_signature_list *)(var->data + list_start);
> +		fwts_uefi_signature_list *signature_list =
> +			(fwts_uefi_signature_list *)(var->data + list_start);
>   		const char *str = "Unknown GUID";
> +		size_t offset = 0;
> +
>   		fwts_guid_buf_to_str(var->data, guid_str, sizeof(guid_str));
>
>   		for (i = 0; guids[i].str; i++)
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list