Re: [PATCH v8] platform: x86: Add ChromeOS ACPI device driver

Muhammad Usama Anjum
2022-04-19T09:25:13Z

On 4/18/22 10:31 PM, Muhammad Usama Anjum wrote:
> Hi,
>
> Thanks for reviewing.
>
>>> + switch (element->type) {
>>> + case ACPI_TYPE_BUFFER:
>>> + length = element->buffer.length;
>>> + info->data = kmemdup(element->buffer.pointer,
>>> + length, GFP_KERNEL);
>>> + break;
>>> + case ACPI_TYPE_INTEGER:
>>> + length = snprintf(buffer, sizeof(buffer), "%d",
>>> + (int)element->integer.value);
>>> + info->data = kmemdup(buffer, length, GFP_KERNEL);
>>
>> You can use `kasprintf()` here, no?
>>
Yeah, I can use sasprintf() in place of snprintf() and kmemdup(). Thanks.

> Choosing kmemdup vs k*printf depends on what is being achieved. Usage of
> kmemdup indicates that only the memory is being duplicated here. While
> in case of k*printf, some transformation is done. Thus in normal memory
> duplication cases like this, the usage of kmemdup makes code more
> readable and seems preferable to me.