Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp173495ybz; Tue, 21 Apr 2020 06:59:48 -0700 (PDT) X-Google-Smtp-Source: APiQypKGZuH2ylK3XvmkSgiDnY/pLrEfv9bQ4SFNH+woLz5U33aoKxypP21nT9UlTDxlHVoUcBUa X-Received: by 2002:a17:906:bb07:: with SMTP id jz7mr11317289ejb.317.1587477588391; Tue, 21 Apr 2020 06:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587477588; cv=none; d=google.com; s=arc-20160816; b=UBqkvnXbTy51I1SlMoZjZp2PUR+XBwcn4I2H+0q2pXqcR0e70U3WpyL0EvqVwBTbsh 7LAyopAw0797Hqi92myrjZbXV2inqMEGtvomVQgvy1LFUWAgViqYQO2ynMJn5bAHWJlE pP4nL/oeWmxvbPJnoQU/IvcvbbmXotsCoQ2HSr3kQKoH4FMaejcS7LBBCHx4/6St4+N/ ztVr0t6J2xaqBdPeslTx8XiXuRuE+MztSICuwDxKXTKks8GIZ5o8gpYecUxg9tqcDIJa o7fblMBu3pk1mSM5ShvXlhbZ0F2OrzIdSGm7qJRMOJOLxBtpSZP8ppEEbnj448Col3zA ADhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=Ok9MyucoAImbm5I30XHdfSrfOSPCPbwvdZHcysjQn8U=; b=JPpWcK9FjVD/mQHXvxIElNihrg4r1oCyhCs4eL1Cu2Kba4jHjult22d2jnufc+ik8G aSTXstVl1PDB1l7aeGlLoBYXOTbW9xv034IQ9c7uA8TzVEnOwW8KTzpOUPhVkX1jxDWQ /+mY5qL+eTwOgMa4LY7ELOUbRvhh2v+SH/Pm6zX9Qnuar8gMJ3nwZVHJjVuYotSPhF4g yM289bfVi3F8W/CmCE9DaFQrQ6JSg9+11qTkn/QCJUxQuWzruYdnMCMETm/FqUBtLZMh Ojgc8941hVNnj3aDpoxRHFU5H0rpHZWexyFOcWlJLrnnlMjoV76aGhw6NLTqQ+kv3hee B1yA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si1495979edy.347.2020.04.21.06.59.24; Tue, 21 Apr 2020 06:59:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbgDUN6I (ORCPT + 99 others); Tue, 21 Apr 2020 09:58:08 -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