Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4212304ybz; Mon, 20 Apr 2020 18:22:29 -0700 (PDT) X-Google-Smtp-Source: APiQypKdfxueTde8X0dyqu4i9TQbCp5iv7TYifoLFNn0JtZ3FaKNE1xLYCxleupQDfnEzQ+3qOh+ X-Received: by 2002:a17:906:505:: with SMTP id j5mr19262484eja.13.1587432149418; Mon, 20 Apr 2020 18:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587432149; cv=none; d=google.com; s=arc-20160816; b=VyI4VDCjbG741XR+kzlAaQ12kjOYPC06PSM3l+lCNjON6TSEXetzjmJBMkxIoMbTKF PzHshK1Tw108piSCe1vKukG8w8IFRkyWSgu3hXJKUr+muk8x6IJHuNA+u6bs+qx9NNRu DoRNoR96jMxOu1AUvQAIlqb+FphVEVPBQcj4lWx5QKIlTpkdWyzP0Ofx8OTa2XRz0MGk hzBP1uOlgN6iwGw/W2SzbOTAvKd53g91y3lWKsL7xT950qZnXtZZVHH/L8i38EdxNvOi y06byDT3Yp0Z0YOpXsYYKooGWEPRwuGQ4VcmrFBhSgdJjPnSGu/OFIR8F9ltj8twi6ux cMsA== 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:references :in-reply-to:subject:cc:date:to:from; bh=z+7uJ6A4OUlsrhZbYAAhyRhZwWZ/+oAPCcy+De3oa1U=; b=pkoGJMe9X9JsRPeSluNVQCmRO9GLZ6XVlg0EMkLQ5jF7shQANsofNX3nwd0L0Ni8s0 1HDoZi/p89QD1gQYxHGurSuOhjtpI+es4buB9srJSGkQGNHDkbEBPyNoyNNKoIXrRIyK gtqCJpvv2WtIY1Cugsrr4mUrutSmK48EmR2hDvb5wzOVG5DCJxiUSq76p9izz8g8Q1MC csKsETsOVTMfycmtEygeRdh1JSaZmN8jdMgpVGS+YHFM+YTnzOKG7IWQ4+W8yDUNng/X Kqe/T38YePQEsi0Wx/CvraXShFfu6041wcptY5XCATQSV8RseoKobxxizjhhiAXiqSha vDlA== 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 n26si578732ejy.188.2020.04.20.18.22.06; Mon, 20 Apr 2020 18:22:29 -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 S1726081AbgDUBVN (ORCPT + 99 others); Mon, 20 Apr 2020 21:21:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:36846 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgDUBVN (ORCPT ); Mon, 20 Apr 2020 21:21:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 85D4EAEBE; Tue, 21 Apr 2020 01:21:09 +0000 (UTC) From: NeilBrown To: Alan Stern , Matthew Wilcox Date: Tue, 21 Apr 2020 11:20:53 +1000 Cc: 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 , Dan Williams , Vishal Verma , Dave Jiang , linux-nvdimm@lists.01.org, "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Zzy Wysm Subject: Re: [PATCH 5/9] usb: fix empty-body warning in sysfs.c In-Reply-To: References: Message-ID: <87368xskga.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 =3D usb_cache_string(udev, alt->desc.iInterface); >> > if (alt->string && device_create_file(&intf->dev, &dev_attr_interfac= e)) >> > - ; /* We don't actually care if the function fails. */ >> > + do_empty(); /* We don't actually care if the function fails. */ >> > intf->sysfs_files_created =3D 1; >> > } >>=20 >> Why not just? >>=20 >> + 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=20 > 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). NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAl6eSnUACgkQOeye3VZi gbn4EQ//WLEH1OYjzYF3ZAV16KgjXghaIeaNMOhGWUi79iqI/c9Zfe7VUDBPE5ip xTdZh+pKAubrzHjja6sbwXCEpY1XaGBeyKxl8lc/w8bsG6yMdN0n3eP7jgMucCtN U7DuAjjSjFvMLYDUBs6jhPbko+Qse3InDgyZH0gTueYI1QMmSag7EZs0xdvv6dAz NgtTQbJ7MBv3CQTg3Y+O6pMvRQbwSYuUb118jv9BH5ktkRmfJ5lP0LGfDD1d/AeR Z9oH8asOZK2ZprUXg6cuI/lf1kxFCNDGwXI9x0eDWpyt8akceeXLsxhg7Jw2KlZA Ry4UOB//Ehxq5ZtqxQAcHNzbfXJM1JaZjbyk+Im8F3q0/i2aE2/9pGvREe91rX3u gq2UO+5djv+TxKg1nZcFIHV/ycfdw4HWT6jKnYwOTahceJxkcswrRYqWBDePNqws oeWTPfUxQIIMUAYl0Zsf8EXLCqKvOmVqRI3cY2jIZHOJraynmtfL+/FRsg3PNu5T m5nSJbLvQMzITNuBTOf8BvdeAasCfR6v4RlIJYbonBJxXtUrXL7yeX0FclVpJ98+ noaE1F/eUxnG5t+n3Gr6C9ttT/avXsr7Gm7okuNwkY1vvZSoXbFPZG0VIW0SiLWY kiqSFLeEDXCaNk4yYZlcNe17qTuJiZxx4RnTkF1IykZIcQv8haE= =K7Ae -----END PGP SIGNATURE----- --=-=-=--