]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DOC: htx: make it clear that htxbuf() and htx_from_buf() always return valid pointers
authorWilly Tarreau <w@1wt.eu>
Thu, 31 Jan 2019 06:21:42 +0000 (07:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 31 Jan 2019 07:07:17 +0000 (08:07 +0100)
Update the comments above htxbuf() and htx_from_buf() to make it clear
that they always return valid htx pointers so that callers know they do
not have to test them. This is only true after the fix on b_is_null()
which was the only known corner case.

This should be backported to 1.9 if the b_is_null() patch is backported.

include/common/htx.h

index 94df4bbd484b91e8091895d4ba35ab7769a778b5..36941401dc5376fd6c151f550d5a13233b570786 100644 (file)
@@ -690,7 +690,10 @@ static inline size_t buf_room_for_htx_data(const struct buffer *buf)
 
 
 /* Returns an HTX message using the buffer <buf>. Unlike htx_from_buf(), this
- * function does not update to the buffer. */
+ * function does not update to the buffer.
+ * Note that it always returns a valid pointer, either to an initialized buffer
+ * or to the empty buffer.
+ */
 static inline struct htx *htxbuf(const struct buffer *buf)
 {
        struct htx *htx;
@@ -707,10 +710,10 @@ static inline struct htx *htxbuf(const struct buffer *buf)
 
 /* Returns an HTX message using the buffer <buf>. <buf> is updated to appear as
  * full. It is the caller responsibility to call htx_to_buf() when it finish to
- * manipulate the HTX message to update <buf> accordingly.
+ * manipulate the HTX message to update <buf> accordingly. The returned pointer
+ * is always valid.
  *
- * If the caller can call htxbuf() function to avoir any update of the
- * buffer.
+ * The caller can call htxbuf() function to avoid any update of the buffer.
  */
 static inline struct htx *htx_from_buf(struct buffer *buf)
 {