lkml.org 
[lkml]   [2018]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/3] ACPI: property: Add acpi_fwnode_name()
On Mon, Nov 26, 2018 at 02:47:51PM +0300, Heikki Krogerus wrote:
> This implements the get_name fwnode op for ACPI.

> +static int
> +acpi_fwnode_get_name(const struct fwnode_handle *fwnode, char *buf, size_t len)
> +{
> + struct acpi_buffer buffer;
> + acpi_handle handle;
> + acpi_status status;
> +
> + if (is_acpi_data_node(fwnode)) {
> + snprintf(buf, len, "%s", to_acpi_data_node(fwnode)->name);

Same question as per patch 1. How are we going to handle bigger strings?

> + return 0;
> + }
> +
> + handle = to_acpi_device_node(fwnode)->handle;
> +

> + buffer.length = min((size_t)ACPI_NAME_SIZE + 1, len);

Hmm...

min_t(size_t, ...) ?


> + buffer.pointer = buf;
> +
> + status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);

And same question here. Is it possible to get length of the name and check?

Perhaps, I would return -ENAMETOOLONG (-EOVERFLOW) or alike for such cases.

> + if (ACPI_FAILURE(status))
> + return -ENXIO;
> + return 0;
> +}

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2018-11-26 14:06    [W:1.763 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site