Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp298837rdb; Mon, 29 Jan 2024 02:37:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyDmkAQ5ytNMqyd7+uR5Whg8N54u6D+ifcKKaB9iCqnspaz3b8J9vkF+ksU2IlVptavWZY X-Received: by 2002:a25:d0d4:0:b0:dbd:1dfd:8b8 with SMTP id h203-20020a25d0d4000000b00dbd1dfd08b8mr3753492ybg.24.1706524678132; Mon, 29 Jan 2024 02:37:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706524678; cv=pass; d=google.com; s=arc-20160816; b=mdnPijcgVLcIr+OExov058xe+D3AUpP111zMPLfSJH5fC0A682YX+Mo2kRKckIbdX4 InrbATh2vZ7aQ2m67g5baz3dZDjVACf08zNtNZZhSg9Ki0HK0dqdzSJLh9f4q18h6JFH qapuwYlwQ25Kh5TyB/uQi4Ie9VBfhAkiHeIuWvbilgA4kkVgkmc6YwhTlxNIKY0PcvkI hjhxUUZFZuxpRLg0KQaxaTwaOVcpDl7x170pBKmIxWXu/7tUvsurbtPEhphoNO/Wd8N3 yS9xNfFrBGXB6GgD99LKBY9WZ3IQ/XpleSyXDnZubf96os0nWTAZI04+7VhzQJ/K5YpB ZB9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=SN0szkxowObuhuLjknKCW5v8Er8Wqapia+3YQTLOHeI=; fh=hJWnh0VE1cXLS4c0RM2tlpFabz+RQy8ceImCgcgsg8w=; b=Vjym6W6d0U+6SXwNbJRYQX8UtV8WKiJ3/DPteDTXwTIi0esAzKYUGyzsx3JAceNz+k PYg4voXJsNJLsJWLZ8qHkCafuvCny4XCP3Z0I7LBXGMcjPEpJpiCYKRPmeJLEXQB8Juy KA4Tu6pg/7VbVIb7jOCnz1tByUbiR3SQuhUKLTqBbWdAjkbMAnCsQ+DE80ZY8pferY26 WzbAsBrOOrYVQJGoO1RomU3l74hy89ODyiKH5YO+oM14UHJEMTaFigU6leaMjV6OPmWj 5WeDszCVkzXmeaI94CJVhFRI1BUovnP0kPU9VtZnIoelk08OeMi1ZuDn3B7SW/W/azHy Nbbw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EBKp1PZV; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-42546-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gs15-20020a056214226f00b0068c461ae06fsi3286057qvb.258.2024.01.29.02.37.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 02:37:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42546-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EBKp1PZV; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-42546-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9F27C1C2202C for ; Mon, 29 Jan 2024 10:37:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0CD557867; Mon, 29 Jan 2024 10:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EBKp1PZV" Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B8A75730C for ; Mon, 29 Jan 2024 10:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706524671; cv=none; b=P9ZmQd+0h69UUE0+juCgVy/gx0pXxcPWeuy5l0ef8wXOOIoiM0KiiAO4lv1AqsyGPOjBISxKqnrzgTq/YX/e/zBXDZEWVYNefVShJOrRCLCwwEPLPsqemWdUCsQ+VtBZtqTnyoNV8WqM9Cysa+qCCFqr71yY+EGjxI9MxcQ3BKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706524671; c=relaxed/simple; bh=1wRdObldpz8Oy1Sjei4zAT/euERB6gBBuM0OId3eFno=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nbNSwSm1T3tdhr//tjuFBjDf+70BdKXU4RO8sTCHvyb+KMoVhPINQBp+D/HNUw/NPuEtwN1Gc8r5El6RlAZ9i6Vs48D8eerx3aAQhJ7svW5d8nIem13ecsh9IpOeoxTUBtEhPpnRDo9B6ZTpg/657LH3qDCMgQ1tWgTOqxgl4ac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EBKp1PZV; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-603dc95b8f3so4819637b3.2 for ; Mon, 29 Jan 2024 02:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706524668; x=1707129468; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SN0szkxowObuhuLjknKCW5v8Er8Wqapia+3YQTLOHeI=; b=EBKp1PZVxtMwI2bFqwYCSwBkt7nmeYGQaN6CO7A/8Pi8G/M0UDXjMcvtHFQQwP90Ja 6FaNOFqkcGkrFxj0qb6CcngE8OIr5Y0KNNQ/5qIlFEduSNVVb87xZ5zS4vCeRpUHt8hp rZee9sBeVSk4St26/DwDUCoaaxFIb/mDiNqcCJnYeLXGbVcgNvWqHLbzF2c8K/qQ6Izl jLlp5jTMXxh8c+qZZv2ed9v1tiMcYClfeZORDs7FCB3hNG/SO46Y7ZMftFIZpDUwa4Vb 1QkVZUObq3yYDu/YPE6GJn6BsAnyJGqzG30kG+0yghXnGuzZFUQX5KzkTTb3yga61qaJ f8RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706524668; x=1707129468; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SN0szkxowObuhuLjknKCW5v8Er8Wqapia+3YQTLOHeI=; b=Lusaz76mfHEVW7sLiUkFf09+ezn+Tc7wdMq7gZ9btCck/SOdgSXy2oW6oWXvc5aCcm LTO4G2/3lt0XLW2M6AJW4rrMfUtWA0pPLMcRk3bGAoDooHz20wJ1PQZ651j4fwy4TQiG cgMdUAVC/jlNiem0O3AR/PnfkgGY6VSwX5PY37XVDWbeWjfHnm2dmfPt2mIGGLCABhgJ F5RPNbUyc1uScZcJY49trPFwuVoDQ2vehb5IpvG+h523o1z1rCOF9izheEoyzRvslTQb ax/KzVgUljHmg9aQUbU4cedn/ZeO0SlfdO1fDSt0EiVvpvryyLvgr/m1MhPjAiXhs2ML IlEA== X-Gm-Message-State: AOJu0YxjCahSNxR1jKlmscpUC9d4nCaBfQY9Co+h6erSdsdiHhWHpr79 u9zPE+u23D9ntdpfcq9cwnzAFnjuNY7J6b+SLaObzp/XVs8UO73stXQRmLCrvbwBrrwQ7ISj6VM 4ZOwWMVCo9Ik2oP8sN+581ARmUTU7aGr5+6LzIg== X-Received: by 2002:a05:690c:d8e:b0:5e9:5538:d930 with SMTP id da14-20020a05690c0d8e00b005e95538d930mr5455648ywb.47.1706524668065; Mon, 29 Jan 2024 02:37:48 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240122124243.44002-5-brgl@bgdev.pl> <170627361652.398.12825437185563577604.tip-bot2@tip-bot2> <20240126210509.GA1212219@dev-arch.thelio-3990X> In-Reply-To: From: Bartosz Golaszewski Date: Mon, 29 Jan 2024 11:37:37 +0100 Message-ID: Subject: Re: [tip: irq/core] genirq/irq_sim: Shrink code by using cleanup helpers To: Ingo Molnar Cc: Nathan Chancellor , Thomas Gleixner , x86@kernel.org, linux-tip-commits@vger.kernel.org, maz@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds Content-Type: text/plain; charset="UTF-8" On Mon, 29 Jan 2024 at 11:13, Ingo Molnar wrote: > > > * Bartosz Golaszewski wrote: > > > On Fri, 26 Jan 2024 at 22:05, Nathan Chancellor wrote: > > > > > > > Committer: Thomas Gleixner > > > > CommitterDate: Fri, 26 Jan 2024 13:44:48 +01:00 > > > > > > > > genirq/irq_sim: Shrink code by using cleanup helpers > > > > > > > > Use the new __free() mechanism to remove all gotos and simplify the error > > > > paths. > > > > > > > > Signed-off-by: Bartosz Golaszewski > > > > Signed-off-by: Thomas Gleixner > > > > Link: https://lore.kernel.org/r/20240122124243.44002-5-brgl@bgdev.pl > > > > > > > > --- > > > > kernel/irq/irq_sim.c | 25 ++++++++++--------------- > > > > 1 file changed, 10 insertions(+), 15 deletions(-) > > > > > > > > diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c > > > > index b0d50b4..fe8fd30 100644 > > > > --- a/kernel/irq/irq_sim.c > > > > +++ b/kernel/irq/irq_sim.c > > > > @@ -4,6 +4,7 @@ > > > > * Copyright (C) 2020 Bartosz Golaszewski > > > > */ > > > > > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -163,33 +164,27 @@ static const struct irq_domain_ops irq_sim_domain_ops = { > > > > struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode, > > > > unsigned int num_irqs) > > > > { > > > > - struct irq_sim_work_ctx *work_ctx; > > > > + struct irq_sim_work_ctx *work_ctx __free(kfree) = kmalloc(sizeof(*work_ctx), GFP_KERNEL); > > > > + unsigned long *pending; > > > > > > > > - work_ctx = kmalloc(sizeof(*work_ctx), GFP_KERNEL); > > > > if (!work_ctx) > > > > - goto err_out; > > > > + return ERR_PTR(-ENOMEM); > > > > > > > > - work_ctx->pending = bitmap_zalloc(num_irqs, GFP_KERNEL); > > > > - if (!work_ctx->pending) > > > > - goto err_free_work_ctx; > > > > + pending = __free(bitmap) = bitmap_zalloc(num_irqs, GFP_KERNEL); > > > > > > Apologies if this has already been reported elsewhere. This does not > > > match what was sent and it causes the build to break with both GCC: > > > > > > > I did not see any other report. I don't know what happened here but > > this was a ninja edit as it's not what I sent. If Thomas' intention > > was to move the variable declaration and detach it from the assignment > > then 'pending' should at least be set to NULL and __free() must > > decorate the declaration. > > > > But the coding style of declaring variables when they're first > > assigned their auto-cleaned value is what Linus Torvalds explicitly > > asked me to do when I first started sending PRs containing uses of > > linux/cleanup.h. > > Ok - I've rebased tip:irq/core with the original patch. > > Do you have a reference to Linus's mail about C++ style definition > of variables? I can see the validity of the pattern in this context, > but it's explicitly against the kernel coding style AFAICS, which > I suppose prompted Thomas's edit. I'd like to have an URL handy when the > inevitable checkpatch 'fix' gets submitted. ;-) > Sure, here's one rant I was the target of: https://lore.kernel.org/all/CAHk-=wgRHiV5VSxtfXA4S6aLUmcQYEuB67u3BJPJPtuESs1JyA@mail.gmail.com/ Bartosz