From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AF21C55183 for ; Tue, 21 Apr 2020 13:58:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 413632070B for ; Tue, 21 Apr 2020 13:58:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729116AbgDUN6J (ORCPT ); Tue, 21 Apr 2020 09:58:09 -0400 Received: from netrider.rowland.org ([192.131.102.5]:38911 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729089AbgDUN6E (ORCPT ); Tue, 21 Apr 2020 09:58:04 -0400 Received: (qmail 21373 invoked by uid 500); 21 Apr 2020 09:58:02 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 21 Apr 2020 09:58:02 -0400 Date: Tue, 21 Apr 2020 09:58:02 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: NeilBrown cc: Matthew Wilcox , Randy Dunlap , , Linus Torvalds , Andrew Morton , Alexander Viro , , Dmitry Torokhov , , Jaroslav Kysela , Takashi Iwai , , Greg Kroah-Hartman , , "J. Bruce Fields" , Chuck Lever , , Johannes Berg , Dan Williams , Vishal Verma , Dave Jiang , , "Martin K. Petersen" , , , Zzy Wysm Subject: Re: [PATCH 5/9] usb: fix empty-body warning in sysfs.c In-Reply-To: <87368xskga.fsf@notabene.neil.brown.name> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Apr 2020, NeilBrown wrote: > On Sat, Apr 18 2020, Alan Stern wrote: > > > On Sat, 18 Apr 2020, 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); > > > > This is another __must_check function call. > > > > The reason we don't care if the call fails is because the file > > being created holds the USB interface string descriptor, something > > which is purely informational and hardly ever gets set (and no doubt > > gets used even less often). > > > > Is this another situation where the comment should be expanded and the > > code modified to include a useless test and cast-to-void? > > > > Or should device_create_file() not be __must_check after all? > > One approach to dealing with __must_check function that you don't want > to check is to cause failure to call > pr_debug("usb: interface descriptor file not created"); > or similar. It silences the compiler, serves as documentation, and > creates a message that is almost certainly never seen. > > This is what I did in drivers/md/md.c... > > if (mddev->kobj.sd && > sysfs_create_group(&mddev->kobj, &md_bitmap_group)) > pr_debug("pointless warning\n"); > > (I give better warnings elsewhere - I must have run out of patience by > this point). That's a decent idea. I'll do something along those lines. Alan Stern