]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: chunk: make chunk_initstr() take a const string
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Jan 2016 19:45:03 +0000 (20:45 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Jan 2016 19:58:55 +0000 (20:58 +0100)
chunk_initstr() prepares a read-only chunk from a string of
fixed length. Thus it must be prepared to accept a read-only
string on the input, otherwise the caller has to force-cast
some const char* and that's not a good idea.

include/common/chunk.h

index 35bf219da22323aa3be583ab0f4a89d8f3b935da..851c7a65e23d750c22d01f7ad28443f9891b7c02 100644 (file)
@@ -77,9 +77,10 @@ static inline int chunk_initlen(struct chunk *chk, char *str, size_t size, int l
        return 1;
 }
 
-static inline void chunk_initstr(struct chunk *chk, char *str)
+/* this is only for temporary manipulation, the chunk is read-only */
+static inline void chunk_initstr(struct chunk *chk, const char *str)
 {
-       chk->str = str;
+       chk->str = (char *)str;
        chk->len = strlen(str);
        chk->size = 0;                  /* mark it read-only */
 }