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 30CA3C54FCC for ; Tue, 21 Apr 2020 13:58:07 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEE4420747 for ; Tue, 21 Apr 2020 13:58:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEE4420747 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BDE26100A30E4; Tue, 21 Apr 2020 06:57:55 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.131.102.5; helo=netrider.rowland.org; envelope-from=stern+5e9eda24@rowland.harvard.edu; receiver= Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by ml01.01.org (Postfix) with SMTP id D4E91100DCB6D for ; Tue, 21 Apr 2020 06:57:53 -0700 (PDT) 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 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 Message-ID-Hash: PYBLGLQPB6LYKP3FT27UAYXT3OSLYGTF X-Message-ID-Hash: PYBLGLQPB6LYKP3FT27UAYXT3OSLYGTF X-MailFrom: stern+5e9eda24@rowland.harvard.edu X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Matthew Wilcox , Randy Dunlap , linux-kernel@vger.kernel.org, Linus Torvalds , Andrew Morton , Alexander Viro , linux-fsdevel@vger.kernel.org, Dmitry Torokhov , linux-input@vger.kernel.org, Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, "J. Bruce Fields" , Chuck Lever , linux-nfs@vger.kernel.org, Johannes Berg , linux-nvdimm@lists.01.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Zzy Wysm X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: TEXT/PLAIN; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org