]> git.pond.sub.org Git - empserver/commitdiff
ef_verify: Fix test for undumpable tables
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 26 Jun 2016 04:33:36 +0000 (06:33 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:17 +0000 (20:09 +0200)
Virtual selectors can't be used in xundump, since we lack a setter to
go with ca_get().  verify_ca() verifies they don't occur in tables
that can be xundumped.

When I restricted xundump to tables with a file name (commit 029d929,
v4.3.28), I neglected to update the test in verify_ca().

Factor out the correct test into xundumpable().  Use it to fix
verify_ca().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/xdump.h
src/lib/common/ef_verify.c
src/lib/common/xundump.c

index cae34af740a6a71ea94acbd2864a52e8fe20a588..da3d37807d8f042bc5363d91426775c6a42d6a47 100644 (file)
@@ -27,7 +27,7 @@
  *  xdump.h: Extended dumps
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2008-2014
+ *     Markus Armbruster, 2008-2016
  */
 
 #ifndef XDUMP_H
@@ -54,6 +54,7 @@ extern void xdcolhdr(struct xdstr *, struct castr[]);
 extern void xdflds(struct xdstr *, struct castr[], void *);
 extern void xdftr(struct xdstr *, int);
 extern int xundump(FILE *, char *, int *, int);
+extern int xundumpable(int);
 extern int xundump_redundant(int, int, void *);
 
 #endif
index c96d7b0fd248240a2b136d9fae837988496acba8..041a92f0a3e30ee24aa6b8257879b6fea2cda26b 100644 (file)
@@ -40,6 +40,7 @@
 #include "misc.h"
 #include "nsc.h"
 #include "product.h"
+#include "xdump.h"
 
 static void verify_fail(int, int, struct castr *, int, char *, ...)
     ATTRIBUTE((format (printf, 5, 6)));
@@ -74,10 +75,9 @@ verify_ca(int type)
     for (i = 0; ca[i].ca_name; i++) {
        /*
         * Virtual selectors can't be used in xundump, since we lack a
-        * setter to go with ca_get().  Exception: if EFF_MEM is not
-        * set, xundump doesn't touch the table.
+        * setter to go with ca_get().
         */
-       if (CANT_HAPPEN((ef_flags(type) & EFF_MEM)
+       if (CANT_HAPPEN(xundumpable(type)
                        && ca[i].ca_get
                        && ca[i].ca_dump <= CA_DUMP_CONST))
            ca[i].ca_dump = CA_DUMP_ONLY;
index 590fdfe9515512f1f788801114dabedddaec1783..b7f8df0473b2f539cdde79cec24ad5e6469cb30f 100644 (file)
@@ -1155,8 +1155,7 @@ xuheader(FILE *fp, int expected_table)
        return gripe("expected table '%s', not '%s'",
                     ef_nameof(expected_table), name);
 
-    if (!empfile[type].file
-       || !ef_cadef(type) || !(ef_flags(type) & EFF_MEM)) {
+    if (!xundumpable(type)) {
        CANT_HAPPEN(expected_table != EF_BAD);
        return gripe("table '%s' is not permitted here", name);
     }
@@ -1168,6 +1167,16 @@ xuheader(FILE *fp, int expected_table)
     return type;
 }
 
+/*
+ * Can table @type be xundumped?
+ */
+int
+xundumpable(int type)
+{
+    return empfile[type].file && ef_cadef(type)
+       && (ef_flags(type) & EFF_MEM);
+}
+
 /*
  * Find fields in this xdump.
  * If reading human-readable syntax, read a field header line from @fp.