aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/evanix.c18
-rw-r--r--src/jobs.c19
-rw-r--r--src/meson.build2
-rw-r--r--src/queue.c4
4 files changed, 20 insertions, 23 deletions
diff --git a/src/evanix.c b/src/evanix.c
index 608345d..d46a366 100644
--- a/src/evanix.c
+++ b/src/evanix.c
@@ -66,24 +66,20 @@ static int evanix(char *expr)
{
struct queue_thread *queue_thread = NULL;
struct build_thread *build_thread = NULL;
- FILE *jobsStream = NULL; /* nix-eval-jobs stdout */
+ FILE *jobs_stream = NULL; /* nix-eval-jobs stdout */
int ret = 0;
- ret = jobs_init(&jobsStream, expr);
+ ret = jobs_init(&jobs_stream, expr);
if (ret < 0)
goto out_free;
- ret = queue_thread_new(&queue_thread, jobsStream);
- if (ret < 0) {
- free(jobsStream);
+ ret = queue_thread_new(&queue_thread, jobs_stream);
+ if (ret < 0)
goto out_free;
- }
ret = build_thread_new(&build_thread, queue_thread->queue);
- if (ret < 0) {
- free(jobsStream);
+ if (ret < 0)
goto out_free;
- }
ret = pthread_create(&queue_thread->tid, NULL, queue_thread_entry,
queue_thread);
@@ -122,8 +118,10 @@ static int evanix(char *expr)
}
out_free:
+ fclose(jobs_stream);
queue_thread_free(queue_thread);
free(build_thread);
+
return ret;
}
@@ -153,7 +151,7 @@ int opts_read(struct evanix_opts_t *opts, char **expr, int argc, char *argv[])
switch (c) {
case 'h':
printf("%s", usage);
- return -EINVAL;
+ return 0;
break;
case 'f':
opts->isflake = true;
diff --git a/src/jobs.c b/src/jobs.c
index 845df08..cb5fe3b 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -332,15 +332,16 @@ int job_read(FILE *stream, struct job **job)
goto out_free;
}
- temp = cJSON_GetObjectItemCaseSensitive(root, "system");
- if (!cJSON_IsString(temp)) {
- ret = JOB_READ_JSON_INVAL;
- goto out_free;
- }
- if (evanix_opts.system != NULL &&
- strcmp(evanix_opts.system, temp->valuestring)) {
- ret = JOB_READ_SYS_MISMATCH;
- goto out_free;
+ if (evanix_opts.system != NULL) {
+ temp = cJSON_GetObjectItemCaseSensitive(root, "system");
+ if (!cJSON_IsString(temp)) {
+ ret = JOB_READ_JSON_INVAL;
+ goto out_free;
+ }
+ if (strcmp(evanix_opts.system, temp->valuestring)) {
+ ret = JOB_READ_SYS_MISMATCH;
+ goto out_free;
+ }
}
temp = cJSON_GetObjectItemCaseSensitive(root, "name");
diff --git a/src/meson.build b/src/meson.build
index d6cfb00..b88a0da 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -19,4 +19,4 @@ e = executable(
c_args: [f'-DNIX_EVAL_JOBS_PATH=@NIX_EVAL_JOBS_PATH@'],
)
-test('evanix', e)
+test('evanix', e, args: '--help')
diff --git a/src/queue.c b/src/queue.c
index bbfbb0f..b914d0f 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -13,7 +13,6 @@
#define MAX_NIX_PKG_COUNT 200000
static int queue_push(struct queue *queue, struct job *job);
-static int queue_htab_job_merge(struct job **job, struct job **htab);
static int queue_dag_isolate(struct job *job, struct job *keep_parent,
struct job_clist *jobs, struct job **htab);
@@ -129,7 +128,7 @@ out_mutex_unlock:
* - only childrens or dependencies have parent node
* - only root node have dependencies
*/
-static int queue_htab_job_merge(struct job **job, struct job **htab)
+int queue_htab_job_merge(struct job **job, struct job **htab)
{
int ret;
struct job *jtab = NULL;
@@ -221,7 +220,6 @@ void queue_thread_free(struct queue_thread *queue_thread)
print_err("%s", strerror(errno));
free(queue_thread->queue);
- fclose(queue_thread->stream);
free(queue_thread);
}