Date: Wed, 19 Nov 2014 11:52:00 +0100 From: Stefan Richter Subject: 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 Reviewed-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -107,22 +107,25 @@ static int textual_leaf_to_string(const } /** * fw_csr_string() - reads a string from the configuration ROM * @directory: e.g. root directory or unit directory * @key: the key of the preceding directory entry * @buf: where to put the string * @size: size of @buf, in bytes * * 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) { const u32 *leaf = search_leaf(directory, key); if (!leaf) return -ENOENT; return textual_leaf_to_string(leaf, buf, size); } EXPORT_SYMBOL(fw_csr_string);