Skip to content

Commit 06526bd

Browse files
garlickgrondo
authored andcommitted
sched-simple: adjust whitespace to modern norms
Problem: some sched-simple code predates modern project conventions. Break long parameter lists to one per line. Don't break short parameter lists. Begin an else on a new line after closing bracket. Indent pack parameters of nested JSON objects.
1 parent 7f68869 commit 06526bd

File tree

1 file changed

+61
-43
lines changed

1 file changed

+61
-43
lines changed

src/modules/sched-simple/sched.c

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ jobreq_create (const flux_msg_t *msg)
113113
if (job == NULL)
114114
return NULL;
115115

116-
if (flux_msg_unpack (msg, "{s:I s:i s:i s:f s:o}",
116+
if (flux_msg_unpack (msg,
117+
"{s:I s:i s:i s:f s:o}",
117118
"id", &job->id,
118119
"priority", &job->priority,
119120
"userid", &job->uid,
@@ -133,8 +134,8 @@ jobreq_create (const flux_msg_t *msg)
133134
if (json_unpack (jobspec,
134135
"{s:{s?{s?O}}}",
135136
"attributes",
136-
"system",
137-
"constraints", &job->constraints) < 0) {
137+
"system",
138+
"constraints", &job->constraints) < 0) {
138139
job->errnum = errno;
139140
goto err;
140141
}
@@ -253,15 +254,14 @@ static int try_alloc (flux_t *h, struct simple_sched *ss)
253254
flux_log_error (h, "try_alloc: rlist_free");
254255
rlist_destroy (alloc);
255256
alloc = NULL;
256-
} else if (errno == ENOSPC)
257+
}
258+
else if (errno == ENOSPC)
257259
return rc;
258260
else if (errno == EOVERFLOW)
259261
note = "unsatisfiable request";
260262
else if (fail_alloc)
261263
note = "DEBUG_FAIL_ALLOC";
262-
if (schedutil_alloc_respond_deny (ss->util_ctx,
263-
job->msg,
264-
note) < 0)
264+
if (schedutil_alloc_respond_deny (ss->util_ctx, job->msg, note) < 0)
265265
flux_log_error (h, "schedutil_alloc_respond_deny");
266266
goto out;
267267
}
@@ -272,9 +272,9 @@ static int try_alloc (flux_t *h, struct simple_sched *ss)
272272
R,
273273
"{ s:{s:s s:n s:n} }",
274274
"sched",
275-
"resource_summary", s,
276-
"reason_pending",
277-
"jobs_ahead") < 0)
275+
"resource_summary", s,
276+
"reason_pending",
277+
"jobs_ahead") < 0)
278278
flux_log_error (h, "schedutil_alloc_respond_success_pack");
279279

280280
flux_log (h, LOG_DEBUG, "alloc: %s: %s", idf58 (job->id), s);
@@ -310,8 +310,10 @@ static void annotate_reason_pending (struct simple_sched *ss)
310310
}
311311
}
312312

313-
static void prep_cb (flux_reactor_t *r, flux_watcher_t *w,
314-
int revents, void *arg)
313+
static void prep_cb (flux_reactor_t *r,
314+
flux_watcher_t *w,
315+
int revents,
316+
void *arg)
315317
{
316318
struct simple_sched *ss = arg;
317319
/* if there is at least one job to schedule, start check and idle */
@@ -322,8 +324,10 @@ static void prep_cb (flux_reactor_t *r, flux_watcher_t *w,
322324
}
323325
}
324326

