daemon: Move useful is_zero function to header file.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 28 Sep 2011 13:17:53 +0000 (14:17 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 28 Sep 2011 13:52:56 +0000 (14:52 +0100)
Code motion.

daemon/daemon.h
daemon/zero.c

index 77ee628..b4f99a8 100644 (file)
@@ -191,6 +191,24 @@ extern void pulse_mode_start (void);
 extern void pulse_mode_end (void);
 extern void pulse_mode_cancel (void);
 
 extern void pulse_mode_end (void);
 extern void pulse_mode_cancel (void);
 
+/* Return true iff the buffer is all zero bytes.
+ *
+ * Note that gcc is smart enough to optimize this properly:
+ * http://stackoverflow.com/questions/1493936/faster-means-of-checking-for-an-empty-buffer-in-c/1493989#1493989
+ */
+static inline int
+is_zero (const char *buffer, size_t size)
+{
+  size_t i;
+
+  for (i = 0; i < size; ++i) {
+    if (buffer[i] != 0)
+      return 0;
+  }
+
+  return 1;
+}
+
 /* Helper for functions that need a root filesystem mounted.
  * NB. Cannot be used for FileIn functions.
  */
 /* Helper for functions that need a root filesystem mounted.
  * NB. Cannot be used for FileIn functions.
  */
index c9f6bf7..8df2298 100644 (file)
 #include "daemon.h"
 #include "actions.h"
 
 #include "daemon.h"
 #include "actions.h"
 
-/* Return true iff the buffer is all zero bytes.
- *
- * Note that gcc is smart enough to optimize this properly:
- * http://stackoverflow.com/questions/1493936/faster-means-of-checking-for-an-empty-buffer-in-c/1493989#1493989
- */
-static int
-is_zero (const char *buffer, size_t size)
-{
-  size_t i;
-
-  for (i = 0; i < size; ++i) {
-    if (buffer[i] != 0)
-      return 0;
-  }
-
-  return 1;
-}
-
 static const char zero_buf[4096];
 
 int
 static const char zero_buf[4096];
 
 int