firewire: core: document fw_csr_string's truncation of long strings
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Wed, 19 Nov 2014 10:52:00 +0000 (11:52 +0100)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Wed, 10 Dec 2014 19:53:02 +0000 (20:53 +0100)
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>
drivers/firewire/core-device.c

index 2c6d5e1..f9e3aee 100644 (file)
@@ -115,6 +115,9 @@ static int textual_leaf_to_string(const u32 *block, char *buf, size_t size)
  *
  * The string is taken from a minimal ASCII text descriptor leaf after
  * the immediate entry with @key.  The string is zero-terminated.
+ * An overlong string is silently truncated such that it and the
+ * zero byte fit into @size.
+ *
  * Returns strlen(buf) or a negative error code.
  */
 int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)