@@ -122,8 +122,7 @@ static void job_destroy (void *data)
122122 free (job -> nodelist );
123123 json_decref (job -> annotations );
124124 grudgeset_destroy (job -> dependencies );
125- json_decref (job -> jobspec_job );
126- json_decref (job -> jobspec_cmd );
125+ json_decref (job -> jobspec );
127126 json_decref (job -> R );
128127 json_decref (job -> exception_context );
129128 zlist_destroy (& job -> next_states );
@@ -395,19 +394,20 @@ static int jobspec_parse (struct list_ctx *ctx,
395394 const char * s )
396395{
397396 json_error_t error ;
398- json_t * jobspec = NULL ;
399- json_t * tasks , * resources , * command , * jobspec_job = NULL ;
397+ json_t * jobspec_job = NULL ;
398+ json_t * command = NULL ;
399+ json_t * tasks , * resources ;
400400 struct res_level res [3 ];
401401 int rc = -1 ;
402402
403- if (!(jobspec = json_loads (s , 0 , & error ))) {
403+ if (!(job -> jobspec = json_loads (s , 0 , & error ))) {
404404 flux_log (ctx -> h , LOG_ERR ,
405405 "%s: job %ju invalid jobspec: %s" ,
406406 __FUNCTION__ , (uintmax_t )job -> id , error .text );
407407 goto error ;
408408 }
409409
410- if (json_unpack_ex (jobspec , & error , 0 ,
410+ if (json_unpack_ex (job -> jobspec , & error , 0 ,
411411 "{s:{s:{s?:o}}}" ,
412412 "attributes" ,
413413 "system" ,
@@ -426,10 +426,9 @@ static int jobspec_parse (struct list_ctx *ctx,
426426 __FUNCTION__ , (uintmax_t )job -> id );
427427 goto nonfatal_error ;
428428 }
429- job -> jobspec_job = json_incref (jobspec_job );
430429 }
431430
432- if (json_unpack_ex (jobspec , & error , 0 ,
431+ if (json_unpack_ex (job -> jobspec , & error , 0 ,
433432 "{s:o}" ,
434433 "tasks" , & tasks ) < 0 ) {
435434 flux_log (ctx -> h , LOG_ERR ,
@@ -453,10 +452,8 @@ static int jobspec_parse (struct list_ctx *ctx,
453452 goto nonfatal_error ;
454453 }
455454
456- job -> jobspec_cmd = json_incref (command );
457-
458- if (job -> jobspec_job ) {
459- if (json_unpack_ex (job -> jobspec_job , & error , 0 ,
455+ if (jobspec_job ) {
456+ if (json_unpack_ex (jobspec_job , & error , 0 ,
460457 "{s?:s}" ,
461458 "name" , & job -> name ) < 0 ) {
462459 flux_log (ctx -> h , LOG_ERR ,
@@ -469,7 +466,7 @@ static int jobspec_parse (struct list_ctx *ctx,
469466 /* If user did not specify job.name, we treat arg 0 of the command
470467 * as the job name */
471468 if (!job -> name ) {
472- json_t * arg0 = json_array_get (job -> jobspec_cmd , 0 );
469+ json_t * arg0 = json_array_get (command , 0 );
473470 if (!arg0 || !json_is_string (arg0 )) {
474471 flux_log (ctx -> h , LOG_ERR ,
475472 "%s: job %ju invalid job command" ,
@@ -480,7 +477,7 @@ static int jobspec_parse (struct list_ctx *ctx,
480477 assert (job -> name );
481478 }
482479
483- if (json_unpack_ex (jobspec , & error , 0 ,
480+ if (json_unpack_ex (job -> jobspec , & error , 0 ,
484481 "{s:o}" ,
485482 "resources" , & resources ) < 0 ) {
486483 flux_log (ctx -> h , LOG_ERR ,
@@ -561,7 +558,6 @@ static int jobspec_parse (struct list_ctx *ctx,
561558nonfatal_error :
562559 rc = 0 ;
563560error :
564- json_decref (jobspec );
565561 return rc ;
566562}
567563
0 commit comments