325-
static void check_cb (flux_reactor_t *r, flux_watcher_t *w,
326-
int revents, void *arg)
327+
static void check_cb (flux_reactor_t *r,
328+
flux_watcher_t *w,
329+
int revents,
330+
void *arg)
327331
{
328332
struct simple_sched *ss = arg;
329333
flux_watcher_stop (ss->idle);
@@ -393,7 +397,8 @@ static void alloc_cb (flux_t *h, const flux_msg_t *msg, void *arg)
393397

394398
if (ss->alloc_limit
395399
&& zlistx_size (ss->queue) >= ss->alloc_limit) {
396-
flux_log (h, LOG_ERR,
400+
flux_log (h,
401+
LOG_ERR,
397402
"alloc received above max concurrency: %d",
398403
ss->alloc_limit);
399404
errno = EINVAL;
@@ -411,14 +416,18 @@ static void alloc_cb (flux_t *h, const flux_msg_t *msg, void *arg)
411416
jobreq_destroy (job);
412417
return;
413418
}
414-
flux_log (h, LOG_DEBUG, "req: %s: spec={%d,%d,%d} duration=%.1f",
415-
idf58 (job->id), job->jj.nnodes,
416-
job->jj.nslots, job->jj.slot_size,
417-
job->jj.duration);
419+
420+
flux_log (h,
421+
LOG_DEBUG,
422+
"req: %s: spec={%d,%d,%d} duration=%.1f",
423+
idf58 (job->id),
424+
job->jj.nnodes,
425+
job->jj.nslots,
426+
job->jj.slot_size,
427+
job->jj.duration);
428+
418429
search_dir = job->priority > FLUX_JOB_URGENCY_DEFAULT;
419-
job->handle = zlistx_insert (ss->queue,
420-
job,
421-
search_dir);
430+
job->handle = zlistx_insert (ss->queue, job, search_dir);
422431
flux_watcher_start (ss->prep);
423432
return;
424433
err:
@@ -430,9 +439,7 @@ static void alloc_cb (flux_t *h, const flux_msg_t *msg, void *arg)
430439
* If a matching job found in queue, respond to the alloc request
431440
* and "dequeue" it.
432441
*/
433-
static void cancel_cb (flux_t *h,
434-
const flux_msg_t *msg,
435-
void *arg)
442+
static void cancel_cb (flux_t *h, const flux_msg_t *msg, void *arg)
436443
{
437444
struct simple_sched *ss = arg;
438445
flux_jobid_t id;
@@ -457,9 +464,7 @@ static void cancel_cb (flux_t *h,
457464
* matching job found in queue, update the priority and reorder queue
458465
* as necessary.
459466
*/
460-
static void prioritize_cb (flux_t *h,
461-
const flux_msg_t *msg,
462-
void *arg)
467+
static void prioritize_cb (flux_t *h, const flux_msg_t *msg, void *arg)
463468
{
464469
static int min_sort_size = 4;
465470
struct simple_sched *ss = arg;
@@ -520,7 +525,8 @@ static int hello_cb (flux_t *h,
520525
uint32_t userid;
521526
double t_submit;
522527

523-
if (flux_msg_unpack (msg, "{s:I s:i s:i s:f}",
528+
if (flux_msg_unpack (msg,
529+
"{s:I s:i s:i s:f}",
524530
"id", &id,
525531
"priority", &priority,
526532
"userid", &userid,
@@ -529,7 +535,8 @@ static int hello_cb (flux_t *h,
529535
return -1;
530536
}
531537

532-
flux_log (h, LOG_DEBUG,
538+
flux_log (h,
539+
LOG_DEBUG,
533540
"hello: id=%s priority=%u userid=%u t_submit=%0.1f",
534541
idf58 (id),
535542
priority,
@@ -594,7 +601,9 @@ static void status_cb (flux_t *h, flux_msg_handler_t *mh,
594601
}
595602
rlist_destroy (rl);
596603

597-
if (flux_respond_pack (h, msg, "{s:o s:o s:o}",
604+
if (flux_respond_pack (h,
605+
msg,
606+
"{s:o s:o s:o}",
598607
"all", all,
599608
"allocated", alloc,
600609
"down", down) < 0)
@@ -622,14 +631,16 @@ static void feasibility_cb (flux_t *h,
622631
const char *errmsg = NULL;
623632
flux_error_t error;
624633

625-
if (flux_request_unpack (msg, NULL, "{s:o}",
634+
if (flux_request_unpack (msg,
635+
NULL,
636+
"{s:o}",
626637
"jobspec", &jobspec) < 0)
627638
goto err;
628639
if (json_unpack (jobspec,
629640
"{s:{s?{s?o}}}",
630641
"attributes",
631-
"system",
632-
"constraints", &constraints) < 0)
642+
"system",
643+
"constraints", &constraints) < 0)
633644
goto err;
634645

635646
if (jj_get_counts_json (jobspec, &jj) < 0) {
@@ -701,9 +712,7 @@ static void expiration_cb (flux_t *h,
701712
errno = EINVAL;
702713
goto err;
703714
}
704-
if (flux_module_debug_test (ss->h,
705-
DEBUG_EXPIRATION_UPDATE_DENY,
706-
false)) {
715+
if (flux_module_debug_test (ss->h, DEBUG_EXPIRATION_UPDATE_DENY, false)) {
707716
errmsg = "Rejecting expiration update for testing";
708717
goto err;
709718
}
@@ -722,7 +731,8 @@ static int ss_resource_update (struct simple_sched *ss, flux_future_t *f)
722731
double expiration = -1.;
723732
const char *s;
724733

725-
int rc = flux_rpc_get_unpack (f, "{s?s s?s s?F}",
734+
int rc = flux_rpc_get_unpack (f,
735+
"{s?s s?s s?F}",
726736
"up", &up,
727737
"down", &down,
728738
"expiration", &expiration);
@@ -760,7 +770,8 @@ static void acquire_continuation (flux_future_t *f, void *arg)
760770
{
761771
struct simple_sched *ss = arg;
762772
if (flux_future_get (f, NULL) < 0) {
763-
flux_log (ss->h, LOG_ERR,
773+
flux_log (ss->h,
774+
LOG_ERR,
764775
"exiting due to resource update failure: %s",
765776
future_strerror (f, errno));
766777
flux_reactor_stop (flux_get_reactor (ss->h));
@@ -780,7 +791,8 @@ static int ss_acquire_resources (flux_t *h, struct simple_sched *ss)
780791
json_t *R;
781792
json_error_t e;
782793

783-
if (!(f = flux_rpc (h, "resource.acquire",
794+
if (!(f = flux_rpc (h,
795+
"resource.acquire",
784796
NULL,
785797
FLUX_NODEID_ANY,
786798
FLUX_RPC_STREAMING))) {
@@ -789,7 +801,9 @@ static int ss_acquire_resources (flux_t *h, struct simple_sched *ss)
789801
}
790802
ss->acquire_f = f;
791803
if (flux_rpc_get_unpack (f, "{s:o}", "resources", &R) < 0) {
792-
flux_log (h, LOG_ERR, "resource.acquire failed: %s",
804+
flux_log (h,
805+
LOG_ERR,
806+
"resource.acquire failed: %s",
793807
future_strerror (f, errno));
794808
goto out;
795809
}
@@ -846,8 +860,12 @@ static int simple_sched_init (flux_t *h, struct simple_sched *ss)
846860
goto out;
847861
}
848862
s = rlist_dumps (ss->rlist);
849-
flux_log (h, LOG_DEBUG, "ready: %d of %d cores: %s",
850-
ss->rlist->avail, ss->rlist->total, s);
863+
flux_log (h,
864+
LOG_DEBUG,
865+
"ready: %d of %d cores: %s",
866+
ss->rlist->avail,
867+
ss->rlist->total,
868+
s);
851869
free (s);
852870
rc = 0;
853871
out:

0 commit comments

Comments
 (0)