[Xen-devel] [PATCH 5/7] Mute some compiler warnings
Andrew Cooper
andrew.cooper3 at citrix.com
Fri Jul 12 10:12:08 EDT 2013
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 at oracle.com>
> ---
> 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;
More information about the kexec
mailing list