Declare read-only data const

This commit is contained in:
Christian Göttsche 2022-08-05 17:40:31 +02:00 committed by Serge Hallyn
parent 44917600b6
commit ae38d3a87f
4 changed files with 10 additions and 10 deletions

View File

@ -14,7 +14,7 @@ static bool path_exists(const char *p)
static const char *btrfs_cmd(void) static const char *btrfs_cmd(void)
{ {
const char *btrfs_paths[] = {"/sbin/btrfs", const char *const btrfs_paths[] = {"/sbin/btrfs",
"/bin/btrfs", "/usr/sbin/btrfs", "/usr/bin/btrfs", NULL}; "/bin/btrfs", "/usr/sbin/btrfs", "/usr/bin/btrfs", NULL};
const char *p; const char *p;
int i; int i;

View File

@ -28,7 +28,7 @@ size_t newenvc = 0;
/*@null@*/char **newenvp = NULL; /*@null@*/char **newenvp = NULL;
extern char **environ; extern char **environ;
static const char *forbid[] = { static const char *const forbid[] = {
"_RLD_=", "_RLD_=",
"BASH_ENV=", /* GNU creeping featurism strikes again... */ "BASH_ENV=", /* GNU creeping featurism strikes again... */
"ENV=", "ENV=",
@ -47,7 +47,7 @@ static const char *forbid[] = {
/* these are allowed, but with no slashes inside /* these are allowed, but with no slashes inside
(to work around security problems in GNU gettext) */ (to work around security problems in GNU gettext) */
static const char *noslash[] = { static const char *const noslash[] = {
"LANG=", "LANG=",
"LANGUAGE=", "LANGUAGE=",
"LC_", /* anything with the LC_ prefix */ "LC_", /* anything with the LC_ prefix */
@ -185,7 +185,7 @@ void set_env (int argc, char *const *argv)
noname++; noname++;
addenv (variable, *argv); addenv (variable, *argv);
} else { } else {
const char **p; const char *const *p;
for (p = forbid; NULL != *p; p++) { for (p = forbid; NULL != *p; p++) {
if (strncmp (*argv, *p, strlen (*p)) == 0) { if (strncmp (*argv, *p, strlen (*p)) == 0) {
@ -218,7 +218,7 @@ void set_env (int argc, char *const *argv)
void sanitize_env (void) void sanitize_env (void)
{ {
char **envp = environ; char **envp = environ;
const char **bad; const char *const *bad;
char **cur; char **cur;
char **move; char **move;

View File

@ -22,7 +22,7 @@ static int ni_conv (int num_msg,
const struct pam_message **msg, const struct pam_message **msg,
struct pam_response **resp, struct pam_response **resp,
unused void *appdata_ptr); unused void *appdata_ptr);
static struct pam_conv non_interactive_pam_conv = { static const struct pam_conv non_interactive_pam_conv = {
ni_conv, ni_conv,
NULL NULL
}; };

View File

@ -96,7 +96,7 @@ long strtoday (const char *str)
* for now we allow just one format, but we can define more later * for now we allow just one format, but we can define more later
* (we try them all until one succeeds). --marekm * (we try them all until one succeeds). --marekm
*/ */
static char *date_formats[] = { static const char *const date_formats[] = {
"%Y-%m-%d", "%Y-%m-%d",
(char *) 0 (char *) 0
}; };
@ -106,12 +106,12 @@ static char *date_formats[] = {
* current month, and the cumulative number of days in the preceding * current month, and the cumulative number of days in the preceding
* months. they are declared so that january is 1, not 0. * months. they are declared so that january is 1, not 0.
*/ */
static short days[13] = { 0, static const short days[13] = { 0,
31, 28, 31, 30, 31, 30, /* JAN - JUN */ 31, 28, 31, 30, 31, 30, /* JAN - JUN */
31, 31, 30, 31, 30, 31 31, 31, 30, 31, 30, 31
}; /* JUL - DEC */ }; /* JUL - DEC */
static short juldays[13] = { 0, static const short juldays[13] = { 0,
0, 31, 59, 90, 120, 151, /* JAN - JUN */ 0, 31, 59, 90, 120, 151, /* JAN - JUN */
181, 212, 243, 273, 304, 334 181, 212, 243, 273, 304, 334
}; /* JUL - DEC */ }; /* JUL - DEC */
@ -129,7 +129,7 @@ long strtoday (const char *str)
{ {
#ifdef HAVE_STRPTIME #ifdef HAVE_STRPTIME
struct tm tp; struct tm tp;
char *const *fmt; const char *const *fmt;
char *cp; char *cp;
time_t result; time_t result;