2012-08-02 07:05:17

by Tang Chen

[permalink] [raw]
Subject: Re: [RFC PATCH 1/3] ACPIHP: introduce a framework for ACPI based system device hotplug

Hi,

A little problem here. :)

On 07/28/2012 07:42 PM, Jiang Liu wrote:
> +int acpihp_register_slot(struct acpihp_slot *slot)
> +{
> + int ret;
> + char *name;
> + size_t off;
> +
> + if (!slot || !slot->slot_ops)
> + return -EINVAL;
> +
> + /* Hook top level hotplug slots under ACPI root device */
> + if (slot->parent)
> + slot->dev.parent = &slot->parent->dev;
> + else
> + slot->dev.parent = &acpi_root->dev;
> +
> + ret = device_add(&slot->dev);
> + if (!ret) {
> + slot->flags |= ACPIHP_SLOT_FLAG_REGISTERED;
> + name = kmalloc(PAGE_SIZE, GFP_KERNEL);
> + if (name) {
> + off = acpihp_generate_link_name(slot, name, 0);
> + name[off - 1] = '\0';
> + sysfs_create_link(&acpihp_slot_kset->kobj,
> + &slot->dev.kobj, name);

I got a compiler warning here:
CC drivers/acpi/hotplug/core.o
drivers/acpi/hotplug/core.c: In function ?acpihp_register_slot?:
drivers/acpi/hotplug/core.c:199: warning: ignoring return value of ?sysfs_create_link?, declared with attribute warn_unused_result

Seems that we need to check the sysfs_create_link()'s return value here, and if it fails,
shall we at least give a warning message here ?

Thanks. :)


> + kfree(name);
> + }
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(acpihp_register_slot);

--
Best Regards,
Tang chen


2012-08-02 07:09:22

by Jiang Liu (Gerry)

[permalink] [raw]
Subject: Re: [RFC PATCH 1/3] ACPIHP: introduce a framework for ACPI based system device hotplug

On 2012-8-2 15:07, Tang Chen wrote:
> Hi,
>
> A little problem here. :)
>
> On 07/28/2012 07:42 PM, Jiang Liu wrote:
>> +int acpihp_register_slot(struct acpihp_slot *slot)
>> +{
>> + int ret;
>> + char *name;
>> + size_t off;
>> +
>> + if (!slot || !slot->slot_ops)
>> + return -EINVAL;
>> +
>> + /* Hook top level hotplug slots under ACPI root device */
>> + if (slot->parent)
>> + slot->dev.parent = &slot->parent->dev;
>> + else
>> + slot->dev.parent = &acpi_root->dev;
>> +
>> + ret = device_add(&slot->dev);
>> + if (!ret) {
>> + slot->flags |= ACPIHP_SLOT_FLAG_REGISTERED;
>> + name = kmalloc(PAGE_SIZE, GFP_KERNEL);
>> + if (name) {
>> + off = acpihp_generate_link_name(slot, name, 0);
>> + name[off - 1] = '\0';
>> + sysfs_create_link(&acpihp_slot_kset->kobj,
>> + &slot->dev.kobj, name);
>
> I got a compiler warning here:
> CC drivers/acpi/hotplug/core.o
> drivers/acpi/hotplug/core.c: In function ?acpihp_register_slot?:
> drivers/acpi/hotplug/core.c:199: warning: ignoring return value of ?sysfs_create_link?, declared with attribute warn_unused_result
>
> Seems that we need to check the sysfs_create_link()'s return value here, and if it fails,
> shall we at least give a warning message here ?
>
> Thanks. :)
Hi Tang,
Thanks for your comments, will fix it in next version.
Regards!
Gerry

>
>
>> + kfree(name);
>> + }
>> + }
>> +
>> + return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(acpihp_register_slot);
>