All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] x86: remove cast from void*
@ 2010-09-14  5:18 ` matt mooney
  0 siblings, 0 replies; 12+ messages in thread
From: matt mooney @ 2010-09-14  5:18 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Ian Campbell, matt mooney, x86, kernel-janitors, Chris Wright,
	virtualization, Ingo Molnar, H. Peter Anvin, Tejun Heo,
	Thomas Gleixner, xen-devel

Unnecessary cast from void* in assignment.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 arch/x86/xen/mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 42086ac..7436283 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
 
 	if (offset < pgd_index(USER_LIMIT)) {
 		struct page *page = virt_to_page(pgd_page);
-		user_ptr = (pgd_t *)page->private;
+		user_ptr = page->private;
 		if (user_ptr)
 			user_ptr += offset;
 	}
-- 
1.7.2.1


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

* [PATCH 1/4] x86: remove cast from void*
@ 2010-09-14  5:18 ` matt mooney
  0 siblings, 0 replies; 12+ messages in thread
From: matt mooney @ 2010-09-14  5:18 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Ian Campbell, matt mooney, x86, kernel-janitors, Chris Wright,
	virtualization, Ingo Molnar, H. Peter Anvin, Tejun Heo,
	Thomas Gleixner, xen-devel

Unnecessary cast from void* in assignment.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 arch/x86/xen/mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 42086ac..7436283 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
 
 	if (offset < pgd_index(USER_LIMIT)) {
 		struct page *page = virt_to_page(pgd_page);
-		user_ptr = (pgd_t *)page->private;
+		user_ptr = page->private;
 		if (user_ptr)
 			user_ptr += offset;
 	}
-- 
1.7.2.1

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

* Re: [PATCH 1/4] x86: remove cast from void*
  2010-09-14  5:18 ` matt mooney
@ 2010-09-14 17:49   ` Jeremy Fitzhardinge
  -1 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2010-09-14 17:49 UTC (permalink / raw)
  To: matt mooney
  Cc: xen-devel, Jeremy Fitzhardinge, x86, kernel-janitors,
	Chris Wright, virtualization, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Thomas Gleixner, Ian Campbell

 On 09/13/2010 10:18 PM, matt mooney wrote:
> Unnecessary cast from void* in assignment.

Not very keen on this.  The cast may not be strictly required, but it
does document what's going on there.

    J

> Signed-off-by: matt mooney <mfm@muteddisk.com>
> ---
>  arch/x86/xen/mmu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> index 42086ac..7436283 100644
> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
>  
>  	if (offset < pgd_index(USER_LIMIT)) {
>  		struct page *page = virt_to_page(pgd_page);
> -		user_ptr = (pgd_t *)page->private;
> +		user_ptr = page->private;
>  		if (user_ptr)
>  			user_ptr += offset;
>  	}


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

* Re: [PATCH 1/4] x86: remove cast from void*
@ 2010-09-14 17:49   ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2010-09-14 17:49 UTC (permalink / raw)
  To: matt mooney
  Cc: xen-devel, Jeremy Fitzhardinge, x86, kernel-janitors,
	Chris Wright, virtualization, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Thomas Gleixner, Ian Campbell

 On 09/13/2010 10:18 PM, matt mooney wrote:
> Unnecessary cast from void* in assignment.

Not very keen on this.  The cast may not be strictly required, but it
does document what's going on there.

    J

> Signed-off-by: matt mooney <mfm@muteddisk.com>
> ---
>  arch/x86/xen/mmu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> index 42086ac..7436283 100644
> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
>  
>  	if (offset < pgd_index(USER_LIMIT)) {
>  		struct page *page = virt_to_page(pgd_page);
> -		user_ptr = (pgd_t *)page->private;
> +		user_ptr = page->private;
>  		if (user_ptr)
>  			user_ptr += offset;
>  	}

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

* Re: [PATCH 1/4] x86: remove cast from void*
  2010-09-14 17:49   ` Jeremy Fitzhardinge
@ 2010-09-14 18:20     ` H. Peter Anvin
  -1 siblings, 0 replies; 12+ messages in thread
From: H. Peter Anvin @ 2010-09-14 18:20 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: xen-devel, Jeremy Fitzhardinge, matt mooney, x86,
	kernel-janitors, Chris Wright, virtualization, Ingo Molnar,
	Tejun Heo, Thomas Gleixner, Ian Campbell

On 09/14/2010 10:49 AM, Jeremy Fitzhardinge wrote:
>  On 09/13/2010 10:18 PM, matt mooney wrote:
>> Unnecessary cast from void* in assignment.
> 
> Not very keen on this.  The cast may not be strictly required, but it
> does document what's going on there.
> 

