From: Ralph Corderoy Date: Sun, 13 Aug 2017 16:54:59 +0000 (+0100) Subject: popsbr.c: Alter traverse() to check action callback's result. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/bb0b14bdb72ac3b3fbee4ba4ff4da0b7848089bf popsbr.c: Alter traverse() to check action callback's result. The action callback returned zero, with a 1999 comment asking if it was checked. traverse() didn't check it. Change it so it does, wanting `OK' if all's well, else returning the non-OK value to traverse's caller; though that only checks for NOTOK. No functional change intended. --- diff --git a/uip/inc.c b/uip/inc.c index 26cdbe53..9a72aa45 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -920,5 +920,5 @@ pop_action(void *closure, char *s) NMH_UNUSED(closure); fprintf (pf, "%s\n", s); stop += strlen (s) + 1; - return 0; /* Is return value used? This was missing before 1999-07-15. */ + return OK; } diff --git a/uip/popsbr.c b/uip/popsbr.c index fba13992..ca6599e0 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -505,21 +505,21 @@ traverse (int (*action)(void *, char *), void *closure, const char *fmt, ...) if ((snoopstate = netsec_get_snoop(nsc))) netsec_set_snoop(nsc, 0); - for (;;) - switch (multiline ()) { - case NOTOK: - netsec_set_snoop(nsc, snoopstate); - return NOTOK; - - case DONE: - strncpy (response, buffer, sizeof(response)); - netsec_set_snoop(nsc, snoopstate); - return OK; + for (;;) { + result = multiline(); + if (result == OK) { + result = (*action)(closure, response); + if (result == OK) + continue; + } else if (result == DONE) { + strncpy(response, buffer, sizeof(response)); + result = OK; + } + break; + } - case OK: - (*action)(closure, response); - break; - } + netsec_set_snoop(nsc, snoopstate); + return result; }