DragonFly BSD
DragonFly submit List (threaded) for 2005-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Patch to init


From: "Kevin M. Kilbride" <kmk@xxxxxxx>
Date: Thu, 24 Feb 2005 21:02:25 -0800

This patch brings sbin/init into WARNS=6 compliance. It depends upon the execve 'constification' patch submitted prior.

--- sbin/init/init.c.orig    2005-02-24 00:20:41.000000000 -0800
+++ sbin/init/init.c    2005-02-24 01:12:44.000000000 -0800
@@ -95,12 +95,13 @@
void handle(sig_t, ...);
void delset(sigset_t *, ...);

-void stall(char *, ...);
-void warning(char *, ...);
-void emergency(char *, ...);
+void stall(const char *, ...);
+void warning(const char *, ...);
+void emergency(const char *, ...);
void disaster(int);
void badsys(int);
int  runshutdown(void);
+char *strk(char *);

/*
 * We really need a recursive typedef...
@@ -128,7 +129,7 @@
void transition(state_t);
state_t requested_transition = runcom;

-void setctty(char *);
+void setctty(const char *);

typedef struct init_session {
    int    se_index;        /* index of entry in ttys file */
@@ -376,7 +377,7 @@
 * NB: should send a message to the session logger to avoid blocking.
 */
void
-stall(char *message, ...)
+stall(const char *message, ...)
{
    va_list ap;

@@ -393,7 +394,7 @@
 * NB: should send a message to the session logger to avoid blocking.
 */
void
-warning(char *message, ...)
+warning(const char *message, ...)
{
    va_list ap;

@@ -408,7 +409,7 @@
 * NB: should send a message to the session logger to avoid blocking.
 */
void
-emergency(char *message, ...)
+emergency(const char *message, ...)
{
    va_list ap;

@@ -476,6 +477,8 @@
 * kernel environment (or NULL if not set).
 * (Most of this has been copied from src/usr.bin/kenv/kenv.c.)
 */
+const char namestring[] = "kern.environment";
+
char *
get_chroot(void)
{
@@ -484,8 +487,8 @@
    int real_oid[CTL_MAXNAME+4];
    int n2oid_oid[2];
    char sbuf[1024];
+    char name[sizeof(namestring)];
    size_t oidlen;
-    char *name;
    char *res;
    int slen;
    int i;
@@ -493,7 +496,7 @@
    n2oid_oid[0] = 0;    /* This is magic & undocumented! */
    n2oid_oid[1] = 3;
    oidlen = sizeof(real_oid);
-    name = "kern.environment";
+    strcpy(name, namestring);    /* ANSI-C has utterly broken const */

    if (sysctl(n2oid_oid, 2, real_oid, &oidlen, name, strlen(name)) < 0) {
        warning("cannot find kern.environment base sysctl OID");
@@ -588,7 +591,7 @@
 * Only called by children of init after forking.
 */
void
-setctty(char *name)
+setctty(const char *name)
{
    int fd;

@@ -612,8 +615,8 @@
    pid_t pid, wpid;
    int status;
    sigset_t mask;
-    char *shell = _PATH_BSHELL;
-    char *argv[2];
+    const char *shell = _PATH_BSHELL;
+    const char *argv[2];
#ifdef SECURE
    struct ttyent *typ;
    struct passwd *pp;
@@ -761,7 +764,7 @@
{
    pid_t pid, wpid;
    int status;
-    char *argv[4];
+    const char *argv[4];
    struct sigaction sa;

    if ((pid = fork()) == 0) {
@@ -921,7 +924,6 @@
char **
construct_argv(char *command)
{
-    char *strk (char *);
    register int argc = 0;
    register char **argv = (char **) malloc(((strlen(command) + 1) / 2 + 1)
                        * sizeof (char *));
@@ -1429,9 +1431,8 @@
 * Note SIGALRM.
 */
void
-alrm_handler(int sig)
+alrm_handler(__attribute__((unused)) int sig)
{
-    sig;
    clang = 1;
}

@@ -1493,7 +1494,7 @@
    int status;
    int shutdowntimeout;
    size_t len;
-    char *argv[4];
+    const char *argv[4];
    struct sigaction sa;
    struct stat sb;





[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]