[Openvpn-devel] buffer.h: Fix buf_substring_len() documentation

Message ID 20260812140515.107442-1-razvanc@mailbox.org
State New
Headers
Series [Openvpn-devel] buffer.h: Fix buf_substring_len() documentation |

Commit Message

Razvan Cojocaru Aug. 12, 2026, 2:05 p.m. UTC
  The documentation added in 21ef7fa8 described neither the return value
nor the not-found case correctly: the count includes the delimiter, and
a missing delimiter yields -1 rather than the buffer length.

Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
---
 src/openvpn/buffer.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index 74c84b29..85277ff8 100644
--- a/src/openvpn/buffer.h
+++ b/src/openvpn/buffer.h
@@ -1605,17 +1605,17 @@  bool buf_string_match_head_str(const struct buffer *src, const char *match);
 bool buf_string_compare_advance(struct buffer *src, const char *match);
 
 /**
- * Return the length of the next token in a buffer up to a delimiter.
+ * Return the number of bytes in a buffer up to and including a delimiter.
  *
- * Scans the buffer content for \c delim and returns the number of bytes
- * up to (but not including) the delimiter, or the full buffer length if
- * the delimiter is not found.
+ * The count includes the delimiter byte, so it can be passed straight to
+ * \c buf_copy_excess() to split off a complete record, keeping the
+ * delimiter with it.
  *
  * @param buf    The buffer to scan.
  * @param delim  Delimiter byte to search for.
  *
- * @return Number of bytes before the first occurrence of \c delim, or -1
- *         if the buffer is empty.
+ * @return Byte count including the first \c delim, or -1 if the buffer
+ *         contains no \c delim.
  */
 int buf_substring_len(const struct buffer *buf, int delim);