[ccan] [PATCH 10/11] bytestring: Use CONST_FUNCTION

David Gibson david at gibson.dropbear.id.au
Sun Oct 12 03:43:35 AEDT 2014


From: David Gibson <dgibson at redhat.com>

The bytestring() constructor function satisfies the constraints of
CONST_FUNCTION, so mark it as such.

Signed-off-by: David Gibson <dgibson at redhat.com>
---
 ccan/bytestring/_info        | 1 +
 ccan/bytestring/bytestring.h | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ccan/bytestring/_info b/ccan/bytestring/_info
index 24d2fad..1e3f514 100644
--- a/ccan/bytestring/_info
+++ b/ccan/bytestring/_info
@@ -35,6 +35,7 @@ int main(int argc, char *argv[])
 
 	if (strcmp(argv[1], "depends") == 0) {
 		printf("ccan/array_size\n");
+		printf("ccan/compiler\n");
 		printf("ccan/memmem\n");
 		return 0;
 	}
diff --git a/ccan/bytestring/bytestring.h b/ccan/bytestring/bytestring.h
index f0dcdf9..512787d 100644
--- a/ccan/bytestring/bytestring.h
+++ b/ccan/bytestring/bytestring.h
@@ -10,6 +10,7 @@
 #include <assert.h>
 
 #include <ccan/array_size/array_size.h>
+#include <ccan/compiler/compiler.h>
 #include <ccan/memmem/memmem.h>
 
 struct bytestring {
@@ -29,7 +30,8 @@ struct bytestring {
  *	struct bytestring bs = bytestring(x, 5);
  *	assert(bs.len == 5);
  */
-static inline struct bytestring bytestring(const char *p, size_t l)
+static inline CONST_FUNCTION struct bytestring
+bytestring(const char *p, size_t l)
 {
 	struct bytestring bs = {
 		.ptr = p,
-- 
1.9.3



More information about the ccan mailing list