Improve consistency of type-attribute usage (volatile/const).

From: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
kfraser@localhost.localdomain committed 2006-12-21 13:58:51 +00:00
1 parent 015f6a2832
commit f9396bbfe8
26 files changed
+166 -143

No files matched your search

+1 -1
View File
@@ -1079,7 +1079,7 @@ static int setup_guest(int xc_handle,
static int xc_linux_build_internal(int xc_handle,
uint32_t domid,
unsigned int mem_mb,
char *image,
const char *image,
unsigned long image_size,
struct initrd_info *initrd,
const char *cmdline,
+5 -5
View File
@@ -80,7 +80,7 @@ static xen_pfn_t *live_m2p = NULL;
#define BITMAP_SIZE ((max_pfn + BITS_PER_LONG - 1) / 8)
#define BITMAP_ENTRY(_nr,_bmap) \
((unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]
((volatile unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]
#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
@@ -112,7 +112,7 @@ static inline unsigned int hweight32(unsigned int w)
static inline int count_bits ( int nr, volatile void *addr)
{
int i, count = 0;
unsigned long *p = (unsigned long *)addr;
volatile unsigned long *p = (volatile unsigned long *)addr;
/* We know that the array is padded to unsigned long. */
for( i = 0; i < (nr / (sizeof(unsigned long)*8)); i++, p++ )
count += hweight32(*p);
@@ -443,7 +443,7 @@ static int canonicalize_pagetable(unsigned long type, unsigned long pfn,
/* XXX index of the L2 entry in PAE mode which holds the guest LPT */
#define PAE_GLPT_L2ENTRY (495)
pte = ((uint64_t*)spage)[PAE_GLPT_L2ENTRY];
pte = ((const uint64_t*)spage)[PAE_GLPT_L2ENTRY];
if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn])
xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
@@ -464,9 +464,9 @@ static int canonicalize_pagetable(unsigned long type, unsigned long pfn,
unsigned long pfn, mfn;
if (pt_levels == 2)
pte = ((uint32_t*)spage)[i];
pte = ((const uint32_t*)spage)[i];
else
pte = ((uint64_t*)spage)[i];
pte = ((const uint64_t*)spage)[i];
if (i >= xen_start && i < xen_end)
pte = 0;
+13 -13
View File
@@ -98,7 +98,7 @@ struct xen_bin_image_table
#define FLAGS_MASK ((~ 0) & (~ XEN_REACTOS_FLAG_ALIGN4K))
#define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID
static struct xen_bin_image_table *
static const struct xen_bin_image_table *
findtable(const char *image, unsigned long image_size);
static int
parsebinimage(
@@ -122,11 +122,11 @@ int probe_bin(const char *image,
return 0;
}
static struct xen_bin_image_table *
static const struct xen_bin_image_table *
findtable(const char *image, unsigned long image_size)
{
struct xen_bin_image_table *table;
unsigned long *probe_ptr;
const struct xen_bin_image_table *table;
const unsigned long *probe_ptr;
unsigned probe_index;
unsigned probe_count;
@@ -142,13 +142,13 @@ findtable(const char *image, unsigned long image_size)
sizeof(unsigned long);
/* Search for the magic header */
probe_ptr = (unsigned long *) image;
probe_ptr = (const unsigned long *) image;
table = NULL;
for ( probe_index = 0; probe_index < probe_count; probe_index++ )
{
if ( XEN_REACTOS_MAGIC3 == *probe_ptr )
{
table = (struct xen_bin_image_table *) probe_ptr;
table = (const struct xen_bin_image_table *) probe_ptr;
/* Checksum correct? */
if ( 0 == table->magic + table->flags + table->checksum )
{
@@ -165,7 +165,7 @@ static int parsebinimage(const char *image,
unsigned long image_size,
struct domain_setup_info *dsi)
{
struct xen_bin_image_table *image_info;
const struct xen_bin_image_table *image_info;
unsigned long start_addr;
unsigned long end_addr;
@@ -186,13 +186,13 @@ static int parsebinimage(const char *image,
/* Sanity check on the addresses */
if ( image_info->header_addr < image_info->load_addr ||
((char *) image_info - image) <
((const char *) image_info - image) <
(image_info->header_addr - image_info->load_addr) )
{
ERROR("Invalid header_addr.");
return -EINVAL;
}
start_addr = image_info->header_addr - ((char *) image_info - image);
start_addr = image_info->header_addr - ((const char *) image_info - image);
if ( 0 != image_info->load_end_addr &&
( image_info->load_end_addr < image_info->load_end_addr ||
start_addr + image_size < image_info->load_end_addr ) )
@@ -221,7 +221,7 @@ static int parsebinimage(const char *image,
else
{
dsi->v_end = image_info->load_addr + image_size -
(((char *) image_info - image) -
(((const char *) image_info - image) -
(image_info->header_addr - image_info->load_addr));
}
dsi->v_kernstart = dsi->v_start;
@@ -240,7 +240,7 @@ loadbinimage(
unsigned long size;
char *va;
unsigned long done, chunksz;
struct xen_bin_image_table *image_info;
const struct xen_bin_image_table *image_info;
image_info = findtable(image, image_size);
if ( NULL == image_info )
@@ -252,7 +252,7 @@ loadbinimage(
/* Determine image size */
if ( 0 == image_info->load_end_addr )
{
size = image_size - (((char *) image_info - image) -
size = image_size - (((const char *)image_info - image) -
(image_info->header_addr -
image_info->load_addr));
}
@@ -262,7 +262,7 @@ loadbinimage(
}
/* It's possible that we need to skip the first part of the image */
image += ((char *)image_info - image) -
image += ((const char *)image_info - image) -
(image_info->header_addr - image_info->load_addr);
for ( done = 0; done < size; done += chunksz )
+47 -38
View File
@@ -75,7 +75,7 @@ int probe_elf(const char *image,
unsigned long image_size,
struct load_funcs *load_funcs)
{
Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
if ( !IS_ELF(*ehdr) )
return -EINVAL;
@@ -86,7 +86,7 @@ int probe_elf(const char *image,
return 0;
}
static inline int is_loadable_phdr(Elf_Phdr *phdr)
static inline int is_loadable_phdr(const Elf_Phdr *phdr)
{
return ((phdr->p_type == PT_LOAD) &&
((phdr->p_flags & (PF_W|PF_X)) != 0));
@@ -96,12 +96,13 @@ static inline int is_loadable_phdr(Elf_Phdr *phdr)
* Fallback for kernels containing only the legacy __xen_guest string
* and no ELF notes.
*/
static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab)
static int is_xen_guest_section(const Elf_Shdr *shdr, const char *shstrtab)
{
return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0;
}
static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type)
static const char *xen_guest_lookup(
const struct domain_setup_info *dsi, int type)
{
const char *xenguest_fallbacks[] = {
[XEN_ELFNOTE_ENTRY] = "VIRT_ENTRY=",
@@ -134,7 +135,8 @@ static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type)
return p + strlen(fallback);
}
static const char *xen_guest_string(struct domain_setup_info *dsi, int type)
static const char *xen_guest_string(
const struct domain_setup_info *dsi, int type)
{
const char *p = xen_guest_lookup(dsi, type);
@@ -148,8 +150,8 @@ static const char *xen_guest_string(struct domain_setup_info *dsi, int type)
return p;
}
static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
int type, int *defined)
static unsigned long long xen_guest_numeric(
const struct domain_setup_info *dsi, int type, int *defined)
{
const char *p = xen_guest_lookup(dsi, type);
unsigned long long value;
@@ -175,19 +177,19 @@ static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
/*
* Interface to the Xen ELF notes.
*/
#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_)))
#define ELFNOTE_NAME(_n_) ((const void*)(_n_) + sizeof(*(_n_)))
#define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
#define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr)
{
Elf_Note *note;
const Elf_Note *note;
if ( shdr->sh_type != SHT_NOTE )
return 0;
for ( note = (Elf_Note *)(image + shdr->sh_offset);
note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
for ( note = (const Elf_Note *)(image + shdr->sh_offset);
note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
note = ELFNOTE_NEXT(note) )
{
if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) )
@@ -197,15 +199,16 @@ static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
return 0;
}
static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
static const Elf_Note *xen_elfnote_lookup(
const struct domain_setup_info *dsi, int type)
{
Elf_Note *note;
const Elf_Note *note;
if ( !dsi->__elfnote_section )
return NULL;
for ( note = (Elf_Note *)dsi->__elfnote_section;
note < (Elf_Note *)dsi->__elfnote_section_end;
for ( note = (const Elf_Note *)dsi->__elfnote_section;
note < (const Elf_Note *)dsi->__elfnote_section_end;
note = ELFNOTE_NEXT(note) )
{
if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) )
@@ -218,9 +221,9 @@ static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
return NULL;
}
const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
const char *xen_elfnote_string(const struct domain_setup_info *dsi, int type)
{
Elf_Note *note;
const Elf_Note *note;
if ( !dsi->__elfnote_section )
return xen_guest_string(dsi, type);
@@ -232,10 +235,10 @@ const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
return (const char *)ELFNOTE_DESC(note);
}
unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi,
int type, int *defined)
{
Elf_Note *note;
const Elf_Note *note;
*defined = 0;
@@ -252,10 +255,10 @@ unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
{
case 4:
*defined = 1;
return *(uint32_t*)ELFNOTE_DESC(note);
return *(const uint32_t*)ELFNOTE_DESC(note);
case 8:
*defined = 1;
return *(uint64_t*)ELFNOTE_DESC(note);
return *(const uint64_t*)ELFNOTE_DESC(note);
default:
xc_set_error(XC_INVALID_KERNEL,
"elfnotes: unknown data size %#x for numeric type note %#x\n",
@@ -268,9 +271,9 @@ static int parseelfimage(const char *image,
unsigned long image_len,
struct domain_setup_info *dsi)
{
Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
Elf_Phdr *phdr;
Elf_Shdr *shdr;
const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
const Elf_Phdr *phdr;
const Elf_Shdr *shdr;
Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry;
const char *shstrtab, *p;
int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined;
@@ -331,12 +334,13 @@ static int parseelfimage(const char *image,
/* Look for .notes segment containing at least one Xen note */
for ( h = 0; h < ehdr->e_shnum; h++ )
{
shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
shdr = (const Elf_Shdr *)(
image + ehdr->e_shoff + (h*ehdr->e_shentsize));
if ( !is_xen_elfnote_section(image, shdr) )
continue;
dsi->__elfnote_section = (void *)image + shdr->sh_offset;
dsi->__elfnote_section = (const void *)image + shdr->sh_offset;
dsi->__elfnote_section_end =
(void *)image + shdr->sh_offset + shdr->sh_size;
(const void *)image + shdr->sh_offset + shdr->sh_size;
break;
}
@@ -350,16 +354,18 @@ static int parseelfimage(const char *image,
"ELF image has no section-header strings table.");
return -EINVAL;
}
shdr = (Elf_Shdr *)(image + ehdr->e_shoff +
shdr = (const Elf_Shdr *)(image + ehdr->e_shoff +
(ehdr->e_shstrndx*ehdr->e_shentsize));
shstrtab = image + shdr->sh_offset;
for ( h = 0; h < ehdr->e_shnum; h++ )
{
shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
shdr = (const Elf_Shdr *)(
image + ehdr->e_shoff + (h*ehdr->e_shentsize));
if ( is_xen_guest_section(shdr, shstrtab) )
{
dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
dsi->__xen_guest_string =
(const char *)image + shdr->sh_offset;
break;
}
}
@@ -442,8 +448,8 @@ static int parseelfimage(const char *image,
* If we are using the modern ELF notes interface then the default
* is 0.
*/
dsi->elf_paddr_offset =
xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET, &elf_pa_off_defined);
dsi->elf_paddr_offset = xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET,
&elf_pa_off_defined);
if ( !elf_pa_off_defined )
{
if ( dsi->__elfnote_section )
@@ -462,7 +468,8 @@ static int parseelfimage(const char *image,
for ( h = 0; h < ehdr->e_phnum; h++ )
{
phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
phdr = (const Elf_Phdr *)(
image + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
continue;
vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
@@ -514,8 +521,8 @@ loadelfimage(
const char *image, unsigned long elfsize, int xch, uint32_t dom,
xen_pfn_t *parray, struct domain_setup_info *dsi)
{
Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
Elf_Phdr *phdr;
const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
const Elf_Phdr *phdr;
int h;
char *va;
@@ -523,7 +530,8 @@ loadelfimage(
for ( h = 0; h < ehdr->e_phnum; h++ )
{
phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
phdr = (const Elf_Phdr *)(
image + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
continue;
@@ -569,7 +577,8 @@ loadelfsymtab(
const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
struct domain_setup_info *dsi)
{
Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr;
const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
Elf_Ehdr *sym_ehdr;
Elf_Shdr *shdr;
unsigned long maxva, symva;
char *p;
+3 -3
View File
@@ -146,7 +146,7 @@ struct domain_setup_info
* You should use the xen_elfnote_* accessors below in order to
* pickup the correct one and retain backwards compatibility.
*/
void *__elfnote_section, *__elfnote_section_end;
const void *__elfnote_section, *__elfnote_section_end;
const char *__xen_guest_string;
};
@@ -162,14 +162,14 @@ typedef int (*loadimagefunc)(const char *image, unsigned long image_size,
* in the note is returned and *defined is set to non-zero. If no such
* note is found then *defined is set to 0 and 0 is returned.
*/
extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
extern unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi,
int type, int *defined);
/*
* If an ELF note of the given type is found then the string contained
* in the value is returned, otherwise NULL is returned.
*/
extern const char * xen_elfnote_string(struct domain_setup_info *dsi,
extern const char * xen_elfnote_string(const struct domain_setup_info *dsi,
int type);
struct load_funcs
+2 -2
View File
@@ -269,7 +269,7 @@ static void print(const char *fmt, ...)
if (!batch) {
if((current_row() < lines()-1)) {
va_start(args, fmt);
vwprintw(stdscr, (char *)fmt, args);
vwprintw(stdscr, (const char *)fmt, args);
va_end(args);
}
} else {
@@ -283,7 +283,7 @@ static void print(const char *fmt, ...)
static void attr_addstr(int attr, const char *str)
{
attron(attr);
addstr((char *)str);
addstr((const char *)str);
attroff(attr);
}
+1 -1
View File
@@ -12,7 +12,7 @@
#define LIST_POISON2 ((void *) 0x00200200)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
/*
+5 -4
View File
@@ -55,12 +55,12 @@ static long dom0_nrpages, dom0_min_nrpages, dom0_max_nrpages = LONG_MAX;
* If +ve: The specified amount is an absolute value.
* If -ve: The specified amount is subtracted from total available memory.
*/
static long parse_amt(char *s, char **ps)
static long parse_amt(const char *s, const char **ps)
{
long pages = parse_size_and_unit((*s == '-') ? s+1 : s, ps) >> PAGE_SHIFT;
return (*s == '-') ? -pages : pages;
}
static void parse_dom0_mem(char *s)
static void parse_dom0_mem(const char *s)
{
do {
if ( !strncmp(s, "min:", 4) )
@@ -152,7 +152,8 @@ static unsigned long compute_dom0_nr_pages(void)
static void process_dom0_ioports_disable(void)
{
unsigned long io_from, io_to;
char *t, *u, *s = opt_dom0_ioports_disable;
char *t, *s = opt_dom0_ioports_disable;
const char *u;
if ( *s == '\0' )
return;
@@ -892,7 +893,7 @@ int construct_dom0(struct domain *d,
return 0;
}
int elf_sanity_check(Elf_Ehdr *ehdr)
int elf_sanity_check(const Elf_Ehdr *ehdr)
{
if ( !IS_ELF(*ehdr) ||
#if defined(__i386__)
+2 -2
View File
@@ -41,7 +41,7 @@ boolean_param("hpet_force", opt_hpet_force);
unsigned long cpu_khz; /* CPU clock frequency in kHz. */
unsigned long hpet_address;
DEFINE_SPINLOCK(rtc_lock);
unsigned long volatile jiffies;
volatile unsigned long jiffies;
static u32 wc_sec, wc_nsec; /* UTC time at last 'time update'. */
static DEFINE_SPINLOCK(wc_lock);
@@ -148,7 +148,7 @@ void timer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
ASSERT(local_irq_is_enabled());
/* Update jiffies counter. */
(*(unsigned long *)&jiffies)++;
(*(volatile unsigned long *)&jiffies)++;
/* Rough hack to allow accurate timers to sort-of-work with no APIC. */
if ( !cpu_has_apic )
+32 -27
View File
@@ -16,7 +16,7 @@
#include <public/elfnote.h>
static void loadelfsymtab(struct domain_setup_info *dsi, int doload);
static inline int is_loadable_phdr(Elf_Phdr *phdr)
static inline int is_loadable_phdr(const Elf_Phdr *phdr)
{
return ((phdr->p_type == PT_LOAD) &&
((phdr->p_flags & (PF_W|PF_X)) != 0));
@@ -26,7 +26,7 @@ static inline int is_loadable_phdr(Elf_Phdr *phdr)
* Fallback for kernels containing only the legacy __xen_guest string
* and no ELF notes.
*/
static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab)
static int is_xen_guest_section(const Elf_Shdr *shdr, const char *shstrtab)
{
return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0;
}
@@ -102,19 +102,19 @@ static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
/*
* Interface to the Xen ELF notes.
*/
#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_)))
#define ELFNOTE_NAME(_n_) ((const void*)(_n_) + sizeof(*(_n_)))
#define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
#define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr)
{
Elf_Note *note;
const Elf_Note *note;
if ( shdr->sh_type != SHT_NOTE )
return 0;
for ( note = (Elf_Note *)(image + shdr->sh_offset);
note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
for ( note = (const Elf_Note *)(image + shdr->sh_offset);
note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
note = ELFNOTE_NEXT(note) )
{
if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) )
@@ -124,15 +124,16 @@ static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
return 0;
}
static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
static const Elf_Note *xen_elfnote_lookup(
struct domain_setup_info *dsi, int type)
{
Elf_Note *note;
const Elf_Note *note;
if ( !dsi->__elfnote_section )
return NULL;
for ( note = (Elf_Note *)dsi->__elfnote_section;
note < (Elf_Note *)dsi->__elfnote_section_end;
for ( note = (const Elf_Note *)dsi->__elfnote_section;
note < (const Elf_Note *)dsi->__elfnote_section_end;
note = ELFNOTE_NEXT(note) )
{
if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) )
@@ -147,7 +148,7 @@ static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
{
Elf_Note *note;
const Elf_Note *note;
if ( !dsi->__elfnote_section )
return xen_guest_string(dsi, type);
@@ -162,7 +163,7 @@ const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
int type, int *defined)
{
Elf_Note *note;
const Elf_Note *note;
*defined = 0;
@@ -179,10 +180,10 @@ unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
{
case 4:
*defined = 1;
return *(uint32_t*)ELFNOTE_DESC(note);
return *(const uint32_t*)ELFNOTE_DESC(note);
case 8:
*defined = 1;
return *(uint64_t*)ELFNOTE_DESC(note);
return *(const uint64_t*)ELFNOTE_DESC(note);
default:
printk("ERROR: unknown data size %#x for numeric type note %#x\n",
note->descsz, type);
@@ -192,9 +193,9 @@ unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
int parseelfimage(struct domain_setup_info *dsi)
{
Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
Elf_Phdr *phdr;
Elf_Shdr *shdr;
const Elf_Ehdr *ehdr = (const Elf_Ehdr *)dsi->image_addr;
const Elf_Phdr *phdr;
const Elf_Shdr *shdr;
Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry;
const char *shstrtab, *p;
const char *image = (char *)dsi->image_addr;
@@ -222,12 +223,13 @@ int parseelfimage(struct domain_setup_info *dsi)
/* Look for .notes segment containing at least one Xen note */
for ( h = 0; h < ehdr->e_shnum; h++ )
{
shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
shdr = (const Elf_Shdr *)(
image + ehdr->e_shoff + (h*ehdr->e_shentsize));
if ( !is_xen_elfnote_section(image, shdr) )
continue;
dsi->__elfnote_section = (void *)image + shdr->sh_offset;
dsi->__elfnote_section = (const void *)image + shdr->sh_offset;
dsi->__elfnote_section_end =
(void *)image + shdr->sh_offset + shdr->sh_size;
(const void *)image + shdr->sh_offset + shdr->sh_size;
break;
}
@@ -240,16 +242,18 @@ int parseelfimage(struct domain_setup_info *dsi)
printk("ELF image has no section-header strings table.\n");
return -EINVAL;
}
shdr = (Elf_Shdr *)(image + ehdr->e_shoff +
shdr = (const Elf_Shdr *)(image + ehdr->e_shoff +
(ehdr->e_shstrndx*ehdr->e_shentsize));
shstrtab = image + shdr->sh_offset;
for ( h = 0; h < ehdr->e_shnum; h++ )
{
shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
shdr = (const Elf_Shdr *)(
image + ehdr->e_shoff + (h*ehdr->e_shentsize));
if ( is_xen_guest_section(shdr, shstrtab) )
{
dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
dsi->__xen_guest_string =
(const char *)image + shdr->sh_offset;
break;
}
}
@@ -327,8 +331,8 @@ int parseelfimage(struct domain_setup_info *dsi)
* If we are using the modern ELF notes interface then the default
* is 0.
*/
dsi->elf_paddr_offset =
xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET, &elf_pa_off_defined);
dsi->elf_paddr_offset = xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET,
&elf_pa_off_defined);
if ( !elf_pa_off_defined )
{
if ( dsi->__elfnote_section )
@@ -346,7 +350,8 @@ int parseelfimage(struct domain_setup_info *dsi)
for ( h = 0; h < ehdr->e_phnum; h++ )
{
phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
phdr = (const Elf_Phdr *)(
image + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
continue;
vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
+4 -3
View File
@@ -20,7 +20,8 @@ int tainted;
void cmdline_parse(char *cmdline)
{
char opt[100], *optval, *p = cmdline, *q;
char opt[100], *optval, *q;
const char *p = cmdline;
struct kernel_param *param;
if ( p == NULL )
@@ -70,13 +71,13 @@ void cmdline_parse(char *cmdline)
break;
case OPT_UINT:
*(unsigned int *)param->var =
simple_strtol(optval, (char **)&optval, 0);
simple_strtol(optval, (const char **)&optval, 0);
break;
case OPT_BOOL:
*(int *)param->var = 1;
break;
case OPT_CUSTOM:
((void (*)(char *))param->var)(optval);
((void (*)(const char *))param->var)(optval);
break;
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ spinlock_t kexec_lock = SPIN_LOCK_UNLOCKED;
xen_kexec_reserve_t kexec_crash_area;
static void __init parse_crashkernel(char *str)
static void __init parse_crashkernel(const char *str)
{
unsigned long start, size;
+7 -4
View File
@@ -439,11 +439,14 @@ s64 __moddi3(s64 a, s64 b)
#endif /* BITS_PER_LONG == 32 */
unsigned long long parse_size_and_unit(const char *s, char **ps)
unsigned long long parse_size_and_unit(const char *s, const char **ps)
{
unsigned long long ret = simple_strtoull(s, (char **)&s, 0);
unsigned long long ret;
const char *s1;
switch (*s) {
ret = simple_strtoull(s, &s1, 0);
switch (*s1) {
case 'G': case 'g':
ret <<= 10;
case 'M': case 'm':
@@ -459,7 +462,7 @@ unsigned long long parse_size_and_unit(const char *s, char **ps)
}
if (ps != NULL)
*ps = (char *)s;
*ps = s1;
return ret;
}
+1 -1
View File
@@ -197,7 +197,7 @@ paddr_t init_boot_allocator(paddr_t bitmap_start)
void init_boot_pages(paddr_t ps, paddr_t pe)
{
unsigned long bad_spfn, bad_epfn, i;
char *p;
const char *p;
ps = round_pgup(ps);
pe = round_pgdown(pe);
+2 -2
View File
@@ -40,7 +40,7 @@ struct tm gmtime(unsigned long t)
struct tm tbuf;
long days, rem;
int y;
unsigned short int *ip;
const unsigned short int *ip;
days = t / SECS_PER_DAY;
rem = t % SECS_PER_DAY;
@@ -66,7 +66,7 @@ struct tm gmtime(unsigned long t)
}
tbuf.tm_year = y - 1900;
tbuf.tm_yday = days;
ip = (unsigned short int *)__mon_lengths[__isleap(y)];
ip = (const unsigned short int *)__mon_lengths[__isleap(y)];
for ( y = 0; days >= ip[y]; ++y )
days -= ip[y];
tbuf.tm_mon = y;
+11 -7
View File
@@ -28,7 +28,8 @@
* @endp: A pointer to the end of the parsed string will be placed here
* @base: The number base to use
*/
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
unsigned long simple_strtoul(
const char *cp, const char **endp, unsigned int base)
{
unsigned long result = 0,value;
@@ -52,7 +53,7 @@ unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
cp++;
}
if (endp)
*endp = (char *)cp;
*endp = cp;
return result;
}
@@ -64,7 +65,7 @@ EXPORT_SYMBOL(simple_strtoul);
* @endp: A pointer to the end of the parsed string will be placed here
* @base: The number base to use
*/
long simple_strtol(const char *cp,char **endp,unsigned int base)
long simple_strtol(const char *cp, const char **endp, unsigned int base)
{
if(*cp=='-')
return -simple_strtoul(cp+1,endp,base);
@@ -79,7 +80,8 @@ EXPORT_SYMBOL(simple_strtol);
* @endp: A pointer to the end of the parsed string will be placed here
* @base: The number base to use
*/
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base)
unsigned long long simple_strtoull(
const char *cp, const char **endp, unsigned int base)
{
unsigned long long result = 0,value;
@@ -103,7 +105,7 @@ unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base)
cp++;
}
if (endp)
*endp = (char *)cp;
*endp = cp;
return result;
}
@@ -115,7 +117,7 @@ EXPORT_SYMBOL(simple_strtoull);
* @endp: A pointer to the end of the parsed string will be placed here
* @base: The number base to use
*/
long long simple_strtoll(const char *cp,char **endp,unsigned int base)
long long simple_strtoll(const char *cp,const char **endp,unsigned int base)
{
if(*cp=='-')
return -simple_strtoull(cp+1,endp,base);
@@ -139,7 +141,9 @@ static int skip_atoi(const char **s)
#define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
static char * number(char * buf, char * end, unsigned long long num, int base, int size, int precision, int type)
static char *number(
char *buf, char *end, unsigned long long num,
int base, int size, int precision, int type)
{
char c,sign,tmp[66];
const char *digits;
+2 -2
View File
@@ -87,7 +87,7 @@ static void *data_from_header(struct xmalloc_hdr *hdr)
#endif
}
static struct xmalloc_hdr *header_from_data(const void *p)
static struct xmalloc_hdr *header_from_data(void *p)
{
#if XMALLOC_DEBUG
unsigned char *data = (unsigned char *)p - SMP_CACHE_BYTES;
@@ -208,7 +208,7 @@ void *_xmalloc(size_t size, size_t align)
return xmalloc_new_page(size);
}
void xfree(const void *p)
void xfree(void *p)
{
unsigned long flags;
struct xmalloc_hdr *i, *tmp, *hdr;
+1 -1
View File
@@ -300,7 +300,7 @@ static int parse_parity_char(int c)
return; \
} while ( 0 )
static void ns16550_parse_port_config(struct ns16550 *uart, char *conf)
static void ns16550_parse_port_config(struct ns16550 *uart, const char *conf)
{
int baud;
+4 -4
View File
@@ -288,7 +288,7 @@ static inline unsigned int __scanbit(unsigned long val)
*/
#define find_first_bit(addr,size) \
((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
(__scanbit(*(unsigned long *)addr)) : \
(__scanbit(*(const unsigned long *)addr)) : \
__find_first_bit(addr,size)))
/**
@@ -299,7 +299,7 @@ static inline unsigned int __scanbit(unsigned long val)
*/
#define find_next_bit(addr,size,off) \
((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
((off) + (__scanbit((*(unsigned long *)addr) >> (off)))) : \
((off) + (__scanbit((*(const unsigned long *)addr) >> (off)))) : \
__find_next_bit(addr,size,off)))
/**
@@ -312,7 +312,7 @@ static inline unsigned int __scanbit(unsigned long val)
*/
#define find_first_zero_bit(addr,size) \
((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
(__scanbit(~*(unsigned long *)addr)) : \
(__scanbit(~*(const unsigned long *)addr)) : \
__find_first_zero_bit(addr,size)))
/**
@@ -323,7 +323,7 @@ static inline unsigned int __scanbit(unsigned long val)
*/
#define find_next_zero_bit(addr,size,off) \
((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
((off)+(__scanbit(~(((*(unsigned long *)addr)) >> (off))))) : \
((off)+(__scanbit(~(((*(const unsigned long *)addr)) >> (off))))) : \
__find_next_zero_bit(addr,size,off)))
+1 -1
View File
@@ -19,7 +19,7 @@
#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
struct __xchg_dummy { unsigned long a[100]; };
#define __xg(x) ((struct __xchg_dummy *)(x))
#define __xg(x) ((volatile struct __xchg_dummy *)(x))
/*
+5 -5
View File
@@ -140,7 +140,7 @@ extern void __put_user_bad(void);
})
struct __large_struct { unsigned long buf[100]; };
#define __m(x) (*(struct __large_struct *)(x))
#define __m(x) (*(const struct __large_struct *)(x))
/*
* Tell gcc we read from memory instead of writing: this is because
@@ -200,16 +200,16 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)
switch (n) {
case 1:
__put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1);
__put_user_size(*(const u8 *)from, (u8 __user *)to, 1, ret, 1);
return ret;
case 2:
__put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2);
__put_user_size(*(const u16 *)from, (u16 __user *)to, 2, ret, 2);
return ret;
case 4:
__put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4);
__put_user_size(*(const u32 *)from, (u32 __user *)to, 4, ret, 4);
return ret;
case 8:
__put_user_size(*(u64 *)from, (u64 __user *)to, 8, ret, 8);
__put_user_size(*(const u64 *)from, (u64 __user *)to, 8, ret, 8);
return ret;
}
}
+1 -1
View File
@@ -526,7 +526,7 @@ extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
extern const char *xen_elfnote_string(struct domain_setup_info *dsi, int type);
#ifdef Elf_Ehdr
extern int elf_sanity_check(Elf_Ehdr *ehdr);
extern int elf_sanity_check(const Elf_Ehdr *ehdr);
#endif
#endif /* __XEN_ELF_H__ */
+7 -7
View File
@@ -41,19 +41,19 @@
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
#define container_of(ptr, type, member) ({ \
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
/*
* Check at compile time that something is of a particular type.
* Always evaluates to 1 so you may use it easily in comparisons.
*/
#define typecheck(type,x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
#define typecheck(type,x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
})
+5 -5
View File
@@ -74,15 +74,15 @@ extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
__attribute__ ((format (printf, 3, 0)));
long simple_strtol(
const char *cp,char **endp, unsigned int base);
const char *cp,const char **endp, unsigned int base);
unsigned long simple_strtoul(
const char *cp,char **endp, unsigned int base);
const char *cp,const char **endp, unsigned int base);
long long simple_strtoll(
const char *cp,char **endp, unsigned int base);
const char *cp,const char **endp, unsigned int base);
unsigned long long simple_strtoull(
const char *cp,char **endp, unsigned int base);
const char *cp,const char **endp, unsigned int base);
unsigned long long parse_size_and_unit(const char *s, char **ps);
unsigned long long parse_size_and_unit(const char *s, const char **ps);
#define TAINT_UNSAFE_SMP (1<<0)
#define TAINT_MACHINE_CHECK (1<<1)
+2 -2
View File
@@ -202,8 +202,8 @@ struct domain_setup_info
* You should use the xen_elfnote_* accessors below in order to
* pickup the correct one and retain backwards compatibility.
*/
void *__elfnote_section, *__elfnote_section_end;
char *__xen_guest_string;
const void *__elfnote_section, *__elfnote_section_end;
const char *__xen_guest_string;
};
extern struct vcpu *idle_vcpu[NR_CPUS];
+1 -1
View File
@@ -12,7 +12,7 @@
#define xmalloc_bytes(_bytes) (_xmalloc(_bytes, SMP_CACHE_BYTES))
/* Free any of the above. */
extern void xfree(const void *);
extern void xfree(void *);
/* Underlying functions */
extern void *_xmalloc(size_t size, size_t align);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.