]> diplodocus.org Git - nmh/commitdiff
popsbr.c: Alter traverse() to check action callback's result.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 13 Aug 2017 16:54:59 +0000 (17:54 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 13 Aug 2017 16:54:59 +0000 (17:54 +0100)
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.

uip/inc.c
uip/popsbr.c

index 26cdbe5..9a72aa4 100644 (file)
--- 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;
 }
index fba1399..ca6599e 100644 (file)
@@ -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;
 }