Re: [PATCH v3 1/3] device property: Introduce fwnode_get_name()

From: Andy Shevchenko
Date: Mon Nov 26 2018 - 07:57:02 EST


On Mon, Nov 26, 2018 at 02:47:50PM +0300, Heikki Krogerus wrote:
> This helper returns the name of the node. The name is
> primarily expected to be returned from a new fwnode
> operation meant for this purpose, but when no name is
> returned, the helper will also attempt to read a device
> property "name".

> +int fwnode_get_name(const struct fwnode_handle *fwnode, char *buf, size_t len)
> +{
> + const char *name;
> + int ret;
> +
> + if (!fwnode_call_int_op(fwnode, get_name, buf, len))
> + return 0;
> +
> + ret = fwnode_call_int_op(fwnode, property_read_string_array,
> + "name", &name, 1);
> + if (!ret)
> + snprintf(buf, len, "%s", name);

What are we going to do in case snprintf has found no room for entire string?

> +
> + return ret;
> +}

--
With Best Regards,
Andy Shevchenko