[PATCH procd 1/2] rcS, ubus: constify char * arguments and variables where appropriate
Nora Matthias Schiffer
neocturne at universe-factory.net
Wed Nov 26 11:36:06 PST 2025
Signed-off-by: Nora Matthias Schiffer <neocturne at universe-factory.net>
---
procd.h | 2 +-
rcS.c | 10 +++++-----
rcS.h | 4 ++--
ubus.c | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/procd.h b/procd.h
index c656d3b..f48edeb 100644
--- a/procd.h
+++ b/procd.h
@@ -27,7 +27,7 @@
#define __init __attribute__((constructor))
-extern char *ubus_socket;
+extern const char *ubus_socket;
void procd_connect_ubus(void);
void procd_reconnect_ubus(int reconnect);
diff --git a/rcS.c b/rcS.c
index bfaf50b..45a96a9 100644
--- a/rcS.c
+++ b/rcS.c
@@ -125,7 +125,7 @@ static void q_initd_complete(struct runqueue *q, struct runqueue_task *p)
free(s);
}
-static bool find_runqueue_list_entry(struct list_head *list, char *file, char *param)
+static bool find_runqueue_list_entry(struct list_head *list, const char *file, const char *param)
{
struct initd *s;
@@ -135,7 +135,7 @@ static bool find_runqueue_list_entry(struct list_head *list, char *file, char *p
return false;
}
-static void add_initd(struct runqueue *q, char *file, char *param)
+static void add_initd(struct runqueue *q, const char *file, const char *param)
{
static const struct runqueue_task_type initd_type = {
.run = q_initd_run,
@@ -168,7 +168,7 @@ static void add_initd(struct runqueue *q, char *file, char *param)
runqueue_task_add(q, &s->proc.task, false);
}
-static int _rc(struct runqueue *q, char *path, const char *file, char *pattern, char *param)
+static int _rc(struct runqueue *q, const char *path, const char *file, const char *pattern, const char *param)
{
char *dir = alloca(2 + strlen(path) + strlen(file) + strlen(pattern));
glob_t gl;
@@ -194,7 +194,7 @@ static int _rc(struct runqueue *q, char *path, const char *file, char *pattern,
return 0;
}
-int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
+int rcS(const char *pattern, const char *param, void (*q_empty)(struct runqueue *))
{
runqueue_init(&q);
q.empty_cb = q_empty;
@@ -203,7 +203,7 @@ int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
return _rc(&q, "/etc/rc.d", pattern, "*", param);
}
-int rc(const char *file, char *param)
+int rc(const char *file, const char *param)
{
return _rc(&r, "/etc/init.d", file, "", param);
}
diff --git a/rcS.h b/rcS.h
index 91d37d1..9b6bb84 100644
--- a/rcS.h
+++ b/rcS.h
@@ -17,7 +17,7 @@
#include <libubox/runqueue.h>
-extern int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *));
-extern int rc(const char *file, char *param);
+extern int rcS(const char *pattern, const char *param, void (*q_empty)(struct runqueue *));
+extern int rc(const char *file, const char *param);
#endif
diff --git a/ubus.c b/ubus.c
index b0b7c9a..23f640a 100644
--- a/ubus.c
+++ b/ubus.c
@@ -19,7 +19,7 @@
#include "procd.h"
-char *ubus_socket = NULL;
+const char *ubus_socket = NULL;
static struct ubus_context *ctx;
static struct uloop_timeout ubus_timer;
static int timeout;
--
2.52.0
More information about the openwrt-devel
mailing list