Prev: ucb1400_core: avoid calling platform_device_put() twice in ucb1400_core_probe error path
Next: [PATCH 0/2] perf: symbol offset breakage with separated debug
From: Valdis.Kletnieks on 3 Aug 2010 07:30 On Mon, 02 Aug 2010 21:26:28 PDT, "Justin P. Mattock" said: > diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c > if (alt->string) > - retval = device_create_file(&intf->dev, &dev_attr_interface); > + device_create_file(&intf->dev, &dev_attr_interface); > intf->sysfs_files_created = 1; > return 0; What should the code do if device_create_file() manages to fail? Yes, ignoring the return value is one option, but is it the best one? 'return ret;' might be another one. Somebody who understands this code and has more caffeine than me should look this over. (Nothing personal Justin - it's just my opinion that *anytime* we have a patch that remove a check for a return code, it needs to justify that ignoring the return code is appropriate).
From: Valdis.Kletnieks on 3 Aug 2010 11:20
On Tue, 03 Aug 2010 10:29:52 EDT, Alan Stern said: > On Tue, 3 Aug 2010 Valdis.Kletnieks(a)vt.edu wrote: > > > On Mon, 02 Aug 2010 21:26:28 PDT, "Justin P. Mattock" said: > > > diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c > > > > > if (alt->string) > > > - retval = device_create_file(&intf->dev, &dev_attr_interface); > > > + device_create_file(&intf->dev, &dev_attr_interface); > > > intf->sysfs_files_created = 1; > > > return 0; > > Justin, did you try compiling your new code? Those unused values are > there because device_create_file is declared as __must_check. > > > What should the code do if device_create_file() manages to fail? Yes, ignoring > > the return value is one option, but is it the best one? 'return ret;' might be > > another one. Somebody who understands this code and has more caffeine than me > > should look this over. > > Failure to create a file in sysfs is almost never fatal and usually not > even dangerous. Ignoring the error is generally better than failing > the entire operation. Then why the __must_check attribute if it's usually ignorable? I thought that was reserved for functions that you damned sight better well check for errors because bad things are afoot otherwise? |