linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi: respect const qualifier
@ 2014-04-17 15:53 Semen Protsenko
  2014-04-21 20:44 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Semen Protsenko @ 2014-04-17 15:53 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: linux-acpi, linux-kernel

This patch fixes next warning:

<------------------------------- cut here --------------------------------->
drivers/acpi/property.c: In function ‘acpi_free_properties’:
drivers/acpi/property.c:35:2: warning: passing argument 1 of ‘acpi_os_free’
                              discards ‘const’ qualifier from pointer
                              target type [enabled by default]

  ACPI_FREE(adev->properties);
<------------------------------- cut here --------------------------------->

The problem is next:

 - acpi_free_properties() calls ACPI_FREE(), passing "const *"
   parameter to it
 - ACPI_FREE() is macro for acpi_os_free()
 - acpi_os_free() takes "void *" parameter
 - acpi_os_free() calls kfree()
 - but kfree() requires "const void *" parameter

So acpi_os_free() should require "const void *" parameter as well.

Signed-off-by: Semen Protsenko <semen.protsenko@linaro.org>
---
 include/acpi/platform/aclinux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 93c55ed..c6fa763 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -174,7 +174,7 @@ static inline void *acpi_os_allocate_zeroed(acpi_size size)
 #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
 #define USE_NATIVE_ALLOCATE_ZEROED
 
-static inline void acpi_os_free(void *memory)
+static inline void acpi_os_free(const void *memory)
 {
 	kfree(memory);
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] acpi: respect const qualifier
  2014-04-17 15:53 [PATCH] acpi: respect const qualifier Semen Protsenko
@ 2014-04-21 20:44 ` Rafael J. Wysocki
  2014-04-25 15:02   ` Sam Protsenko
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2014-04-21 20:44 UTC (permalink / raw)
  To: Semen Protsenko; +Cc: Len Brown, linux-acpi, linux-kernel

On Thursday, April 17, 2014 06:53:26 PM Semen Protsenko wrote:
> This patch fixes next warning:
> 
> <------------------------------- cut here --------------------------------->
> drivers/acpi/property.c: In function ‘acpi_free_properties’:
> drivers/acpi/property.c:35:2: warning: passing argument 1 of ‘acpi_os_free’
>                               discards ‘const’ qualifier from pointer
>                               target type [enabled by default]
> 
>   ACPI_FREE(adev->properties);
> <------------------------------- cut here --------------------------------->

This is not a mainline kernel problem, surely?

> 
> The problem is next:
> 
>  - acpi_free_properties() calls ACPI_FREE(), passing "const *"
>    parameter to it
>  - ACPI_FREE() is macro for acpi_os_free()
>  - acpi_os_free() takes "void *" parameter
>  - acpi_os_free() calls kfree()
>  - but kfree() requires "const void *" parameter
> 
> So acpi_os_free() should require "const void *" parameter as well.
> 
> Signed-off-by: Semen Protsenko <semen.protsenko@linaro.org>
> ---
>  include/acpi/platform/aclinux.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
> index 93c55ed..c6fa763 100644
> --- a/include/acpi/platform/aclinux.h
> +++ b/include/acpi/platform/aclinux.h
> @@ -174,7 +174,7 @@ static inline void *acpi_os_allocate_zeroed(acpi_size size)
>  #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
>  #define USE_NATIVE_ALLOCATE_ZEROED
>  
> -static inline void acpi_os_free(void *memory)
> +static inline void acpi_os_free(const void *memory)
>  {
>  	kfree(memory);
>  }
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] acpi: respect const qualifier
  2014-04-21 20:44 ` Rafael J. Wysocki
@ 2014-04-25 15:02   ` Sam Protsenko
  0 siblings, 0 replies; 3+ messages in thread
From: Sam Protsenko @ 2014-04-25 15:02 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Len Brown, linux-acpi, linux-kernel

> This is not a mainline kernel problem, surely?

Correct, this warning is just example of possible issue that can be
occurred because of missing "const" qualifier. Actually I saw this
warning in Linaro ACPI kernel (intended for ARMv8 AArch64
architecture).

But I believe that this issue should be fixed in mainline kernel,
because it can cause the same warning in the future.

On 21 April 2014 23:44, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Thursday, April 17, 2014 06:53:26 PM Semen Protsenko wrote:
>> This patch fixes next warning:
>>
>> <------------------------------- cut here --------------------------------->
>> drivers/acpi/property.c: In function ‘acpi_free_properties’:
>> drivers/acpi/property.c:35:2: warning: passing argument 1 of ‘acpi_os_free’
>>                               discards ‘const’ qualifier from pointer
>>                               target type [enabled by default]
>>
>>   ACPI_FREE(adev->properties);
>> <------------------------------- cut here --------------------------------->
>
> This is not a mainline kernel problem, surely?
>
>>
>> The problem is next:
>>
>>  - acpi_free_properties() calls ACPI_FREE(), passing "const *"
>>    parameter to it
>>  - ACPI_FREE() is macro for acpi_os_free()
>>  - acpi_os_free() takes "void *" parameter
>>  - acpi_os_free() calls kfree()
>>  - but kfree() requires "const void *" parameter
>>
>> So acpi_os_free() should require "const void *" parameter as well.
>>
>> Signed-off-by: Semen Protsenko <semen.protsenko@linaro.org>
>> ---
>>  include/acpi/platform/aclinux.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
>> index 93c55ed..c6fa763 100644
>> --- a/include/acpi/platform/aclinux.h
>> +++ b/include/acpi/platform/aclinux.h
>> @@ -174,7 +174,7 @@ static inline void *acpi_os_allocate_zeroed(acpi_size size)
>>  #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
>>  #define USE_NATIVE_ALLOCATE_ZEROED
>>
>> -static inline void acpi_os_free(void *memory)
>> +static inline void acpi_os_free(const void *memory)
>>  {
>>       kfree(memory);
>>  }
>>
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-25 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 15:53 [PATCH] acpi: respect const qualifier Semen Protsenko
2014-04-21 20:44 ` Rafael J. Wysocki
2014-04-25 15:02   ` Sam Protsenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).