But unnecessary casts are problematic in that if the type changes, they
can hide a real bug in the future.
	
	-hpa

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

* Re: [PATCH 1/4] x86: remove cast from void*
@ 2010-09-14 18:20     ` H. Peter Anvin
  0 siblings, 0 replies; 12+ messages in thread
From: H. Peter Anvin @ 2010-09-14 18:20 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: xen-devel, Jeremy Fitzhardinge, matt mooney, x86,
	kernel-janitors, Chris Wright, virtualization, Ingo Molnar,
	Tejun Heo, Thomas Gleixner, Ian Campbell

On 09/14/2010 10:49 AM, Jeremy Fitzhardinge wrote:
>  On 09/13/2010 10:18 PM, matt mooney wrote:
>> Unnecessary cast from void* in assignment.
> 
> Not very keen on this.  The cast may not be strictly required, but it
> does document what's going on there.
> 

But unnecessary casts are problematic in that if the type changes, they
can hide a real bug in the future.
	
	-hpa

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

* Re: [PATCH 1/4] x86: remove cast from void*
  2010-09-14 18:20     ` H. Peter Anvin
@ 2010-09-14 18:46       ` Jeremy Fitzhardinge
  -1 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2010-09-14 18:46 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: xen-devel, Jeremy Fitzhardinge, matt mooney, x86,
	kernel-janitors, Chris Wright, virtualization, Ingo Molnar,
	Tejun Heo, Thomas Gleixner, Ian Campbell

 On 09/14/2010 11:20 AM, H. Peter Anvin wrote:
> On 09/14/2010 10:49 AM, Jeremy Fitzhardinge wrote:
>>  On 09/13/2010 10:18 PM, matt mooney wrote:
>>> Unnecessary cast from void* in assignment.
>> Not very keen on this.  The cast may not be strictly required, but it
>> does document what's going on there.
>>
> But unnecessary casts are problematic in that if the type changes, they
> can hide a real bug in the future.

If page->private changes in a way which invalidates this kind of usage,
I would hope it would also change name to something more descriptive of
its new role.  If it changes type but is broadly compatible with this
usage (say, void * -> unsigned long), then the cast won't matter, or
will become a requirement.

I'm more concerned about "user_ptr" changing type, in which case the
cast will highlight the problem.

In general, the casts from these kinds of generic/polymorphic fields let
you easily eyeball how they're being used, without having to work out
what the type of the other side is.

    J

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

* Re: [PATCH 1/4] x86: remove cast from void*
@ 2010-09-14 18:46       ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2010-09-14 18:46 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: xen-devel, Jeremy Fitzhardinge, matt mooney, x86,
	kernel-janitors, Chris Wright, virtualization, Ingo Molnar,
	Tejun Heo, Thomas Gleixner, Ian Campbell

 On 09/14/2010 11:20 AM, H. Peter Anvin wrote:
> On 09/14/2010 10:49 AM, Jeremy Fitzhardinge wrote:
>>  On 09/13/2010 10:18 PM, matt mooney wrote:
>>> Unnecessary cast from void* in assignment.
>> Not very keen on this.  The cast may not be strictly required, but it
>> does document what's going on there.
>>
> But unnecessary casts are problematic in that if the type changes, they
> can hide a real bug in the future.

If page->private changes in a way which invalidates this kind of usage,
I would hope it would also change name to something more descriptive of
its new role.  If it changes type but is broadly compatible with this
usage (say, void * -> unsigned long), then the cast won't matter, or
will become a requirement.

I'm more concerned about "user_ptr" changing type, in which case the
cast will highlight the problem.

In general, the casts from these kinds of generic/polymorphic fields let
you easily eyeball how they're being used, without having to work out
what the type of the other side is.

    J

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

* Re: [PATCH 1/4] x86: remove cast from void*
  2010-09-14  5:18 ` matt mooney
