strdup -> rc_xstrdup
This commit is contained in:
parent
3ed60d5202
commit
2569e85579
@ -131,7 +131,7 @@ int main (int argc, char **argv)
|
||||
"%s%s", isspecial_spaced ? " " : ":", value);
|
||||
} else {
|
||||
free (envs[k - 1]);
|
||||
envs[k - 1] = strdup (entry);
|
||||
envs[k - 1] = rc_xstrdup (entry);
|
||||
}
|
||||
replaced = true;
|
||||
}
|
||||
|
@ -305,21 +305,21 @@ void rc_set_service_daemon (const char *service, const char *exec,
|
||||
mexec = rc_xmalloc (sizeof (char *) * i);
|
||||
snprintf (mexec, i, "exec=%s", exec);
|
||||
} else
|
||||
mexec = strdup ("exec=");
|
||||
mexec = rc_xstrdup ("exec=");
|
||||
|
||||
if (name) {
|
||||
i = strlen (name) + 6;
|
||||
mname = rc_xmalloc (sizeof (char *) * i);
|
||||
snprintf (mname, i, "name=%s", name);
|
||||
} else
|
||||
mname = strdup ("name=");
|
||||
mname = rc_xstrdup ("name=");
|
||||
|
||||
if (pidfile) {
|
||||
i = strlen (pidfile) + 9;
|
||||
mpidfile = rc_xmalloc (sizeof (char *) * i);
|
||||
snprintf (mpidfile, i, "pidfile=%s", pidfile);
|
||||
} else
|
||||
mpidfile = strdup ("pidfile=");
|
||||
mpidfile = rc_xstrdup ("pidfile=");
|
||||
|
||||
/* Regardless, erase any existing daemon info */
|
||||
if (rc_is_dir (dirpath)) {
|
||||
@ -479,15 +479,15 @@ bool rc_service_daemons_crashed (const char *service)
|
||||
if (strcmp (token, "exec") == 0) {
|
||||
if (exec)
|
||||
free (exec);
|
||||
exec = strdup (p);
|
||||
exec = rc_xstrdup (p);
|
||||
} else if (strcmp (token, "name") == 0) {
|
||||
if (name)
|
||||
free (name);
|
||||
name = strdup (p);
|
||||
name = rc_xstrdup (p);
|
||||
} else if (strcmp (token, "pidfile") == 0) {
|
||||
if (pidfile)
|
||||
free (pidfile);
|
||||
pidfile = strdup (p);
|
||||
pidfile = rc_xstrdup (p);
|
||||
}
|
||||
}
|
||||
fclose (fp);
|
||||
|
@ -109,7 +109,7 @@ rc_depinfo_t *rc_load_deptree (void)
|
||||
depinfo = depinfo->next;
|
||||
}
|
||||
memset (depinfo, 0, sizeof (rc_depinfo_t));
|
||||
depinfo->service = strdup (e);
|
||||
depinfo->service = rc_xstrdup (e);
|
||||
deptype = NULL;
|
||||
continue;
|
||||
}
|
||||
@ -138,7 +138,7 @@ rc_depinfo_t *rc_load_deptree (void)
|
||||
}
|
||||
|
||||
if (! deptype->type)
|
||||
deptype->type = strdup (type);
|
||||
deptype->type = rc_xstrdup (type);
|
||||
|
||||
deptype->services = rc_strlist_addsort (deptype->services, e);
|
||||
}
|
||||
@ -661,7 +661,7 @@ int rc_update_deptree (bool force)
|
||||
depinfo = last_depinfo->next;
|
||||
}
|
||||
memset (depinfo, 0, sizeof (rc_depinfo_t));
|
||||
depinfo->service = strdup (service);
|
||||
depinfo->service = rc_xstrdup (service);
|
||||
}
|
||||
|
||||
/* We may not have any depends */
|
||||
@ -689,7 +689,7 @@ int rc_update_deptree (bool force)
|
||||
deptype = last_deptype->next;
|
||||
}
|
||||
memset (deptype, 0, sizeof (rc_deptype_t));
|
||||
deptype->type = strdup (type);
|
||||
deptype->type = rc_xstrdup (type);
|
||||
}
|
||||
|
||||
/* Now add each depend to our type.
|
||||
@ -730,7 +730,7 @@ int rc_update_deptree (bool force)
|
||||
last_depinfo->next = rc_xmalloc (sizeof (rc_depinfo_t));
|
||||
di = last_depinfo->next;
|
||||
memset (di, 0, sizeof (rc_depinfo_t));
|
||||
di->service = strdup (service);
|
||||
di->service = rc_xstrdup (service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -779,7 +779,7 @@ int rc_update_deptree (bool force)
|
||||
dt = last_deptype->next;
|
||||
}
|
||||
memset (dt, 0, sizeof (rc_deptype_t));
|
||||
dt->type = strdup (deppairs[i].addto);
|
||||
dt->type = rc_xstrdup (deppairs[i].addto);
|
||||
}
|
||||
|
||||
already_added = false;
|
||||
|
@ -59,7 +59,7 @@ char *rc_xstrdup (const char *str)
|
||||
if (! str)
|
||||
return (NULL);
|
||||
|
||||
value = strdup (str);
|
||||
value = rc_xstrdup (str);
|
||||
|
||||
if (value)
|
||||
return (value);
|
||||
@ -490,7 +490,7 @@ char **rc_filter_env (void)
|
||||
/* Now go through the env var and only add bits not in our PREFIX */
|
||||
sep = env_var;
|
||||
while ((token = strsep (&sep, ":"))) {
|
||||
char *np = strdup (PATH_PREFIX);
|
||||
char *np = rc_xstrdup (PATH_PREFIX);
|
||||
char *npp = np;
|
||||
char *tok = NULL;
|
||||
while ((tok = strsep (&npp, ":")))
|
||||
|
@ -136,7 +136,7 @@ char *rc_resolve_service (const char *service)
|
||||
r = readlink (file, buffer, sizeof (buffer));
|
||||
free (file);
|
||||
if (r > 0)
|
||||
return strdup (buffer);
|
||||
return (rc_xstrdup (buffer));
|
||||
}
|
||||
|
||||
snprintf (buffer, sizeof (buffer), RC_INITDIR "%s", service);
|
||||
@ -467,7 +467,7 @@ static pid_t _exec_service (const char *service, const char *arg)
|
||||
}
|
||||
|
||||
if ((pid = fork ()) == 0) {
|
||||
char *myarg = strdup (arg);
|
||||
char *myarg = rc_xstrdup (arg);
|
||||
int e = 0;
|
||||
execl (file, file, myarg, (char *) NULL);
|
||||
e = errno;
|
||||
|
@ -77,7 +77,7 @@ void rc_plugin_load (void)
|
||||
plugin = plugins = rc_xmalloc (sizeof (plugin_t));
|
||||
|
||||
memset (plugin, 0, sizeof (plugin_t));
|
||||
plugin->name = strdup (file);
|
||||
plugin->name = rc_xstrdup (file);
|
||||
plugin->handle = h;
|
||||
plugin->hook = f;
|
||||
}
|
||||
|
4
src/rc.c
4
src/rc.c
@ -161,7 +161,7 @@ static int do_e (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (message)
|
||||
fmt = strdup ("%s");
|
||||
fmt = rc_xstrdup ("%s");
|
||||
|
||||
if (strcmp (applet, "einfo") == 0)
|
||||
einfo (fmt, message);
|
||||
@ -482,7 +482,7 @@ int main (int argc, char **argv)
|
||||
char ksoftbuffer [PATH_MAX];
|
||||
|
||||
if (argv[0])
|
||||
applet = strdup (basename (argv[0]));
|
||||
applet = rc_xstrdup (basename (argv[0]));
|
||||
|
||||
if (! applet)
|
||||
eerrorx ("arguments required");
|
||||
|
@ -15,16 +15,13 @@
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef __linux__
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
#include "einfo.h"
|
||||
#include "rc.h"
|
||||
#include "rc-misc.h"
|
||||
@ -802,7 +799,7 @@ static void svc_restart (const char *service, bool deps)
|
||||
if (inactive) {
|
||||
rc_schedule_start_service (service, svc);
|
||||
ewarn ("WARNING: %s is scheduled to started when %s has started",
|
||||
svc, basename (service));
|
||||
svc, applet);
|
||||
} else
|
||||
rc_start_service (svc);
|
||||
}
|
||||
@ -821,11 +818,11 @@ static struct option longopts[] = {
|
||||
{ "help", 0, NULL, 'h'},
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
#include "_usage.c"
|
||||
// #include "_usage.c"
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
const char *service = argv[1];
|
||||
char *service = argv[1];
|
||||
int i;
|
||||
bool deps = true;
|
||||
bool doneone = false;
|
||||
@ -840,7 +837,7 @@ int main (int argc, char **argv)
|
||||
applet, strerror (errno));
|
||||
}
|
||||
|
||||
applet = strdup (basename (service));
|
||||
applet = rc_xstrdup (basename (service));
|
||||
atexit (cleanup);
|
||||
|
||||
#ifdef __linux__
|
||||
@ -956,7 +953,7 @@ int main (int argc, char **argv)
|
||||
that is being called and not any dependents */
|
||||
if (getenv ("IN_BACKGROUND")) {
|
||||
in_background = rc_is_env ("IN_BACKGROUND", "true");
|
||||
ibsave = strdup (getenv ("IN_BACKGROUND"));
|
||||
ibsave = rc_xstrdup (getenv ("IN_BACKGROUND"));
|
||||
unsetenv ("IN_BACKGROUND");
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,7 @@ int main (int argc, char **argv)
|
||||
char *cu = strsep (&p, ":");
|
||||
struct passwd *pw = NULL;
|
||||
|
||||
changeuser = strdup (cu);
|
||||
changeuser = rc_xstrdup (cu);
|
||||
if (sscanf (cu, "%d", &tid) != 1)
|
||||
pw = getpwnam (cu);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user