linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] um: Cleanup compiler warning in arch/x86/um/tls_32.c
@ 2022-08-26 15:29 Lukas Straub
  2022-08-26 20:36 ` Randy Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Straub @ 2022-08-26 15:29 UTC (permalink / raw)
  To: linux-um
  Cc: Randy Dunlap, Richard Weinberger, Anton Ivanov, Johannes Berg,
	x86, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2307 bytes --]

arch.tls_array is statically allocated so checking for NULL doesn't
make sense. This causes the compiler warning below.

Remove the checks to silence these warnings.

../arch/x86/um/tls_32.c: In function 'get_free_idx':
../arch/x86/um/tls_32.c:68:13: warning: the comparison will always evaluate as 'true' for the address of 'tls_array' will never be NULL [-Waddress]
   68 |         if (!t->arch.tls_array)
      |             ^
In file included from ../arch/x86/um/asm/processor.h:10,
                 from ../include/linux/rcupdate.h:30,
                 from ../include/linux/rculist.h:11,
                 from ../include/linux/pid.h:5,
                 from ../include/linux/sched.h:14,
                 from ../arch/x86/um/tls_32.c:7:
../arch/x86/um/asm/processor_32.h:22:31: note: 'tls_array' declared here
   22 |         struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
      |                               ^~~~~~~~~
../arch/x86/um/tls_32.c: In function 'get_tls_entry':
../arch/x86/um/tls_32.c:243:13: warning: the comparison will always evaluate as 'true' for the address of 'tls_array' will never be NULL [-Waddress]
  243 |         if (!t->arch.tls_array)
      |             ^
../arch/x86/um/asm/processor_32.h:22:31: note: 'tls_array' declared here
   22 |         struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
      |                               ^~~~~~~~~

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 arch/x86/um/tls_32.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
index ac8eee093f9c..66162eafd8e8 100644
--- a/arch/x86/um/tls_32.c
+++ b/arch/x86/um/tls_32.c
@@ -65,9 +65,6 @@ static int get_free_idx(struct task_struct* task)
 	struct thread_struct *t = &task->thread;
 	int idx;
 
-	if (!t->arch.tls_array)
-		return GDT_ENTRY_TLS_MIN;
-
 	for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++)
 		if (!t->arch.tls_array[idx].present)
 			return idx + GDT_ENTRY_TLS_MIN;
@@ -240,9 +237,6 @@ static int get_tls_entry(struct task_struct *task, struct user_desc *info,
 {
 	struct thread_struct *t = &task->thread;
 
-	if (!t->arch.tls_array)
-		goto clear;
-
 	if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
 		return -EINVAL;
 
-- 
2.37.2

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH 2/2] um: Cleanup compiler warning in arch/x86/um/tls_32.c
  2022-08-26 15:29 [PATCH 2/2] um: Cleanup compiler warning in arch/x86/um/tls_32.c Lukas Straub
@ 2022-08-26 20:36 ` Randy Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2022-08-26 20:36 UTC (permalink / raw)
  To: Lukas Straub, linux-um
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, x86,
	linux-kernel



On 8/26/22 08:29, Lukas Straub wrote:
> arch.tls_array is statically allocated so checking for NULL doesn't
> make sense. This causes the compiler warning below.
> 
> Remove the checks to silence these warnings.
> 
> ../arch/x86/um/tls_32.c: In function 'get_free_idx':
> ../arch/x86/um/tls_32.c:68:13: warning: the comparison will always evaluate as 'true' for the address of 'tls_array' will never be NULL [-Waddress]
>    68 |         if (!t->arch.tls_array)
>       |             ^
> In file included from ../arch/x86/um/asm/processor.h:10,
>                  from ../include/linux/rcupdate.h:30,
>                  from ../include/linux/rculist.h:11,
>                  from ../include/linux/pid.h:5,
>                  from ../include/linux/sched.h:14,
>                  from ../arch/x86/um/tls_32.c:7:
> ../arch/x86/um/asm/processor_32.h:22:31: note: 'tls_array' declared here
>    22 |         struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
>       |                               ^~~~~~~~~
> ../arch/x86/um/tls_32.c: In function 'get_tls_entry':
> ../arch/x86/um/tls_32.c:243:13: warning: the comparison will always evaluate as 'true' for the address of 'tls_array' will never be NULL [-Waddress]
>   243 |         if (!t->arch.tls_array)
>       |             ^
> ../arch/x86/um/asm/processor_32.h:22:31: note: 'tls_array' declared here
>    22 |         struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
>       |                               ^~~~~~~~~
> 
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>  arch/x86/um/tls_32.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
> index ac8eee093f9c..66162eafd8e8 100644
> --- a/arch/x86/um/tls_32.c
> +++ b/arch/x86/um/tls_32.c
> @@ -65,9 +65,6 @@ static int get_free_idx(struct task_struct* task)
>  	struct thread_struct *t = &task->thread;
>  	int idx;
>  
> -	if (!t->arch.tls_array)
> -		return GDT_ENTRY_TLS_MIN;
> -
>  	for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++)
>  		if (!t->arch.tls_array[idx].present)
>  			return idx + GDT_ENTRY_TLS_MIN;
> @@ -240,9 +237,6 @@ static int get_tls_entry(struct task_struct *task, struct user_desc *info,
>  {
>  	struct thread_struct *t = &task->thread;
>  
> -	if (!t->arch.tls_array)
> -		goto clear;
> -
>  	if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
>  		return -EINVAL;
>  

-- 
~Randy

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

end of thread, other threads:[~2022-08-26 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-26 15:29 [PATCH 2/2] um: Cleanup compiler warning in arch/x86/um/tls_32.c Lukas Straub
2022-08-26 20:36 ` Randy Dunlap

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).