@ 2010-09-21 18:39   ` Jeremy Fitzhardinge
  -1 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2010-09-21 18:39 UTC (permalink / raw)
  To: matt mooney
  Cc: xen-devel, Jeremy Fitzhardinge, x86, kernel-janitors,
	Chris Wright, virtualization, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Thomas Gleixner, Ian Campbell

 On 09/13/2010 10:18 PM, matt mooney wrote:
> Unnecessary cast from void* in assignment.
>
> Signed-off-by: matt mooney <mfm@muteddisk.com>
> ---
>  arch/x86/xen/mmu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> index 42086ac..7436283 100644
> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
>  
>  	if (offset < pgd_index(USER_LIMIT)) {
>  		struct page *page = virt_to_page(pgd_page);
> -		user_ptr = (pgd_t *)page->private;
> +		user_ptr = page->private;

Um, page->private is unsigned long anyway, so this is needed either way.

    J


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

* Re: [PATCH 1/4] x86: remove cast from void*
@ 2010-09-21 18:39   ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2010-09-21 18:39 UTC (permalink / raw)
  To: matt mooney
  Cc: xen-devel, Jeremy Fitzhardinge, x86, kernel-janitors,
	Chris Wright, virtualization, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Thomas Gleixner, Ian Campbell

 On 09/13/2010 10:18 PM, matt mooney wrote:
> Unnecessary cast from void* in assignment.
>
> Signed-off-by: matt mooney <mfm@muteddisk.com>
> ---
>  arch/x86/xen/mmu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> index 42086ac..7436283 100644
> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
>  
>  	if (offset < pgd_index(USER_LIMIT)) {
>  		struct page *page = virt_to_page(pgd_page);
> -		user_ptr = (pgd_t *)page->private;
> +		user_ptr = page->private;

Um, page->private is unsigned long anyway, so this is needed either way.

    J

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

* Re: [PATCH 1/4] x86: remove cast from void*
  2010-09-21 18:39   ` Jeremy Fitzhardinge
@ 2010-09-21 19:15     ` matt mooney
  -1 siblings, 0 replies; 12+ messages in thread
From: matt mooney @ 2010-09-21 19:15 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: xen-devel, x86, kernel-janitors, Chris Wright, virtualization,
	Ingo Molnar, H. Peter Anvin, Tejun Heo, Thomas Gleixner,
	Ian Campbell

On 11:39 Tue 21 Sep     , Jeremy Fitzhardinge wrote:
>  On 09/13/2010 10:18 PM, matt mooney wrote:
> > Unnecessary cast from void* in assignment.
> >
> > Signed-off-by: matt mooney <mfm@muteddisk.com>
> > ---
> >  arch/x86/xen/mmu.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> > index 42086ac..7436283 100644
> > --- a/arch/x86/xen/mmu.c
> > +++ b/arch/x86/xen/mmu.c
> > @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
> >  
> >  	if (offset < pgd_index(USER_LIMIT)) {
> >  		struct page *page = virt_to_page(pgd_page);
> > -		user_ptr = (pgd_t *)page->private;
> > +		user_ptr = page->private;
> 
> Um, page->private is unsigned long anyway, so this is needed either way.
> 

You're right. I missed that one, sorry; I really thought I had verified it.

-mfm

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

* Re: [PATCH 1/4] x86: remove cast from void*
@ 2010-09-21 19:15     ` matt mooney
  0 siblings, 0 replies; 12+ messages in thread
From: matt mooney @ 2010-09-21 19:15 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: xen-devel, x86, kernel-janitors, Chris Wright, virtualization,
	Ingo Molnar, H. Peter Anvin, Tejun Heo, Thomas Gleixner,
	Ian Campbell

On 11:39 Tue 21 Sep     , Jeremy Fitzhardinge wrote:
>  On 09/13/2010 10:18 PM, matt mooney wrote:
> > Unnecessary cast from void* in assignment.
> >
> > Signed-off-by: matt mooney <mfm@muteddisk.com>
> > ---
> >  arch/x86/xen/mmu.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> > index 42086ac..7436283 100644
> > --- a/arch/x86/xen/mmu.c
> > +++ b/arch/x86/xen/mmu.c
> > @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
> >  
> >  	if (offset < pgd_index(USER_LIMIT)) {
> >  		struct page *page = virt_to_page(pgd_page);
> > -		user_ptr = (pgd_t *)page->private;
> > +		user_ptr = page->private;
> 
> Um, page->private is unsigned long anyway, so this is needed either way.
> 

You're right. I missed that one, sorry; I really thought I had verified it.

-mfm

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

end of thread, other threads:[~2010-09-21 19:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14  5:18 [PATCH 1/4] x86: remove cast from void* matt mooney
2010-09-14  5:18 ` matt mooney
2010-09-14 17:49 ` Jeremy Fitzhardinge
2010-09-14 17:49   ` Jeremy Fitzhardinge
2010-09-14 18:20   ` H. Peter Anvin
2010-09-14 18:20     ` H. Peter Anvin
2010-09-14 18:46     ` Jeremy Fitzhardinge
2010-09-14 18:46       ` Jeremy Fitzhardinge
2010-09-21 18:39 ` Jeremy Fitzhardinge
2010-09-21 18:39   ` Jeremy Fitzhardinge
2010-09-21 19:15   ` matt mooney
2010-09-21 19:15     ` matt mooney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.