diff --git a/sys/arm/arm/identcpu-v6.c b/sys/arm/arm/identcpu-v6.c --- a/sys/arm/arm/identcpu-v6.c +++ b/sys/arm/arm/identcpu-v6.c @@ -49,10 +49,10 @@ #include #include -char machine[] = "arm"; +const char machine[] = "arm"; -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, - machine, 0, "Machine class"); +SYSCTL_CONST_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, + machine, "Machine class"); static char cpu_model[64]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD | CTLFLAG_CAPRD, diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -59,7 +59,7 @@ static u_long parse_cpu_features_hwcap32(void); #endif -char machine[] = "arm64"; +const char machine[] = "arm64"; #ifdef SCTL_MASK32 extern int adaptive_machine_arch; diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -312,13 +312,13 @@ #define VERSTR "${VERSTR}" #define RELSTR "${RELEASE}" -char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; -char version[sizeof(VERSTR) > 256 ? sizeof(VERSTR) : 256] = VERSTR; -char compiler_version[] = "${compiler_v}"; -char ostype[] = "${TYPE}"; -char osrelease[sizeof(RELSTR) > 32 ? sizeof(RELSTR) : 32] = RELSTR; -int osreldate = ${RELDATE}; -char kern_ident[] = "${i}"; +const char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; +const char version[sizeof(VERSTR) > 256 ? sizeof(VERSTR) : 256] = VERSTR; +const char compiler_version[] = "${compiler_v}"; +const char ostype[] = "${TYPE}"; +const char osrelease[sizeof(RELSTR) > 32 ? sizeof(RELSTR) : 32] = RELSTR; +const int osreldate = ${RELDATE}; +const char kern_ident[] = "${i}"; EOF ) vers_content_old=$(cat vers.c 2>/dev/null || true) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -365,36 +365,36 @@ printf("%s\n", compiler_version); } -SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t, +C_SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t, copyright); -SYSINIT(trademark, SI_SUB_COPYRIGHT, SI_ORDER_SECOND, print_caddr_t, +C_SYSINIT(trademark, SI_SUB_COPYRIGHT, SI_ORDER_SECOND, print_caddr_t, trademark); -SYSINIT(version, SI_SUB_COPYRIGHT, SI_ORDER_THIRD, print_version, NULL); +C_SYSINIT(version, SI_SUB_COPYRIGHT, SI_ORDER_THIRD, print_version, NULL); #ifdef WITNESS -static char wit_warn[] = +static const char wit_warn[] = "WARNING: WITNESS option enabled, expect reduced performance.\n"; -SYSINIT(witwarn, SI_SUB_COPYRIGHT, SI_ORDER_FOURTH, +C_SYSINIT(witwarn, SI_SUB_COPYRIGHT, SI_ORDER_FOURTH, print_caddr_t, wit_warn); -SYSINIT(witwarn2, SI_SUB_LAST, SI_ORDER_FOURTH, +C_SYSINIT(witwarn2, SI_SUB_LAST, SI_ORDER_FOURTH, print_caddr_t, wit_warn); #endif #ifdef DIAGNOSTIC -static char diag_warn[] = +static const char diag_warn[] = "WARNING: DIAGNOSTIC option enabled, expect reduced performance.\n"; -SYSINIT(diagwarn, SI_SUB_COPYRIGHT, SI_ORDER_FIFTH, +C_SYSINIT(diagwarn, SI_SUB_COPYRIGHT, SI_ORDER_FIFTH, print_caddr_t, diag_warn); -SYSINIT(diagwarn2, SI_SUB_LAST, SI_ORDER_FIFTH, +C_SYSINIT(diagwarn2, SI_SUB_LAST, SI_ORDER_FIFTH, print_caddr_t, diag_warn); #endif #if __SIZEOF_LONG__ == 4 -static char ilp32_warn[] = +static const char ilp32_warn[] = "WARNING: 32-bit kernels are deprecated and may be removed in FreeBSD 15.0.\n"; -SYSINIT(ilp32warn, SI_SUB_COPYRIGHT, SI_ORDER_FIFTH, +C_SYSINIT(ilp32warn, SI_SUB_COPYRIGHT, SI_ORDER_FIFTH, print_caddr_t, ilp32_warn); -SYSINIT(ilp32warn2, SI_SUB_LAST, SI_ORDER_FIFTH, +C_SYSINIT(ilp32warn2, SI_SUB_LAST, SI_ORDER_FIFTH, print_caddr_t, ilp32_warn); #endif diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -94,20 +94,20 @@ "Regression test MIB"); #endif -SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD, - kern_ident, 0, "Kernel identifier"); +SYSCTL_CONST_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD, + kern_ident, "Kernel identifier"); SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD | CTLFLAG_CAPRD, SYSCTL_NULL_INT_PTR, BSD, "Operating system revision"); -SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD, - version, 0, "Kernel version"); +SYSCTL_CONST_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD, + version, "Kernel version"); -SYSCTL_STRING(_kern, OID_AUTO, compiler_version, CTLFLAG_RD, - compiler_version, 0, "Version of compiler used to compile kernel"); +SYSCTL_CONST_STRING(_kern, OID_AUTO, compiler_version, CTLFLAG_RD, + compiler_version, "Version of compiler used to compile kernel"); -SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD | CTLFLAG_CAPRD, - ostype, 0, "Operating system type"); +SYSCTL_CONST_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD | CTLFLAG_CAPRD, + ostype, "Operating system type"); SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxproc, 0, "Maximum number of processes"); diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -152,8 +152,9 @@ static struct trapframe frame0; -char machine[] = "powerpc"; -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, machine, 0, ""); +const char machine[] = "powerpc"; +SYSCTL_CONST_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, + machine, "Machine class"); static void cpu_startup(void *); SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); diff --git a/sys/riscv/riscv/identcpu.c b/sys/riscv/riscv/identcpu.c --- a/sys/riscv/riscv/identcpu.c +++ b/sys/riscv/riscv/identcpu.c @@ -59,10 +59,10 @@ #include #endif -char machine[] = "riscv"; +const char machine[] = "riscv"; -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, machine, 0, - "Machine class"); +SYSCTL_CONST_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, + machine, "Machine class"); /* Hardware implementation info. These values may be empty. */ register_t mvendorid; /* The CPU's JEDEC vendor ID */ diff --git a/sys/sys/copyright.h b/sys/sys/copyright.h --- a/sys/sys/copyright.h +++ b/sys/sys/copyright.h @@ -45,5 +45,5 @@ #define COPYRIGHT_UCB \ "Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994\n\tThe Regents of the University of California. All rights reserved.\n" -char copyright[] = COPYRIGHT_Vendor COPYRIGHT_FreeBSD COPYRIGHT_UCB; -char trademark[] = TRADEMARK_Foundation; +const char copyright[] = COPYRIGHT_Vendor COPYRIGHT_FreeBSD COPYRIGHT_UCB; +const char trademark[] = TRADEMARK_Foundation; diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1153,10 +1153,10 @@ SYSCTL_DECL(_security); SYSCTL_DECL(_security_bsd); -extern char machine[]; -extern char osrelease[]; -extern char ostype[]; -extern char kern_ident[]; +extern const char machine[]; +extern const char osrelease[]; +extern const char ostype[]; +extern const char kern_ident[]; /* Dynamic oid handling */ struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, diff --git a/sys/sys/systm.h b/sys/sys/systm.h --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -51,9 +51,9 @@ extern int cold; /* nonzero if we are doing a cold boot */ extern int suspend_blocked; /* block suspend due to pending shutdown */ extern int rebooting; /* kern_reboot() has been called. */ -extern char version[]; /* system version */ -extern char compiler_version[]; /* compiler version */ -extern char copyright[]; /* system copyright */ +extern const char version[]; /* system version */ +extern const char compiler_version[]; /* compiler version */ +extern const char copyright[]; /* system copyright */ extern int kstack_pages; /* number of kernel stack pages */ extern u_long pagesizes[]; /* supported page sizes */ @@ -109,7 +109,7 @@ */ #define SCHEDULER_STOPPED() __predict_false(scheduler_stopped) -extern int osreldate; +extern const int osreldate; extern const void *zero_region; /* address space maps to a zeroed page */ diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -124,7 +124,7 @@ u_int cpu_power_ebx; /* 06H: Power management leaf, %ebx */ u_int cpu_power_ecx; /* 06H: Power management leaf, %ecx */ u_int cpu_power_edx; /* 06H: Power management leaf, %edx */ -char machine[] = MACHINE; +const char machine[] = MACHINE; SYSCTL_UINT(_hw, OID_AUTO, via_feature_rng, CTLFLAG_RD, &via_feature_rng, 0, @@ -158,8 +158,8 @@ SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A", "Machine class"); #else -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, - machine, 0, "Machine class"); +SYSCTL_CONST_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, + machine, "Machine class"); #endif char cpu_model[128];