]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
chunk: Fix signedness warnings caused by chunk_from_* macros
authorTobias Brunner <tobias@strongswan.org>
Wed, 27 Nov 2013 16:52:10 +0000 (17:52 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 27 Nov 2013 17:28:44 +0000 (18:28 +0100)
There are countless other such warnings because e.g. chunk_create() is called
with char*, but at least we prevent users from causing such warnings
inadvertently when using these macros.

src/libstrongswan/utils/chunk.h

index d3751da704394a2186be13bd2311718e633832ae..80b6237ec54e5b58503ebca68444447406a9b9d6 100644 (file)
@@ -191,17 +191,17 @@ static inline void chunk_clear(chunk_t *chunk)
 /**
  * Initialize a chunk using a char array
  */
-#define chunk_from_chars(...) ((chunk_t){(char[]){__VA_ARGS__}, sizeof((char[]){__VA_ARGS__})})
+#define chunk_from_chars(...) ((chunk_t){(u_char[]){__VA_ARGS__}, sizeof((u_char[]){__VA_ARGS__})})
 
 /**
  * Initialize a chunk to point to a thing
  */
-#define chunk_from_thing(thing) chunk_create((char*)&(thing), sizeof(thing))
+#define chunk_from_thing(thing) chunk_create((u_char*)&(thing), sizeof(thing))
 
 /**
  * Initialize a chunk from a string, not containing 0-terminator
  */
-#define chunk_from_str(str) ({char *x = (str); chunk_create(x, strlen(x));})
+#define chunk_from_str(str) ({char *x = (str); chunk_create((u_char*)x, strlen(x));})
 
 /**
  * Allocate a chunk on the heap