diff mbox

We're getting efi_runtime build warnings with recent kernels:

Message ID 1373026086-29184-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King July 5, 2013, 12:08 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

make -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-25-generic'
  CC [M] /home/king/tmp/fwts/efi_runtime/efi_runtime.o
/home/king/tmp/fwts/efi_runtime/efi_runtime.c: In function ‘efi_runtime_init’:
/home/king/tmp/fwts/efi_runtime/efi_runtime.c:364:6: warning: the address of ‘efi_enabled’ will always evaluate as ‘true’ [-Waddress]

This occurs because of kernel commit 83e681897 which turned efi_enabled from an integer into a function, hence efi_enabled will always now evaluate as true.
The commit introduced macro EFI_RUNTIME_SERVICES so if this is defined we
call efi_enabled() otherwise efi_enabled is a plain int.  So use this macro
to determine if we are using historic or new efi_enabled for different kernel
versions.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 efi_runtime/efi_runtime.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Alex Hung July 8, 2013, 1:58 a.m. UTC | #1
On 07/05/2013 08:08 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> make -C /lib/modules/`uname -r`/build M=`pwd` modules
> make[1]: Entering directory `/usr/src/linux-headers-3.8.0-25-generic'
>    CC [M] /home/king/tmp/fwts/efi_runtime/efi_runtime.o
> /home/king/tmp/fwts/efi_runtime/efi_runtime.c: In function ‘efi_runtime_init’:
> /home/king/tmp/fwts/efi_runtime/efi_runtime.c:364:6: warning: the address of ‘efi_enabled’ will always evaluate as ‘true’ [-Waddress]
>
> This occurs because of kernel commit 83e681897 which turned efi_enabled from an integer into a function, hence efi_enabled will always now evaluate as true.
> The commit introduced macro EFI_RUNTIME_SERVICES so if this is defined we
> call efi_enabled() otherwise efi_enabled is a plain int.  So use this macro
> to determine if we are using historic or new efi_enabled for different kernel
> versions.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   efi_runtime/efi_runtime.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 63fea7b..73171df 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -34,6 +34,13 @@ MODULE_AUTHOR("Ivan Hu");
>   MODULE_DESCRIPTION("EFI Runtime Driver");
>   MODULE_LICENSE("GPL");
>
> +/* commit 83e681897 turned efi_enabled into a function, so abstract it */
> +#ifdef EFI_RUNTIME_SERVICES
> +#define EFI_RUNTIME_ENABLED	efi_enabled(EFI_RUNTIME_SERVICES)
> +#else
> +#define EFI_RUNTIME_ENABLED	efi_enabled
> +#endif
> +
>   static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
>   {
>   	memset(time, 0, sizeof(EFI_TIME));
> @@ -361,8 +368,10 @@ static int __init efi_runtime_init(void)
>
>   	printk(KERN_INFO "EFI_RUNTIME Driver v%s\n", EFI_FWTS_EFI_VERSION);
>
> -	if (!efi_enabled)
> +	if (!EFI_RUNTIME_ENABLED) {
> +		printk(KERN_INFO "EFI runtime services not enabled.\n");
>   		return -ENODEV;
> +	}
>
>   	ret = misc_register(&efi_runtime_dev);
>   	if (ret) {
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Colin Ian King July 8, 2013, 7:37 a.m. UTC | #2
On 05/07/13 13:08, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> make -C /lib/modules/`uname -r`/build M=`pwd` modules
> make[1]: Entering directory `/usr/src/linux-headers-3.8.0-25-generic'
>   CC [M] /home/king/tmp/fwts/efi_runtime/efi_runtime.o
> /home/king/tmp/fwts/efi_runtime/efi_runtime.c: In function ‘efi_runtime_init’:
> /home/king/tmp/fwts/efi_runtime/efi_runtime.c:364:6: warning: the address of ‘efi_enabled’ will always evaluate as ‘true’ [-Waddress]
> 
> This occurs because of kernel commit 83e681897 which turned efi_enabled from an integer into a function, hence efi_enabled will always now evaluate as true.
> The commit introduced macro EFI_RUNTIME_SERVICES so if this is defined we
> call efi_enabled() otherwise efi_enabled is a plain int.  So use this macro
> to determine if we are using historic or new efi_enabled for different kernel
> versions.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  efi_runtime/efi_runtime.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 63fea7b..73171df 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -34,6 +34,13 @@ MODULE_AUTHOR("Ivan Hu");
>  MODULE_DESCRIPTION("EFI Runtime Driver");
>  MODULE_LICENSE("GPL");
>  
> +/* commit 83e681897 turned efi_enabled into a function, so abstract it */
> +#ifdef EFI_RUNTIME_SERVICES
> +#define EFI_RUNTIME_ENABLED	efi_enabled(EFI_RUNTIME_SERVICES)
> +#else
> +#define EFI_RUNTIME_ENABLED	efi_enabled
> +#endif
> +
>  static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
>  {
>  	memset(time, 0, sizeof(EFI_TIME));
> @@ -361,8 +368,10 @@ static int __init efi_runtime_init(void)
>  
>  	printk(KERN_INFO "EFI_RUNTIME Driver v%s\n", EFI_FWTS_EFI_VERSION);
>  
> -	if (!efi_enabled)
> +	if (!EFI_RUNTIME_ENABLED) {
> +		printk(KERN_INFO "EFI runtime services not enabled.\n");
>  		return -ENODEV;
> +	}
>  
>  	ret = misc_register(&efi_runtime_dev);
>  	if (ret) {
> 

Forgot to mention: LP: #1198168 for this patch, Keng-Yu, can you add
that to the subject line of the patch before applying?

Colin
Keng-Yu Lin July 8, 2013, 8:33 a.m. UTC | #3
On Mon, Jul 8, 2013 at 3:37 PM, Colin Ian King <colin.king@canonical.com> wrote:
> On 05/07/13 13:08, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> make -C /lib/modules/`uname -r`/build M=`pwd` modules
>> make[1]: Entering directory `/usr/src/linux-headers-3.8.0-25-generic'
>>   CC [M] /home/king/tmp/fwts/efi_runtime/efi_runtime.o
>> /home/king/tmp/fwts/efi_runtime/efi_runtime.c: In function ‘efi_runtime_init’:
>> /home/king/tmp/fwts/efi_runtime/efi_runtime.c:364:6: warning: the address of ‘efi_enabled’ will always evaluate as ‘true’ [-Waddress]
>>
>> This occurs because of kernel commit 83e681897 which turned efi_enabled from an integer into a function, hence efi_enabled will always now evaluate as true.
>> The commit introduced macro EFI_RUNTIME_SERVICES so if this is defined we
>> call efi_enabled() otherwise efi_enabled is a plain int.  So use this macro
>> to determine if we are using historic or new efi_enabled for different kernel
>> versions.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  efi_runtime/efi_runtime.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
>> index 63fea7b..73171df 100644
>> --- a/efi_runtime/efi_runtime.c
>> +++ b/efi_runtime/efi_runtime.c
>> @@ -34,6 +34,13 @@ MODULE_AUTHOR("Ivan Hu");
>>  MODULE_DESCRIPTION("EFI Runtime Driver");
>>  MODULE_LICENSE("GPL");
>>
>> +/* commit 83e681897 turned efi_enabled into a function, so abstract it */
>> +#ifdef EFI_RUNTIME_SERVICES
>> +#define EFI_RUNTIME_ENABLED  efi_enabled(EFI_RUNTIME_SERVICES)
>> +#else
>> +#define EFI_RUNTIME_ENABLED  efi_enabled
>> +#endif
>> +
>>  static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
>>  {
>>       memset(time, 0, sizeof(EFI_TIME));
>> @@ -361,8 +368,10 @@ static int __init efi_runtime_init(void)
>>
>>       printk(KERN_INFO "EFI_RUNTIME Driver v%s\n", EFI_FWTS_EFI_VERSION);
>>
>> -     if (!efi_enabled)
>> +     if (!EFI_RUNTIME_ENABLED) {
>> +             printk(KERN_INFO "EFI runtime services not enabled.\n");
>>               return -ENODEV;
>> +     }
>>
>>       ret = misc_register(&efi_runtime_dev);
>>       if (ret) {
>>
>
> Forgot to mention: LP: #1198168 for this patch, Keng-Yu, can you add
> that to the subject line of the patch before applying?
>
> Colin
>

No problem, and

Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index 63fea7b..73171df 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -34,6 +34,13 @@  MODULE_AUTHOR("Ivan Hu");
 MODULE_DESCRIPTION("EFI Runtime Driver");
 MODULE_LICENSE("GPL");
 
+/* commit 83e681897 turned efi_enabled into a function, so abstract it */
+#ifdef EFI_RUNTIME_SERVICES
+#define EFI_RUNTIME_ENABLED	efi_enabled(EFI_RUNTIME_SERVICES)
+#else
+#define EFI_RUNTIME_ENABLED	efi_enabled
+#endif
+
 static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
 {
 	memset(time, 0, sizeof(EFI_TIME));
@@ -361,8 +368,10 @@  static int __init efi_runtime_init(void)
 
 	printk(KERN_INFO "EFI_RUNTIME Driver v%s\n", EFI_FWTS_EFI_VERSION);
 
-	if (!efi_enabled)
+	if (!EFI_RUNTIME_ENABLED) {
+		printk(KERN_INFO "EFI runtime services not enabled.\n");
 		return -ENODEV;
+	}
 
 	ret = misc_register(&efi_runtime_dev);
 	if (ret) {