maint: ensure dd's computation of O_FULLBLOCK uses all O_ symbol names
authorJim Meyering <meyering@redhat.com>
Fri, 26 Dec 2008 11:00:18 +0000 (12:00 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 26 Dec 2008 11:08:51 +0000 (12:08 +0100)
* src/dd.c (O_FULLBLOCK): Use a more uniform initializer, that makes
it easier to extract all O_ symbol names.
* maint.mk (syntax-check-rules): Also search for sc_ rules in cfg.mk.
(sc_root_tests): Ensure that this rule sets $diff.
* cfg.mk (sc_dd_O_FLAGS): New rule.

cfg.mk
maint.mk
src/dd.c

diff --git a/cfg.mk b/cfg.mk
index 9de10ce..7e08026 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -43,3 +43,17 @@ gnulib_dir = /gnulib
 export VERBOSE = yes
 
 old_NEWS_hash = e56dee27333ad86eaf0aa7ac7d04fca5  -
+
+# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
+dd = $(srcdir)/src/dd.c
+sc_dd_O_FLAGS:
+       @rm -f $@.1 $@.2
+       @{ echo O_FULLBLOCK; perl -nle '/MAX \((O_\w*),/ and print $$1' \
+         $(dd); } | sort > $@.1
+       @{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
+         $(dd); } | sort > $@.2
+       @diff -u $@.1 $@.2 || diff=1 || diff=;                          \
+       rm -f $@.1 $@.2;                                                \
+       test "$$diff"                                                   \
+         && { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2;   \
+              exit 1; } || :
index 7a9649e..82a526c 100644 (file)
--- a/maint.mk
+++ b/maint.mk
@@ -70,7 +70,7 @@ export LC_ALL = C
 
 # Collect the names of rules starting with `sc_'.
 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
-                        $(srcdir)/$(ME))
+                        $(srcdir)/$(ME) $(srcdir)/cfg.mk)
 .PHONY: $(syntax-check-rules)
 
 local-checks-available = \
@@ -318,7 +318,7 @@ sc_root_tests:
          $(srcdir)/tests/Makefile.am                                   \
            | sed 's/^  *//;/^root_tests =/d'                           \
            | tr -s '\012\\' '  ' | fmt -1 | sort > $$t2;               \
-       diff -u $$t1 $$t2 || diff=1;                                    \
+       diff -u $$t1 $$t2 || diff=1 || diff=;                           \
        rm -f $$t1 $$t2;                                                \
        test "$$diff"                                                   \
          && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
index 7639612..d683c5d 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -279,7 +279,8 @@ enum
                    MAX (O_NOFOLLOW,
                    MAX (O_NOLINKS,
                    MAX (O_NONBLOCK,
-                   MAX (O_SYNC, O_TEXT))))))))))))) << 1)
+                   MAX (O_SYNC,
+                   MAX (O_TEXT, 0)))))))))))))) << 1)
   };
 
 /* Ensure that we didn't shift it off the end.  */