Skip to content

Commit

Permalink
Add const to path functions.
Browse files Browse the repository at this point in the history
In order to help avoid modifying static path variables,
they are now returned as const char*.

Signed-off-by: Anna (navi) Figueiredo Gomes <[email protected]>
  • Loading branch information
navi-desu committed Mar 8, 2023
1 parent d04b512 commit 972510f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/librc/librc-depend.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#define RC_DEPCONFIG "/depconfig"

static char*
static const char*
depconfigpath_get(void) {
static char path[PATH_MAX] = { 0 };
if (!*path) {
Expand Down
10 changes: 5 additions & 5 deletions src/librc/librc.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ rc_sys(void)
return sys;
}

char *
const char *
rc_sysconfdir_get(void) {
static char path[PATH_MAX] = { 0 };
if (!*path) {
Expand All @@ -387,7 +387,7 @@ rc_sysconfdir_get(void) {
return path;
}

char *
const char *
rc_svcdir_get(void) {
static char path[PATH_MAX] = { 0 };
if (!*path) {
Expand All @@ -409,7 +409,7 @@ rc_svcdir_get(void) {
return path;
}

char *
const char *
rc_initdir_get(void) {
static char path[PATH_MAX] = { 0 };
if (!*path) {
Expand All @@ -418,7 +418,7 @@ rc_initdir_get(void) {
return path;
}

char *
const char *
rc_confdir_get(void) {
static char path[PATH_MAX] = { 0 };
if (!*path) {
Expand All @@ -427,7 +427,7 @@ rc_confdir_get(void) {
return path;
}

char *
const char *
rc_runleveldir_get(void) {
static char path[PATH_MAX] = { 0 };
if (!*path) {
Expand Down
12 changes: 6 additions & 6 deletions src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ typedef TAILQ_HEAD(rc_stringlist, rc_string) RC_STRINGLIST;
bool rc_sysconfdir_set(char *path);
bool rc_svcdir_set(char *path);

char *rc_sysconfdir_get(void);
char *rc_initdir_get(void);
char *rc_confdir_get(void);
char *rc_svcdir_get(void);
char *rc_runtimedir_get(void);
char *rc_runleveldir_get(void);
const char *rc_sysconfdir_get(void);
const char *rc_initdir_get(void);
const char *rc_confdir_get(void);
const char *rc_svcdir_get(void);
const char *rc_runtimedir_get(void);
const char *rc_runleveldir_get(void);

/*! Return the current runlevel.
* @return the current runlevel */
Expand Down
2 changes: 1 addition & 1 deletion src/openrc-run/openrc-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

#define PREFIX_LOCK "prefix.lock"

static char *
static const char *
prefix_lock_get(void) {
static char path[PATH_MAX] = { 0 };
if (!path[0]) {
Expand Down
2 changes: 1 addition & 1 deletion src/openrc/rc-logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#define TMPLOG "rc.log"

static char *
static const char *
gettmplog(void) {
static char path[PATH_MAX] = { 0 };
if (!path[0]) {
Expand Down

0 comments on commit 972510f

Please sign in to comment.