Message ID | 20200418184111.13401-6-rdunlap@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fix -Wempty-body build warnings | expand |
On Sat, Apr 18, 2020 at 11:41:07AM -0700, Randy Dunlap wrote: > +++ linux-next-20200327/drivers/usb/core/sysfs.c > @@ -1263,7 +1263,7 @@ void usb_create_sysfs_intf_files(struct > if (!alt->string && !(udev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) > alt->string = usb_cache_string(udev, alt->desc.iInterface); > if (alt->string && device_create_file(&intf->dev, &dev_attr_interface)) > - ; /* We don't actually care if the function fails. */ > + do_empty(); /* We don't actually care if the function fails. */ > intf->sysfs_files_created = 1; > } Why not just? + if (alt->string) + device_create_file(&intf->dev, &dev_attr_interface);
On 4/18/20 11:44 AM, Matthew Wilcox wrote: > On Sat, Apr 18, 2020 at 11:41:07AM -0700, Randy Dunlap wrote: >> +++ linux-next-20200327/drivers/usb/core/sysfs.c >> @@ -1263,7 +1263,7 @@ void usb_create_sysfs_intf_files(struct >> if (!alt->string && !(udev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) >> alt->string = usb_cache_string(udev, alt->desc.iInterface); >> if (alt->string && device_create_file(&intf->dev, &dev_attr_interface)) >> - ; /* We don't actually care if the function fails. */ >> + do_empty(); /* We don't actually care if the function fails. */ >> intf->sysfs_files_created = 1; >> } > > Why not just? > > + if (alt->string) > + device_create_file(&intf->dev, &dev_attr_interface); > Yes, looks good. Thanks.
--- linux-next-20200327.orig/drivers/usb/core/sysfs.c +++ linux-next-20200327/drivers/usb/core/sysfs.c @@ -1263,7 +1263,7 @@ void usb_create_sysfs_intf_files(struct if (!alt->string && !(udev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) alt->string = usb_cache_string(udev, alt->desc.iInterface); if (alt->string && device_create_file(&intf->dev, &dev_attr_interface)) - ; /* We don't actually care if the function fails. */ + do_empty(); /* We don't actually care if the function fails. */ intf->sysfs_files_created = 1; }
Fix gcc empty-body warning when -Wextra is used: ../drivers/usb/core/sysfs.c: In function ‘usb_create_sysfs_intf_files’: ../drivers/usb/core/sysfs.c:1266:3: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ; /* We don't actually care if the function fails. */ ^ Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- drivers/usb/core/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)