Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1842506lqp; Sat, 23 Mar 2024 11:02:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVo4syl/GouhzDrhkUNjruLZ3nKyhqhx5heMSc+KugHL9LK4T/8y/NMlr6Jys0Va7KbBcaEstnlGOAyGOL4lgvHrKgVAtozPZ0kGn4DSg== X-Google-Smtp-Source: AGHT+IGd0ZDonWVzGjCmuGxy6UTXoqbEmdL/9KRXVVtWLtAnt+gtdlsv/3Mu07ZIEfUTUK4Fro20 X-Received: by 2002:a17:90a:8d01:b0:2a0:3b2a:48a2 with SMTP id c1-20020a17090a8d0100b002a03b2a48a2mr2628970pjo.42.1711216928592; Sat, 23 Mar 2024 11:02:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711216928; cv=pass; d=google.com; s=arc-20160816; b=jdBs8b9+Tt1MfkPk4BIu2M8E8Y4sgjX/pDa+J1TbMjXQ0OvBmiE0jTXwupREvLBlOQ F1si2VUby/YKRvQuI/c21rHduegmIUVMf0ErIERlqV4AomzHDWf8KB2zvjdPWxtXThDy kDtNwWJs9iZ52ewbJk8FxyR8ycEZrzckoA4uHcw7O63XLKJO0LkwuftBp/BWe61h8DRi zTN437lha4j3X3RQL/I3n+41p/4xcRLgmj14WW0J4T6oH3ikWQd24sLzEyfeTr3ALz18 ohE/LJTNI570czLxdmKvYVYRiU78zS//zOZkWDOsVKamUgl0IJHa79Y3ZtIKVsq6IWtf oDFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:from :content-language:subject:references:cc:to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=PyL2Ioh4vlALFYGvyjWWeKkUOfZjj8evfoP8akboAlw=; fh=FkwAhdD1DHTePhGJgdKj2MJTR78ZtxzOM9DHgUvX9Ws=; b=xIHFpqVFKaEpGLSxJtDHC71jMIALAdmtDvqmbI+1bwlpP2MuQGx1cDCrGxdlbayaCJ qjWcW/jZAzHn7rHnyF/DlsXgLXxLx+RMceQB9iJOFEBYe4Vh3hcQZGpGBCoQPVUFCqK0 7oEEf9/sjZCQglytOqIzq5KOtPfKiBfZxNheG6NO9Cg6vd8/EfjXzkcOCyB2lTN0jtUA DYtf5Lxp9PY14kLyEx+fRgo7qAoFHjcQRo7ndHYA+PaExmZAdLxYxXle+kHd5KhZ1ASj rWI+k6oJetpFqABl+HUGHNjgn0W1G8Vt8zQwrfeoAmisZt52Tjs49hufKVuvCZ3sTTEK n9mA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=iqUrlb+e; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-112438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x4-20020a17090a788400b0029deb85c03fsi4347946pjk.178.2024.03.23.11.02.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 11:02:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=iqUrlb+e; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-112438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3BDD32823D4 for ; Sat, 23 Mar 2024 18:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10AF751C3B; Sat, 23 Mar 2024 18:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="iqUrlb+e" Received: from mout.web.de (mout.web.de [212.227.15.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67AB763D; Sat, 23 Mar 2024 18:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711216915; cv=none; b=TC3EgJPtIFpr0kkNSsUI30Ctr5nCkERm+HAYYlwf15YMCN69wGR6WIB+CLx39+1WF9kxzCiRKCexBeguZiVKil/my7fBQA8ldOXNi9p1G8jemDDG67ucp+1NWhCUaGvPTy3SIQmstsxIJS8q4jHi/ZuIRUAq3vHaCTvYvTiE2Y8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711216915; c=relaxed/simple; bh=QVrfyERZB/O2NaoOaw/v0iV9cdqwocK7uYeLZ2eGZcI=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=u2LbysP78WDoMWOtYjYkUfDzzNH+/VSDlw8g/fUfB6IT6lDncBVLNcTriurq0ZkU2bQkP6nyXbq1Iicu5oRmiMY9BenYi5XxIG8f8IaChYkRmEh0UJIAT84FDjsn+RePru3xppgJy7FZ0jgm2SQ+LY7NJ5ZnceOC90yApevl3IE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=iqUrlb+e; arc=none smtp.client-ip=212.227.15.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1711216868; x=1711821668; i=markus.elfring@web.de; bh=PyL2Ioh4vlALFYGvyjWWeKkUOfZjj8evfoP8akboAlw=; h=X-UI-Sender-Class:Date:To:Cc:References:Subject:From: In-Reply-To; b=iqUrlb+eCxD5v3QWSGMGSn0sg84vRhtzyJ14IT2t7CKw2G+CREDGrIQ8SprUgNaa qwyEKTb10wlKWY2R74C2Qr4t4B81khDw7Wvb7KRVFH97aJSitVK40ZYIERFJgX8TU kBVb7EhbklERu95cuaUo3s6xac3NmzN8U7SerzDJaEeynueSvCGPV0CSDESu3V31o tpjJpKZxZR1VORFde0mRn/viCvKxnqsC8MqrTZFPDpA4gp17NLR+g1jTovYdhzpQc rXtuydO1w20NWNKzwcpZiP7ACBbbbYuzHN9C5T6GAHpBo+IlO14tWPvBpwOYcbJPx Rlp+mSnxwFSJsQ+x0g== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.90.95]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N3Xnj-1qnudT2Rxz-00zEZM; Sat, 23 Mar 2024 19:01:08 +0100 Message-ID: Date: Sat, 23 Mar 2024 19:01:03 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Dan Williams , Peter Zijlstra , Linus Torvalds , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kernel-janitors@vger.kernel.org Cc: Bjorn Helgaas , Greg Kroah-Hartman , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Ira Weiny , Jesse Brandeburg , Jonathan Cameron , Julia Lawall , Kevin Tian , Lukas Wunner References: <65fe1f9aadf51_2690d2948f@dwillia2-mobl3.amr.corp.intel.com.notmuch> Subject: RE: [PATCH] cleanup: Add usage and style documentation Content-Language: en-GB From: Markus Elfring In-Reply-To: <65fe1f9aadf51_2690d2948f@dwillia2-mobl3.amr.corp.intel.com.notmuch> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:SmyqD010p0uwXhTqLFAT+MKBEAIrDaiCEBHBDDR0wyTqCIJfaTN hhkOvtxDEjq2pESON3LwSrVFy/5Xu2I1SsB7NG4o5ftJB7ZkZLH4LOzUVFD0uKqtgGFZMFr 8q5118J4thJ7hf5Y4Ub/QAmDfKjWBmU7udNDS7aLl6uVpMKyT8deDvoU3/NxrKA63mmdodS skuSI80wdZBvkcGZVUEnw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:dUActWliC4w=;hdeZqY0mxakffsHlGyutv6l/x6V 34T0aoeci1Pufl8ZUt98g5j4kqBglt7/6+xJLX20BZCxEPRVEyxgJOi6+vYlCX71SLR5DbsZV kxtYuforeNfBXZR5B8/IlwPock3+ibJXaH8Rjr9GScuAZA1ua+N/cfgy7K2lZHZ7Z02vYHvrC yQoXjLj93PxQGx3a/iHgoqpVkoGtMNl96sgYQK/cP4o1AKetq/43EUfZGheTq5rlryNYtK/aZ byIESvgr2hfz0z6YzqJ7cejyvDMJGoqDYWYs6rMCERlsxiupcXmxpHEiRiXdAntXoGZsAN7vL Ru+rIYBspjysvIeO/lxC0BnDKN4/ITZEygYocFdgxLCapf0Z1PqzpzRrB2rrt6rR0WO1R7wCG BfBTs6bb3NYSBo2dOrewns61D3jj1VuAjop9G4bWRiu7IQ0kLkIeObE8Q5gGlx0+5aJsp3Gpu KDlcASUKWOoo64SjR02m24SJICe5AS+7COIN3+xmM6s/EdsCWwngMUmOaguzq59TF3Q6a0drh n5Z0/7IISQ2F9Tu/FkbziUvZT253ScXShp/JR9AAJ0r0AY6894x2HXkuSpcKQZxXiSVrH9pbY vKfg5PSUUakfb019YxzC2bTQlFDOD5QRWxIQxTE6VGrIVFNbD4E3lBLk/6w60rBWVY+DbKilv 4k6FGjglKA5vGIFNCrP85/rAA3yPIeTumJWOiAEJAAv2gwrSwB2evs6ZFWlA2u1dUigQIykgf VuxVrYjlCypDlzqFSFPp0kwKucI1g43CGhcAGZZNmq8E/8RenBET09I+XJvko4X6V3AQch++o Xn7twrHuWGHtQ+rOvu6glL7ivS+wJ/1BgNqA83P6JjDoI= > DEFINE_FREE(remove_free, struct object *, if (_T) remove_free(_T)) > static int init(void) > { > struct object *obj __free(remove_free) =3D NULL; > int err; > > guard(mutex)(lock); > obj =3D alloc_add(); > > if (!obj) > return -ENOMEM; > > err =3D other_init(obj); > if (err) > return err; // remove_free() called without the lock!! > > no_free_ptr(obj); > return 0; > } You demonstrated an improvable lock granularity and a questionable combina= tion of variable scopes. > The fix for this bug is to replace the "__free(...) =3D NULL" pattern an= d > move the assignment to the declaration. > > guard(mutex)(lock); > struct object *obj __free(remove_free) =3D alloc_add(); How do you think about to describe such a source code transformation as a conversion of a variable assignment to a variable definition at the place of a resource allocation? Would you like to increase the collaboration with the macros =E2=80=9CDEFI= NE_CLASS=E2=80=9D and =E2=80=9CCLASS=E2=80=9D? https://elixir.bootlin.com/linux/v6.8.1/source/include/linux/cleanup.h#L82 Regards, Markus