[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen/x86: Use const char * for string literals
commit d642c07066780e67016a2f9391dc0f125f1123a6 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Fri Jul 14 11:18:53 2023 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Mon Jul 17 11:35:41 2023 +0100 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@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/acpi/cpu_idle.c | 2 +- xen/arch/x86/cpu/mcheck/mce.c | 2 +- xen/arch/x86/cpu/mcheck/mce.h | 2 +- xen/arch/x86/e820.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 4 ++-- xen/arch/x86/include/asm/hvm/hvm.h | 2 +- xen/arch/x86/oprofile/nmi_int.c | 8 ++++---- xen/arch/x86/time.c | 4 ++-- xen/include/xen/dmi.h | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 427c8c89c5..cfce4cc040 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -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", diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 140634198c..c2173cfc78 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -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(); diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h index 5a751d1485..d40cee531a 100644 --- a/xen/arch/x86/cpu/mcheck/mce.h +++ b/xen/arch/x86/cpu/mcheck/mce.h @@ -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 *); diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index c5911cf48d..0b89935510 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -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]; diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index b209563625..13719cc923 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -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; diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h index 9555b4c41f..3c37f522b9 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -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; diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_int.c index 17bf3135f8..1313818af8 100644 --- a/xen/arch/x86/oprofile/nmi_int.c +++ b/xen/arch/x86/oprofile/nmi_int.c @@ -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; diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index f5e30d4e02..af40a9993c 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -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); diff --git a/xen/include/xen/dmi.h b/xen/include/xen/dmi.h index fa25f6cd38..71a5c46dc6 100644 --- a/xen/include/xen/dmi.h +++ b/xen/include/xen/dmi.h @@ -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; }; -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |