[PATCH 6/6] efi_runtime: expand to a full if-conditional instead of using terneary operator
Colin Ian King
colin.king at canonical.com
Fri Aug 19 07:54:12 UTC 2016
On 19/08/16 03:57, Ivan Hu wrote:
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
> efi_runtime/efi_runtime.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 6f8e096..a18690f 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -309,6 +309,7 @@ static long efi_runtime_get_time(unsigned long arg)
> efi_status_t status;
> efi_time_cap_t cap;
> efi_time_t efi_time;
> + int rv = 0;
>
> gettime_user = (struct efi_gettime __user *)arg;
> if (copy_from_user(&gettime, gettime_user, sizeof(gettime)))
> @@ -333,10 +334,12 @@ static long efi_runtime_get_time(unsigned long arg)
> put_user(cap.sets_to_zero, &(cap_local->sets_to_zero)))
> return -EFAULT;
> }
> - if (gettime.time)
> - return copy_to_user(gettime.time, &efi_time,
> - sizeof(efi_time_t)) ? -EFAULT : 0;
> - return 0;
> + if (gettime.time) {
> + if(copy_to_user(gettime.time, &efi_time, sizeof(efi_time_t)))
> + return -EFAULT;
> + }
> +
> + return status == EFI_SUCCESS ? 0 : -EINVAL;
> }
>
> static long efi_runtime_set_time(unsigned long arg)
> @@ -367,6 +370,7 @@ static long efi_runtime_get_waketime(unsigned long arg)
> efi_bool_t enabled, pending;
> efi_status_t status;
> efi_time_t efi_time;
> + int rv = 0;
>
> getwakeuptime_user = (struct efi_getwakeuptime __user *)arg;
> if (copy_from_user(&getwakeuptime, getwakeuptime_user,
> @@ -386,10 +390,13 @@ static long efi_runtime_get_waketime(unsigned long arg)
> getwakeuptime.enabled))
> return -EFAULT;
>
> - if (getwakeuptime.time)
> - return copy_to_user(getwakeuptime.time, &efi_time,
> - sizeof(efi_time_t)) ? -EFAULT : 0;
> - return 0;
> + if (getwakeuptime.time) {
> + if (copy_to_user(getwakeuptime.time, &efi_time,
> + sizeof(efi_time_t)))
> + return -EFAULT;
> + }
> +
> + return status == EFI_SUCCESS ? 0 : -EINVAL;
> }
>
> static long efi_runtime_set_waketime(unsigned long arg)
>
I get the following warning when applying this patch:
Applying: efi_runtime: expand to a full if-conditional instead of using
terneary operator
.git/rebase-apply/patch:55: trailing whitespace.
warning: 1 line adds whitespace errors.
This final patch introduces build warnings:
gcc version 6.1.1 20160815 (Ubuntu 6.1.1-12ubuntu11) 4.6.0-10-generic
make -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory '/usr/src/linux-headers-4.6.0-10-generic'
CC [M] /home/king/repos/fwts/efi_runtime/efi_runtime.o
/home/king/repos/fwts/efi_runtime/efi_runtime.c: In function
‘efi_runtime_get_time’:
/home/king/repos/fwts/efi_runtime/efi_runtime.c:312:6: warning: unused
variable ‘rv’ [-Wunused-variable]
int rv = 0;
^~
/home/king/repos/fwts/efi_runtime/efi_runtime.c: In function
‘efi_runtime_get_waketime’:
/home/king/repos/fwts/efi_runtime/efi_runtime.c:373:6: warning: unused
variable ‘rv’ [-Wunused-variable]
int rv = 0;
^~
Building modules, stage 2.
MODPOST 1 modules
CC /home/king/repos/fwts/efi_runtime/efi_runtime.mod.o
LD [M] /home/king/repos/fwts/efi_runtime/efi_runtime.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.6.0-10-generic'
More information about the fwts-devel
mailing list