Skip to content

Commit e463d8d

Browse files
jfsmigfvennetier
authored andcommitted
gridinit: Minor cosmetic refactoring
1 parent 8d18ce8 commit e463d8d

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

main/children.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,10 @@ _child_can_be_restarted(struct child_s *sd)
567567
int
568568
supervisor_children_get_info(const gchar *key, struct child_info_s *ci)
569569
{
570-
struct child_s *sd;
571-
572-
if (!key || !ci || !*key) {
573-
errno= EINVAL;
574-
return -1;
575-
}
570+
g_assert_nonnull(key);
571+
g_assert_nonnull(ci);
576572

573+
struct child_s *sd;
577574
if (!(sd = supervisor_get_child(key))) {
578575
errno = ENOENT;
579576
return -1;
@@ -587,10 +584,9 @@ supervisor_children_get_info(const gchar *key, struct child_info_s *ci)
587584
guint
588585
supervisor_children_killall(int sig)
589586
{
590-
guint count;
591-
struct child_s *sd;
587+
guint count = 0;
592588

593-
count = 0;
589+
struct child_s *sd;
594590
FOREACH_CHILD(sd) {
595591
if (sd->pid > 0) {
596592
if (0 == kill(sd->pid, sig))
@@ -604,10 +600,9 @@ supervisor_children_killall(int sig)
604600
guint
605601
supervisor_children_start_enabled(void *udata, supervisor_cb_f cb)
606602
{
607-
guint count, proc_count;
608-
struct child_s *sd;
603+
guint count = 0U, proc_count = 0U;
609604

610-
count = proc_count = 0U;
605+
struct child_s *sd;
611606
FOREACH_CHILD(sd) {
612607

613608
proc_count ++;
@@ -635,10 +630,9 @@ supervisor_children_start_enabled(void *udata, supervisor_cb_f cb)
635630
guint
636631
supervisor_children_mark_obsolete(void)
637632
{
638-
guint count;
639-
struct child_s *sd;
633+
guint count = 0;
640634

641-
count = 0;
635+
struct child_s *sd;
642636
FOREACH_CHILD(sd) {
643637
FLAG_SET(sd, MASK_OBSOLETE);
644638
count ++;
@@ -650,10 +644,9 @@ supervisor_children_mark_obsolete(void)
650644
guint
651645
supervisor_children_disable_obsolete(void)
652646
{
653-
guint count;
654-
struct child_s *sd;
647+
guint count = 0;
655648

656-
count = 0U;
649+
struct child_s *sd;
657650
FOREACH_CHILD(sd) {
658651
if (FLAG_HAS(sd,MASK_OBSOLETE)) {
659652
FLAG_SET(sd, MASK_DISABLED);
@@ -771,7 +764,6 @@ supervisor_children_register(const gchar *key, const gchar *cmd)
771764
/* check if the service is present */
772765
FOREACH_CHILD(sd) {
773766
if (0 == g_ascii_strcasecmp(sd->key, key)) {
774-
775767
/* the command might have changed */
776768
if (sd->command)
777769
g_free(sd->command);

main/gridinit.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ service_run_groupv(int nb_groups, char **groupv, GString *out, _on_proc_f cb)
269269
/* notifies the client the group has not been found */
270270
g_string_append_printf(out, "%d %s\n", ENOENT, what);
271271
}
272-
}
273-
else {
272+
} else {
274273
struct child_info_s ci = {};
275274
if (0 == supervisor_children_get_info(what, &ci)) {
276275
TRACE("Calback on service [%s]", what);

0 commit comments

Comments
 (0)