Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firewire: core: document fw_csr_string's truncation of long strings

fw_csr_string() truncates and terminates target strings like strlcpy()
does. Unlike strlcpy(), it returns the target strlen, not the source
strlen, hence users of fw_csr_string() are unable to detect truncation.

Point this behavior out in the kerneldoc comment.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+3
+3
drivers/firewire/core-device.c
··· 115 115 * 116 116 * The string is taken from a minimal ASCII text descriptor leaf after 117 117 * the immediate entry with @key. The string is zero-terminated. 118 + * An overlong string is silently truncated such that it and the 119 + * zero byte fit into @size. 120 + * 118 121 * Returns strlen(buf) or a negative error code. 119 122 */ 120 123 int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)