mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 16:34:45 +07:00
Minor optimization, drop expensive memset() ops
No need to zero out whole buffer for strlcat(), or other string check ops. Also drop a few completely useless memset() calls. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -110,7 +110,7 @@ static int missing(char *job, char *id)
|
||||
|
||||
static int do_query(char *buf, size_t len)
|
||||
{
|
||||
memset(query_buf, 0, sizeof(query_buf));
|
||||
query_buf[0] = 0;
|
||||
if (svc_parse_jobstr(buf, len, NULL, missing)) {
|
||||
memcpy(buf, query_buf, len);
|
||||
return 1;
|
||||
|
||||
+2
-2
@@ -357,7 +357,7 @@ char *lim2str(struct rlimit *rlim)
|
||||
char tmp[25];
|
||||
static char buf[42];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buf[0] = 0;
|
||||
if (RLIM_INFINITY == rlim->rlim_cur)
|
||||
snprintf(tmp, sizeof(tmp), "unlimited, ");
|
||||
else
|
||||
@@ -661,7 +661,7 @@ static int parse_conf(char *file, int is_rcsd)
|
||||
/* Prepare default limits and group for each service in /etc/finit.d/ */
|
||||
if (is_rcsd) {
|
||||
memcpy(rlimit, global_rlimit, sizeof(rlimit));
|
||||
memset(cgroup_current, 0, sizeof(cgroup_current));
|
||||
cgroup_current[0] = 0;
|
||||
}
|
||||
|
||||
_d("*** Parsing %s", file);
|
||||
|
||||
+2
-2
@@ -260,7 +260,7 @@ void print_banner(const char *heading)
|
||||
if (progress_style == PROGRESS_SILENT)
|
||||
return;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buf[0] = 0;
|
||||
strlcat(buf, "\r\e[2K", sizeof(buf));
|
||||
|
||||
if (progress_style == PROGRESS_CLASSIC) {
|
||||
@@ -339,7 +339,7 @@ void printv(const char *fmt, va_list ap)
|
||||
|
||||
delline();
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buf[0] = 0;
|
||||
len = print_timestamp(buf, sizeof(buf));
|
||||
vsnprintf(&buf[len], sizeof(buf) - len, fmt, ap);
|
||||
|
||||
|
||||
+1
-5
@@ -120,7 +120,6 @@ static int runlevel_get(int *prevlevel)
|
||||
int result;
|
||||
struct init_request rq;
|
||||
|
||||
memset(&rq, 0, sizeof(rq));
|
||||
rq.cmd = INIT_CMD_GET_RUNLEVEL;
|
||||
rq.magic = INIT_MAGIC;
|
||||
|
||||
@@ -359,7 +358,7 @@ static char *svc_cond(svc_t *svc, char *buf, size_t len)
|
||||
{
|
||||
char *cond, *conds;
|
||||
|
||||
memset(buf, 0, len);
|
||||
buf[0] = 0;
|
||||
|
||||
if (!svc->cond[0])
|
||||
return buf;
|
||||
@@ -485,10 +484,7 @@ int utmp_show(char *file)
|
||||
while ((ut = getutent())) {
|
||||
char addr[64];
|
||||
|
||||
memset(id, 0, sizeof(id));
|
||||
strlcpy(id, ut->ut_id, sizeof(id));
|
||||
|
||||
memset(user, 0, sizeof(user));
|
||||
strlcpy(user, ut->ut_user, sizeof(user));
|
||||
|
||||
sec = ut->ut_tv.tv_sec;
|
||||
|
||||
Reference in New Issue
Block a user