[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 5/7] Mute some compiler warnings



On 12/07/13 14:48, Daniel Kiper wrote:
> This patch mutes follwing compiler warnings:
>   - warning: assignment discards âconstâ qualifier from
>     pointer target type [enabled by default],
>   - warning: variable âpage_offsetâ set but not used
>     [-Wunused-but-set-variable].
>
> Signed-off-by: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
> ---
>  dwarf_info.c  |    4 ++--
>  sadump_info.c |    2 --
>  2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/dwarf_info.c b/dwarf_info.c
> index 6e21b8a..86cae69 100644
> --- a/dwarf_info.c
> +++ b/dwarf_info.c
> @@ -1427,7 +1427,7 @@ get_die_member(unsigned long long die_off, int index, 
> long *offset,
>       if (!get_data_member_location(die, offset))
>               *offset = 0;
>  
> -     *name = dwarf_diename(die);
> +     *name = (char *)dwarf_diename(die);

Discarding a const qualifier like this is usually a good sign that you
are misusing name in the first place.

Indeed, name is merely non-const to strdup() and reuse the same variable.

This would be more clearly done using

const char * diename = dwarf_diename(&result) ;

and

name = strdup(diename);

~Andrew

>       /*
>        * Duplicate the string before we pass it to eppic layer. The
>        * original string returned by dwarf layer will become invalid
> @@ -1513,7 +1513,7 @@ get_die_name(unsigned long long die_off)
>               return NULL;
>       }
>  
> -     name = dwarf_diename(&result);
> +     name = (char *)dwarf_diename(&result);
>       if (name)
>               name = strdup(name);
>       clean_dwfl_info();
> diff --git a/sadump_info.c b/sadump_info.c
> index be6cf55..01cf5eb 100644
> --- a/sadump_info.c
> +++ b/sadump_info.c
> @@ -948,7 +948,6 @@ int
>  readpage_sadump(unsigned long long paddr, void *bufptr)
>  {
>       unsigned long long pfn, block, whole_offset, perdisk_offset;
> -     ulong page_offset;
>       int fd_memory;
>  
>       if (si->kdump_backed_up &&
> @@ -957,7 +956,6 @@ readpage_sadump(unsigned long long paddr, void *bufptr)
>               paddr += si->backup_offset - si->backup_src_start;
>  
>       pfn = paddr_to_pfn(paddr);
> -     page_offset = paddr % info->page_size;
>  
>       if (pfn >= si->sh_memory->max_mapnr)
>               return FALSE;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.