This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH -tip 1/2] x86/alternatives: Fix build warning


* Masami Hiramatsu <mhiramat@redhat.com> wrote:

> Fixes below warnings.
> 
> ====
> FYI, there's this new build warning on x86 defconfig:
> 
> arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
> arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
> arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
> arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
> arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
> 
> Caused by:
> 
> 2cfa197: ftrace/alternatives: Introducing *_text_reserved functions
> ====
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> Reported-by: Ingo Molnar <mingo@elte.hu>
> ---
> 
>  arch/x86/kernel/alternative.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 3832fdc..99d9920 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -399,10 +399,10 @@ int alternatives_text_reserved(void *start, void *end)
>  	u8 **ptr;
>  
>  	list_for_each_entry(mod, &smp_alt_modules, next) {
> -		if (mod->text > end || mod->text_end < start)
> +		if (mod->text > (u8 *)end || mod->text_end < (u8 *)start)
>  			continue;
>  		for (ptr = mod->locks; ptr < mod->locks_end; ptr++)
> -			if (start <= *ptr && end >= *ptr)
> +			if ((u8 *)start <= *ptr && (u8 *)end >= *ptr)
>  				return 1;
>  	}

Such casts are a bit ugly and in general type casts are somewhat dangerous.

One possible solution would be to add intermediary local variables 
(text_start/text_end) with u8 * type and assign start/end to them - which can 
be done without a cast.

Thanks,

	Ingo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]