ACK: [PATCH] uefi: uefirttime: make status static, cleans up cppcheck warnings

Alex Hung alex.hung at canonical.com
Tue Jun 11 16:32:05 UTC 2019


On 2019-06-11 2:28 a.m., Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> Using an auto-variable (declared on the stack) for the status
> is problematic because we return the address of this variable
> back to the callee via a function parameter. Thus there is a
> potential of the callee referencing the now dead stack variable.
> Although this is not actually referenced later, it's worth just
> cleaning this up by making the variable static so we avoid any
> potential risk in the future.  Cleans up 3 cppcheck warnings
> of the kind:
> 
> "(error) Address of local auto-variable assigned to a function parameter."
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/uefi/uefirttime/uefirttime.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/uefi/uefirttime/uefirttime.c b/src/uefi/uefirttime/uefirttime.c
> index 7626f06e..647bd5a7 100644
> --- a/src/uefi/uefirttime/uefirttime.c
> +++ b/src/uefi/uefirttime/uefirttime.c
> @@ -401,8 +401,9 @@ static int uefirttime_test_settime_invalid(
>  	struct efi_settime *settime)
>  {
>  	long ioret;
> -	uint64_t status = ~0ULL;
> +	static uint64_t status;
>  
> +	status = ~0ULL;
>  	settime->status = &status;
>  
>  	ioret = ioctl(fd, EFI_RUNTIME_SET_TIME, settime);
> @@ -648,7 +649,9 @@ static int uefirttime_test_getwaketime_invalid(
>  	struct efi_getwakeuptime *getwakeuptime)
>  {
>  	long ioret;
> -	uint64_t status = ~0ULL;
> +	static uint64_t status;
> +
> +	status = ~0ULL;
>  	getwakeuptime->status = &status;
>  
>  	ioret = ioctl(fd, EFI_RUNTIME_GET_WAKETIME, getwakeuptime);
> @@ -854,8 +857,9 @@ static int uefirttime_test_setwakeuptime_invalid(
>  )
>  {
>  	long ioret;
> -	uint64_t status = ~0ULL;
> +	static uint64_t status;
>  
> +	status = ~0ULL;
>  	setwakeuptime->status = &status;
>  
>  	ioret = ioctl(fd, EFI_RUNTIME_SET_WAKETIME, setwakeuptime);
> 


Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list