Re: kernel/params.c: 'err' variable "set but not used" and perhaps should be?

From: Rusty Russell
Date: Wed Jun 03 2015 - 21:59:16 EST


Tejun Heo <htejun@xxxxxxxxx> writes:
>> > @@ -853,7 +853,8 @@ static void __init version_sysfs_builtin(void)
>> > mk = locate_module_kobject(vattr->module_name);
>> > if (mk) {
>> > - err = sysfs_create_file(&mk->kobj, &vattr->mattr.attr);
>> > + if (sysfs_create_file(&mk->kobj, &vattr->mattr.attr))
>> > + doesnt_happen();
>> > kobject_uevent(&mk->kobj, KOBJ_ADD);
>> > kobject_put(&mk->kobj);
>> > }
>>
>> Arguably then, the BUG_ON macro seems more appropriate for this situation
>> than this suggested doesnt_happen macro or my original offering of a call to
>> pr_warning.
>
> It does happen. If you don't wanna roll back on failure, just wrap it
> in WARN_ON() so that there's at least some indication that something
> failed there? It'd kinda suck to be missing some interface files w/o
> any indication, wouldn't it?

Please describe the circumstances under which this function can fail.

Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/