]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
dd.c: reduce duplication in new O_FULLBLOCK-defining code
authorJim Meyering <meyering@redhat.com>
Thu, 7 Aug 2008 21:01:16 +0000 (23:01 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 9 Aug 2008 14:56:01 +0000 (16:56 +0200)
* src/dd.c (MULTIPLE_BITS_SET): New macro, extracted from...
(multiple_bits_set): ...this function.
Use a single-line, and far simpler expression (no need to list all
O_* symbols again) to validate the derived O_FULLBLOCK value.

src/dd.c

index 8c9400b11641cfe1691a5be6aff007cce75f64f4..ea852afe1957a3fe4031230f4a5847f5dae14fd5 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -278,11 +278,10 @@ enum
 /* Ensure that we didn't shift it off the end.  */
 verify (O_FULLBLOCK != 0);
 
+#define MULTIPLE_BITS_SET(i) (((i) & ((i) - 1)) != 0)
+
 /* Ensure that this is a single-bit value.  */
-verify ((O_FULLBLOCK &
-        ( O_APPEND | O_BINARY | O_DIRECT | O_DIRECTORY | O_DSYNC
-          | O_NOATIME | O_NOCTTY | O_NOFOLLOW | O_NOLINKS | O_NONBLOCK
-          | O_SYNC | O_TEXT)) == 0);
+verify ( ! MULTIPLE_BITS_SET (O_FULLBLOCK));
 
 /* Flags, for iflag="..." and oflag="...".  */
 static struct symbol_value const flags[] =
@@ -576,7 +575,7 @@ translate_charset (char const *new_trans)
 static inline bool
 multiple_bits_set (int i)
 {
-  return (i & (i - 1)) != 0;
+  return MULTIPLE_BITS_SET (i);
 }
 
 /* Print transfer statistics.  */