-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: Simplify and remove some dead code
Stop using w_obj_t as base struct for task_t and remove the unused task_new() and _task_free() functions.
- Loading branch information
Showing
2 changed files
with
5 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* task.c | ||
* Copyright (C) 2010 Adrian Perez <[email protected]> | ||
* Copyright (C) 2010-2020 Adrian Perez <[email protected]> | ||
* | ||
* Distributed under terms of the MIT license. | ||
*/ | ||
|
@@ -18,49 +18,6 @@ | |
#include <grp.h> /* setgroups() */ | ||
|
||
|
||
static void | ||
_task_free (void *taskptr) | ||
{ | ||
task_t *task = taskptr; | ||
|
||
if (task->argc) { | ||
int i; | ||
assert (task->argv); | ||
|
||
for (i = 0; i < task->argc; i++) | ||
free (task->argv[i]); | ||
|
||
task->argv = 0; | ||
task->argv = NULL; | ||
} | ||
} | ||
|
||
|
||
task_t* | ||
task_new (int argc, const char **argv) | ||
{ | ||
task_t template = TASK; | ||
task_t *task = w_obj_new (task_t); | ||
memcpy (((w_obj_t*) task) + 1, | ||
((w_obj_t*) &template) + 1, | ||
sizeof (task_t) - sizeof (w_obj_t)); | ||
|
||
if (argc) { | ||
int i; | ||
assert (argv); | ||
|
||
task->argv = w_alloc (char*, argc); | ||
for (i = 0; i < argc; i++) | ||
task->argv[i] = w_str_dup (argv[i]); | ||
task->argc = argc; | ||
} | ||
else { | ||
assert (argv == NULL); | ||
} | ||
return (task_t*) w_obj_dtor (task, _task_free); | ||
} | ||
|
||
|
||
void | ||
task_start (task_t *task) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* task.h | ||
* Copyright (C) 2010 Adrian Perez <[email protected]> | ||
* Copyright (C) 2010-2020 Adrian Perez <[email protected]> | ||
* | ||
* Distributed under terms of the MIT license. | ||
*/ | ||
|
@@ -19,9 +19,7 @@ typedef enum { | |
} action_t; | ||
|
||
|
||
W_OBJ (task_t) | ||
{ | ||
w_obj_t parent; | ||
typedef struct { | ||
pid_t pid; | ||
action_t action; | ||
int argc; | ||
|
@@ -32,12 +30,11 @@ W_OBJ (task_t) | |
time_t started; | ||
uidgid_t user; | ||
unsigned redir_errfd; | ||
}; | ||
} task_t; | ||
|
||
#define NO_PID (-1) | ||
#define NO_SIGNAL (-1) | ||
#define TASK { W_OBJ_STATIC (NULL), \ | ||
NO_PID, \ | ||
#define TASK { NO_PID, \ | ||
A_START, \ | ||
0, \ | ||
NULL, \ | ||
|