xen/x86: Use const char * for string literals

For pre-ANSI-C compatibility reasons, string literals have a mutable type, but
it is undefined behaviour to mutate them.

Swap char *'s to const char *'s for variables which hold string literals.

This fixes several violations of MISRA Rule 7.4:

  A string literal shall not be assigned to an object unless the object's type
  is "pointer to const-qualified char".

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2023-07-17 11:35:41 +01:00
1 parent edecca33f9
commit d642c07066
9 files changed
+15 -15

No files matched your search

+1 -1
View File
@@ -302,7 +302,7 @@ static void print_hw_residencies(uint32_t cpu)
hw_res.cc6, hw_res.cc7);
}
static char* acpi_cstate_method_name[] =
static const char *const acpi_cstate_method_name[] =
{
"NONE",
"SYSIO",
+1 -1
View File
@@ -1705,7 +1705,7 @@ static void mc_panic_dump(void)
dprintk(XENLOG_ERR, "End dump mc_info, %x mcinfo dumped\n", mcinfo_dumpped);
}
void mc_panic(char *s)
void mc_panic(const char *s)
{
is_mc_panic = true;
console_force_unlock();
+1 -1
View File
@@ -57,7 +57,7 @@ struct mcinfo_extended *intel_get_extended_msrs(
bool mce_available(const struct cpuinfo_x86 *c);
unsigned int mce_firstbank(struct cpuinfo_x86 *c);
/* Helper functions used for collecting error telemetry */
void noreturn mc_panic(char *s);
void noreturn mc_panic(const char *s);
void x86_mc_get_cpu_info(unsigned, uint32_t *, uint16_t *, uint16_t *,
uint32_t *, uint32_t *, uint32_t *, uint32_t *);
+1 -1
View File
@@ -363,7 +363,7 @@ static unsigned long __init find_max_pfn(void)
return max_pfn;
}
static void __init clip_to_limit(uint64_t limit, char *warnmsg)
static void __init clip_to_limit(uint64_t limit, const char *warnmsg)
{
unsigned int i;
char _warnmsg[160];
+2 -2
View File
@@ -1949,7 +1949,7 @@ static inline unsigned long vmr(unsigned long field)
(uint32_t)vmr(fld); \
})
static void vmx_dump_sel(char *name, uint32_t selector)
static void vmx_dump_sel(const char *name, uint32_t selector)
{
uint32_t sel, attr, limit;
uint64_t base;
@@ -1960,7 +1960,7 @@ static void vmx_dump_sel(char *name, uint32_t selector)
printk("%s: %04x %05x %08x %016"PRIx64"\n", name, sel, attr, limit, base);
}
static void vmx_dump_sel2(char *name, uint32_t lim)
static void vmx_dump_sel2(const char *name, uint32_t lim)
{
uint32_t limit;
uint64_t base;
+1 -1
View File
@@ -92,7 +92,7 @@ struct hvm_vcpu_nonreg_state {
* supports Intel's VT-x and AMD's SVM extensions.
*/
struct hvm_function_table {
char *name;
const char *name;
/* Support Hardware-Assisted Paging? */
bool_t hap_supported;
+4 -4
View File
@@ -36,7 +36,7 @@ struct op_x86_model_spec const *__read_mostly model;
static struct op_msrs cpu_msrs[NR_CPUS];
static unsigned long saved_lvtpc[NR_CPUS];
static char *cpu_type;
static const char *cpu_type;
static DEFINE_PER_CPU(struct vcpu *, nmi_cont_vcpu);
@@ -309,7 +309,7 @@ void nmi_stop(void)
}
static int __init p4_init(char ** cpu_type)
static int __init p4_init(const char **cpu_type)
{
unsigned int cpu_model = current_cpu_data.x86_model;
@@ -353,7 +353,7 @@ static int __init cf_check force_cpu_type(const char *str)
}
custom_param("cpu_type", force_cpu_type);
static int __init ppro_init(char ** cpu_type)
static int __init ppro_init(const char **cpu_type)
{
if (force_arch_perfmon && cpu_has_arch_perfmon)
return 0;
@@ -375,7 +375,7 @@ static int __init ppro_init(char ** cpu_type)
return 1;
}
static int __init arch_perfmon_init(char **cpu_type)
static int __init arch_perfmon_init(const char **cpu_type)
{
if (!cpu_has_arch_perfmon)
return 0;
+2 -2
View File
@@ -64,8 +64,8 @@ struct cpu_time {
};
struct platform_timesource {
char *id;
char *name;
const char *id;
const char *name;
u64 frequency;
/* Post-init this hook may only be invoked via the read_counter() wrapper! */
u64 (*read_counter)(void);
+2 -2
View File
@@ -20,12 +20,12 @@ enum dmi_field {
*/
struct dmi_strmatch {
u8 slot;
char *substr;
const char *substr;
};
struct dmi_system_id {
int (*callback)(const struct dmi_system_id *);
char *ident;
const char *ident;
struct dmi_strmatch matches[4];
void *driver_data;
};
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.