Skip to content

Commit 3b98a41

Browse files
committed
Add const to path functions.
In order to help avoid modifying static path variables, they are now returned as const char*. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
1 parent d04b512 commit 3b98a41

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

src/librc/librc-depend.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#define RC_DEPCONFIG "/depconfig"
3939

40-
static char*
40+
static const char*
4141
depconfigpath_get(void) {
4242
static char path[PATH_MAX] = { 0 };
4343
if (!*path) {
@@ -782,7 +782,7 @@ rc_deptree_update(void)
782782
char *depend, *depends, *service, *type, *nosys, *onosys;
783783
size_t i, k, l;
784784
bool retval = true;
785-
const char *sys = rc_sys();
785+
const char *sys = rc_sys(), *depconf = depconfigpath_get();
786786
struct utsname uts;
787787
int serrno;
788788

@@ -1084,7 +1084,6 @@ rc_deptree_update(void)
10841084
}
10851085

10861086
/* Save our external config files to disk */
1087-
char *depconf = depconfigpath_get();
10881087
if (TAILQ_FIRST(config)) {
10891088
if ((fp = fopen(depconf, "w"))) {
10901089
TAILQ_FOREACH(s, config, entries)

src/librc/librc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ rc_sys(void)
367367
return sys;
368368
}
369369

370-
char *
370+
const char *
371371
rc_sysconfdir_get(void) {
372372
static char path[PATH_MAX] = { 0 };
373373
if (!*path) {
@@ -387,7 +387,7 @@ rc_sysconfdir_get(void) {
387387
return path;
388388
}
389389

390-
char *
390+
const char *
391391
rc_svcdir_get(void) {
392392
static char path[PATH_MAX] = { 0 };
393393
if (!*path) {
@@ -409,7 +409,7 @@ rc_svcdir_get(void) {
409409
return path;
410410
}
411411

412-
char *
412+
const char *
413413
rc_initdir_get(void) {
414414
static char path[PATH_MAX] = { 0 };
415415
if (!*path) {
@@ -418,7 +418,7 @@ rc_initdir_get(void) {
418418
return path;
419419
}
420420

421-
char *
421+
const char *
422422
rc_confdir_get(void) {
423423
static char path[PATH_MAX] = { 0 };
424424
if (!*path) {
@@ -427,7 +427,7 @@ rc_confdir_get(void) {
427427
return path;
428428
}
429429

430-
char *
430+
const char *
431431
rc_runleveldir_get(void) {
432432
static char path[PATH_MAX] = { 0 };
433433
if (!*path) {

src/librc/rc.h.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ typedef TAILQ_HEAD(rc_stringlist, rc_string) RC_STRINGLIST;
128128
bool rc_sysconfdir_set(char *path);
129129
bool rc_svcdir_set(char *path);
130130

131-
char *rc_sysconfdir_get(void);
132-
char *rc_initdir_get(void);
133-
char *rc_confdir_get(void);
134-
char *rc_svcdir_get(void);
135-
char *rc_runtimedir_get(void);
136-
char *rc_runleveldir_get(void);
131+
const char *rc_sysconfdir_get(void);
132+
const char *rc_initdir_get(void);
133+
const char *rc_confdir_get(void);
134+
const char *rc_svcdir_get(void);
135+
const char *rc_runtimedir_get(void);
136+
const char *rc_runleveldir_get(void);
137137

138138
/*! Return the current runlevel.
139139
* @return the current runlevel */

src/openrc-run/openrc-run.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
#define PREFIX_LOCK "prefix.lock"
5959

60-
static char *
60+
static const char *
6161
prefix_lock_get(void) {
6262
static char path[PATH_MAX] = { 0 };
6363
if (!path[0]) {

src/openrc/rc-logger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
#define TMPLOG "rc.log"
5050

51-
static char *
51+
static const char *
5252
gettmplog(void) {
5353
static char path[PATH_MAX] = { 0 };
5454
if (!path[0]) {

0 commit comments

Comments
 (0)