From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 082CC5382 for ; Mon, 28 Feb 2022 21:19:07 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id h17so6236084plc.5 for ; Mon, 28 Feb 2022 13:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=JpEWCU5sl0Tb/FD34RSH61Ey9dRKreZqOQa3CJ02luf0uqIT78+8GWNevF0TXmNO1k V82hjNGseb3oWLNgnnFwXHAFmfIF+pTCtPsXm95pt2iCzBmJFwg04njU2K1WfIC8K4PQ JYTCrkA4ACMCh2biL4u47uoOFfhnbmO/1jCCSOx3OESfK5+oDGNitg9s7NqsmIU5fVsE xsR4ABTTJUTksMDshckaPyVLHegSArBm3erCaRT01IEJkH2S1g98XNdRHKV6JZW5AanM gI9+nSzlxhKCRaqGLAQjGqwME5o9/K6faQyfblLD265MKP0MWlgdnuFxCRxjUTwlasET Zo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=pOgl5o2PVW3PIOtN6KPmbJ3wOppL0yZA8IqiOTerXU3pnia7z2UrJ8dV3sIdBy2gLx Y77f9sYEf05pAJyuyZkxOzl0uN4acjn6olXnNSGU2WyTeNIPEoBSYAXjWzXGUyEO1ZQl OByu9EfBAAzL7RnRXYAMoK9m2lSMMY2C0zbmSX4uk7TVeFhrpfXAWOskUDcO88roGHbA r80tQ7lJLYTa8rQqKdBDSNIRynOc+c3lwovtueUUzDfgtCQ7msd135Pm1dBNSqvj2Uwa ZFZaDsOajeQwgTHiUavIWkfJfBtH83qhb4L2IXWqh3atUCRHosMH+Oxpgsuo1j5G5+SK shKA== X-Gm-Message-State: AOAM533U8gwBNaorLHQJ7qm/r2y8jb41qjeHThjqiT/0wHGtULgWXune BLsjXitdR/hPKUzXZcGDNwJ7uYT+1LUbkveONNQ= X-Google-Smtp-Source: ABdhPJxYQDaw0FFWrTXZCk3OvnKpy6mSdQ8Z9qbCWYQ2FvSetamSp4Rz90y2uoGU7tjomvOtre1MYsL9s+rZuYttBVs= X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr22765912plg.47.1646083147399; Mon, 28 Feb 2022 13:19:07 -0800 (PST) Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> In-Reply-To: Reply-To: noloader@gmail.com From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Message-ID: Subject: Re: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr To: James Bottomley Cc: =?UTF-8?Q?Christian_K=C3=B6nig?= , Linus Torvalds , Jakob Koschel , alsa-devel@alsa-project.org, linux-aspeed@lists.ozlabs.org, "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , amd-gfx list , samba-technical@lists.samba.org, linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , KVM list , linux-scsi , linux-rdma , linux-staging@lists.linux.dev, "Bos, H.J." , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , Brian Johannesmeyer , Nathan Chancellor , linux-fsdevel , Christophe JAILLET , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, linux-wireless , Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , dma , linux-mediatek@lists.infradead.org, Andrew Morton , linuxppc-dev , Mike Rapoport Content-Type: text/plain; charset="UTF-8" On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff 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 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44CB1C433F5 for ; Mon, 28 Feb 2022 21:19:20 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nOnQN-0000qp-Tk; Mon, 28 Feb 2022 21:19:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nOnQM-0000qP-PH; Mon, 28 Feb 2022 21:19:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: Reply-To:In-Reply-To:References:MIME-Version:Sender:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=XplNfm8LsGKhFTiwD83nENoLUV UpUaUqbvW/HCdjhV7qAqnPWeG7FeOlJFOJoMEdvlcV8ZNqW07ZC0v6a7y8GErlVx2Jax4ivgsE56r 75owL7dTHz0iTIZ/gH2gnQrb9zSnJKNThTkTeCuTEDWt6WCKgDLCx1JgX6BK+JGKGLTA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:Reply-To:In-Reply-To: References:MIME-Version:Sender:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=iFHr7ogXj3qexABixswVcFrK1f hFhwNCncdtf6CGda1SUKSicLC7LENx7TtmZXS2h3qlkSGd3w4jAtE+J8tgiOl6WHOXiaZDYf+xCIK eVDGHD/wEKqXQWXiotiCoKtTT3KFrUxqPte/UMqmeJr5qRblqhcO/k8wIviUSdj9xykM=; Received: from mail-pl1-f180.google.com ([209.85.214.180]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.94.2) id 1nOnQH-000W1i-Px; Mon, 28 Feb 2022 21:19:17 +0000 Received: by mail-pl1-f180.google.com with SMTP id ay5so8989902plb.1; Mon, 28 Feb 2022 13:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=JpEWCU5sl0Tb/FD34RSH61Ey9dRKreZqOQa3CJ02luf0uqIT78+8GWNevF0TXmNO1k V82hjNGseb3oWLNgnnFwXHAFmfIF+pTCtPsXm95pt2iCzBmJFwg04njU2K1WfIC8K4PQ JYTCrkA4ACMCh2biL4u47uoOFfhnbmO/1jCCSOx3OESfK5+oDGNitg9s7NqsmIU5fVsE xsR4ABTTJUTksMDshckaPyVLHegSArBm3erCaRT01IEJkH2S1g98XNdRHKV6JZW5AanM gI9+nSzlxhKCRaqGLAQjGqwME5o9/K6faQyfblLD265MKP0MWlgdnuFxCRxjUTwlasET Zo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=phTAERSzYgyUAeXyuwrG3KCAc/FYxOXH07CjeCS3xCEbQvHXj0ZQ88p6/50ODgfO4+ QfXtdjKy7NONSHOPjZe2bwGK7RVeP0uopG2p9cRhCV78D70cu3rD1maC1sZPMWI5++Ya X7wLFcA/R2pDnHaVtO6mJ8hQ0CURl+dsb0mNvoED+Cl0IZ3zbP5BT3+0K7C8rT+kd3Tq UpAkugtB0oFwlpwXqWDlDJ0ORI6Sqw5Rj5m3rpLOR7HTO0xhOFZSU6eNWRU7bOIy1y2i 8FpohddhVN4C3ZKSOJp3nZUKSZZuODxbOKN4PCLoAMerkZaDFNxdS80M9c6z5+qtJ7Nr Nzwg== X-Gm-Message-State: AOAM5321gzXlt1YLZOdRXFqB2qrmy/y1MGT5cuKSQAeZ3hkGkzN55REB 3ea1SDUDjif+fadKENS/yJgqQboRlZY8dkEbEnY= X-Google-Smtp-Source: ABdhPJxYQDaw0FFWrTXZCk3OvnKpy6mSdQ8Z9qbCWYQ2FvSetamSp4Rz90y2uoGU7tjomvOtre1MYsL9s+rZuYttBVs= X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr22765912plg.47.1646083147399; Mon, 28 Feb 2022 13:19:07 -0800 (PST) MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> In-Reply-To: From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Message-ID: To: James Bottomley X-Headers-End: 1nOnQH-000W1i-Px Subject: Re: [f2fs-dev] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Cc: linux-wireless , alsa-devel@alsa-project.org, KVM list , "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , "Bos, H.J." , linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , linux-aspeed@lists.ozlabs.org, linux-scsi , linux-rdma , linux-staging@lists.linux.dev, amd-gfx list , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , linuxppc-dev , Brian Johannesmeyer , Nathan Chancellor , dma , Christophe JAILLET , Jakob Koschel , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, samba-technical@lists.samba.org, Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , linux-fsdevel , linux-mediatek@lists.infradead.org, Andrew Morton , Linus Torvalds , =?UTF-8?Q?Christian_K=C3=B6nig?= , Mike Rapoport Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94849C433EF for ; Mon, 28 Feb 2022 21:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date :From:In-Reply-To:References:MIME-Version:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WnRtahgZ7gIN82A4stx4NJIM+2IF87EFJyH8WVz5Frk=; b=ZHgO5x2xEzeWzU XZzx8/amuOhJHW0m9RpfCI5ckplIiXzlUdRH8qjm9/Zd0FqABd/TcnZwzlI8h60VEzp+QgGfo9uMy 6WKg9gTdCKflIWzMgq9HGaEg5TqTeFy92Ex76u6MxsxdtE9meupE9HPc+B5UFui1oZWybinY0mdd+ 5VVNjswi7KN+tS2XL5cxpFbg9WnPYgLTRcIdxh7fuARXlKXxP0++/DeqS/VcNdhRJky+Pmq29EuC7 iXLs7khA7ql+vQV2VsmMaDKtv2xy5AJ41txpN/DfcS5zy3TtX1pl/XDroQoIWFPs5zgRjEc/bNfMq 65ORGurgo5+F+LH8ZNqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOnQI-00E7yJ-HW; Mon, 28 Feb 2022 21:19:14 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOnQE-00E7wi-Kh; Mon, 28 Feb 2022 21:19:11 +0000 Received: by mail-pl1-x636.google.com with SMTP id z2so11805674plg.8; Mon, 28 Feb 2022 13:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=JpEWCU5sl0Tb/FD34RSH61Ey9dRKreZqOQa3CJ02luf0uqIT78+8GWNevF0TXmNO1k V82hjNGseb3oWLNgnnFwXHAFmfIF+pTCtPsXm95pt2iCzBmJFwg04njU2K1WfIC8K4PQ JYTCrkA4ACMCh2biL4u47uoOFfhnbmO/1jCCSOx3OESfK5+oDGNitg9s7NqsmIU5fVsE xsR4ABTTJUTksMDshckaPyVLHegSArBm3erCaRT01IEJkH2S1g98XNdRHKV6JZW5AanM gI9+nSzlxhKCRaqGLAQjGqwME5o9/K6faQyfblLD265MKP0MWlgdnuFxCRxjUTwlasET Zo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=v2Oy19XXDz5LEx5G7OopzZZdWcJstPbXCzeptZAoIFz7rnxJ041FrEcoYS5RbMgunS jRNiYKFCyeIarlKy1Z/DDYz7NkIyFTEMI3ifzxaD/8KSuKtLTDHDWhL6zSq49FNdMyMZ InKkPQzOXCCWZpaDHHy+1H2cx5kkqqkmowGgDBYL+oFKfS2fIpoWRNgU4AbGNKSwQUG5 U4azM0xl8nxVivTONWvJUEtsgsn9SCmf9ay4sglkkJXLJ8I3Y8U5GLBEdTaz79MAY52H e/7Cf1zvXI2cGxLtaG1sY/c39XgnNwysJQZz95q30SB7HBMMXHFgmLKp5sD6cU13dShE RXyQ== X-Gm-Message-State: AOAM532tyYVzzGoLqn5rlPU4kGRcIZFHboayZfbVWvKyKt9BeNQZ+CQx 8QCdpA/zvCbQDtXwcPJ9tbyn+do3SxfWlSdSZd0= X-Google-Smtp-Source: ABdhPJxYQDaw0FFWrTXZCk3OvnKpy6mSdQ8Z9qbCWYQ2FvSetamSp4Rz90y2uoGU7tjomvOtre1MYsL9s+rZuYttBVs= X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr22765912plg.47.1646083147399; Mon, 28 Feb 2022 13:19:07 -0800 (PST) MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> In-Reply-To: From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Message-ID: Subject: Re: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr To: James Bottomley Cc: =?UTF-8?Q?Christian_K=C3=B6nig?= , Linus Torvalds , Jakob Koschel , alsa-devel@alsa-project.org, linux-aspeed@lists.ozlabs.org, "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , amd-gfx list , samba-technical@lists.samba.org, linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , KVM list , linux-scsi , linux-rdma , linux-staging@lists.linux.dev, "Bos, H.J." , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , Brian Johannesmeyer , Nathan Chancellor , linux-fsdevel , Christophe JAILLET , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, linux-wireless , Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , dma , linux-mediatek@lists.infradead.org, Andrew Morton , linuxppc-dev , Mike Rapoport X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_131910_708679_E46D3378 X-CRM114-Status: GOOD ( 15.18 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek 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 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21318C433FE for ; Wed, 2 Mar 2022 08:49:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 438E31F09; Wed, 2 Mar 2022 09:48:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 438E31F09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1646210954; bh=aJu3pzAGqwBcM5uGpphz6KK1dUgnQBtzTRMiVYJ4NT4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Reply-To:From; b=OC4oUrgmIMRiLsBa+8A47mycrE20JqYpFmibHYdBtoEUYlqs1hOoz/3ICwFYPr1N7 kyxHVvWay8ZzetAMF4FZJ+aG5hLW1eCDkH3W69uAkmDkL9tBTht/ag+FenWZHXoWTM Q4JnAcq6ckZ6/WQB4eqfekuBQm+BSue9V+ZcWTC4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8F6F9F8065E; Wed, 2 Mar 2022 09:34:10 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2C56EF800F8; Mon, 28 Feb 2022 22:19:16 +0100 (CET) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D815FF800F8 for ; Mon, 28 Feb 2022 22:19:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D815FF800F8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JpEWCU5s" Received: by mail-pl1-x62b.google.com with SMTP id s1so11789145plg.12 for ; Mon, 28 Feb 2022 13:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=JpEWCU5sl0Tb/FD34RSH61Ey9dRKreZqOQa3CJ02luf0uqIT78+8GWNevF0TXmNO1k V82hjNGseb3oWLNgnnFwXHAFmfIF+pTCtPsXm95pt2iCzBmJFwg04njU2K1WfIC8K4PQ JYTCrkA4ACMCh2biL4u47uoOFfhnbmO/1jCCSOx3OESfK5+oDGNitg9s7NqsmIU5fVsE xsR4ABTTJUTksMDshckaPyVLHegSArBm3erCaRT01IEJkH2S1g98XNdRHKV6JZW5AanM gI9+nSzlxhKCRaqGLAQjGqwME5o9/K6faQyfblLD265MKP0MWlgdnuFxCRxjUTwlasET Zo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=HPnHQHCW7J52NqQKizLBRxeML/3AiYU4luu/YIqbaM1phQCM2Ago+WTJZd17EslFie TCTsklJXGFUuPtfDgW8uBOwdek8bnvwmFDK7NjK3TxkLCXXBj0zJNUNnpybCvFohGG7l McYzqyEpq5Z2Cv9WuVIxhKr3ch9CsnDHpdtbXiDqGK6rreqMD4V7mH9/hS/MP2Pfqbj3 Tuy6f44iwQxodaz5i6grj+Ww6RRi5YO1kpLSEFZ0hq+BkmVGRWSnBxDg1Yw78aEKBvDe 3zMum1fJSreT9z9mWQPB9WV+mEoqHjy5jfz5NPDIMf9eOnuTMac9T34sYPkdXGeH3xZu mrMQ== X-Gm-Message-State: AOAM530Tk1X7LmH3IggEBP3kGagSOaHe9XORs1XGLaxQkJdWLNu8xiIO xTq2jxc3oMSrtCmCbBEQ1toicdHIQEM4DmQMWbg= X-Google-Smtp-Source: ABdhPJxYQDaw0FFWrTXZCk3OvnKpy6mSdQ8Z9qbCWYQ2FvSetamSp4Rz90y2uoGU7tjomvOtre1MYsL9s+rZuYttBVs= X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr22765912plg.47.1646083147399; Mon, 28 Feb 2022 13:19:07 -0800 (PST) MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> In-Reply-To: From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Message-ID: Subject: Re: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr To: James Bottomley Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Wed, 02 Mar 2022 09:33:35 +0100 Cc: linux-wireless , alsa-devel@alsa-project.org, KVM list , "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , "Bos, H.J." , linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , linux-aspeed@lists.ozlabs.org, linux-scsi , linux-rdma , linux-staging@lists.linux.dev, amd-gfx list , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , linuxppc-dev , Brian Johannesmeyer , Nathan Chancellor , dma , Christophe JAILLET , Jakob Koschel , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, samba-technical@lists.samba.org, Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , linux-fsdevel , linux-mediatek@lists.infradead.org, Andrew Morton , Linus Torvalds , =?UTF-8?Q?Christian_K=C3=B6nig?= , Mike Rapoport X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff 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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32B19C433EF for ; Tue, 1 Mar 2022 04:38:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC4C010EB63; Tue, 1 Mar 2022 04:37:48 +0000 (UTC) Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA0B710E8F3; Mon, 28 Feb 2022 21:19:07 +0000 (UTC) Received: by mail-pl1-x62a.google.com with SMTP id e13so11824167plh.3; Mon, 28 Feb 2022 13:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=JpEWCU5sl0Tb/FD34RSH61Ey9dRKreZqOQa3CJ02luf0uqIT78+8GWNevF0TXmNO1k V82hjNGseb3oWLNgnnFwXHAFmfIF+pTCtPsXm95pt2iCzBmJFwg04njU2K1WfIC8K4PQ JYTCrkA4ACMCh2biL4u47uoOFfhnbmO/1jCCSOx3OESfK5+oDGNitg9s7NqsmIU5fVsE xsR4ABTTJUTksMDshckaPyVLHegSArBm3erCaRT01IEJkH2S1g98XNdRHKV6JZW5AanM gI9+nSzlxhKCRaqGLAQjGqwME5o9/K6faQyfblLD265MKP0MWlgdnuFxCRxjUTwlasET Zo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=egp74ez16sYePF6VXevNYQckygfSYtAquVgDmEOAcYIQTBoEpsLbK4H+LZuEvIwkrU o9FT+OMTU6JFOombmD7QpAKGgTSlNU1ZMoGXbGc2fh9sGa6d/e6mJq7KJEUKLIg0c65L ZHRidR5OQjdsIaGzQQaP3xbyP4jSfXIaX0pJi5knkKAjR7j+nJOgusWz3ZiwTcj94zX6 Sc8stgED187TT6TbsIhRuZADQ4kJUMxsBwx14Hm44Dry5quEJ6gUQIEXGoGEM6wwpYhm UG+DqPDmELgBxqMjU9WMf9+U/8GqS/U+/eH9TzrYq+GJRLa3D6LQBfbaX3436obcQUHQ sSuw== X-Gm-Message-State: AOAM533hTJhroOcyATPueYVwzrRJa69BtCOifI9hLOk89BiMZcyDjo5n h/X7EoVxqljkiX3sojtpI4C3sFUh6w057XaZJV4= X-Google-Smtp-Source: ABdhPJxYQDaw0FFWrTXZCk3OvnKpy6mSdQ8Z9qbCWYQ2FvSetamSp4Rz90y2uoGU7tjomvOtre1MYsL9s+rZuYttBVs= X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr22765912plg.47.1646083147399; Mon, 28 Feb 2022 13:19:07 -0800 (PST) MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> In-Reply-To: From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Message-ID: To: James Bottomley Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Tue, 01 Mar 2022 04:37:20 +0000 Subject: Re: [Nouveau] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Cc: linux-wireless , alsa-devel@alsa-project.org, KVM list , "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , "Bos, H.J." , linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , linux-aspeed@lists.ozlabs.org, linux-scsi , linux-rdma , linux-staging@lists.linux.dev, amd-gfx list , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , linuxppc-dev , Brian Johannesmeyer , Nathan Chancellor , dma , Christophe JAILLET , Jakob Koschel , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, samba-technical@lists.samba.org, Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , linux-fsdevel , linux-mediatek@lists.infradead.org, Andrew Morton , Linus Torvalds , =?UTF-8?Q?Christian_K=C3=B6nig?= , Mike Rapoport Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff 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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDA82C433FE for ; Tue, 1 Mar 2022 09:19:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E5BF10E750; Tue, 1 Mar 2022 09:19:23 +0000 (UTC) Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA0B710E8F3; Mon, 28 Feb 2022 21:19:07 +0000 (UTC) Received: by mail-pl1-x62a.google.com with SMTP id e13so11824167plh.3; Mon, 28 Feb 2022 13:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=JpEWCU5sl0Tb/FD34RSH61Ey9dRKreZqOQa3CJ02luf0uqIT78+8GWNevF0TXmNO1k V82hjNGseb3oWLNgnnFwXHAFmfIF+pTCtPsXm95pt2iCzBmJFwg04njU2K1WfIC8K4PQ JYTCrkA4ACMCh2biL4u47uoOFfhnbmO/1jCCSOx3OESfK5+oDGNitg9s7NqsmIU5fVsE xsR4ABTTJUTksMDshckaPyVLHegSArBm3erCaRT01IEJkH2S1g98XNdRHKV6JZW5AanM gI9+nSzlxhKCRaqGLAQjGqwME5o9/K6faQyfblLD265MKP0MWlgdnuFxCRxjUTwlasET Zo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=pX3FOaQ5tpG+krWAy5EzbawK39YqA5YwRZTg6hddt4E=; b=egp74ez16sYePF6VXevNYQckygfSYtAquVgDmEOAcYIQTBoEpsLbK4H+LZuEvIwkrU o9FT+OMTU6JFOombmD7QpAKGgTSlNU1ZMoGXbGc2fh9sGa6d/e6mJq7KJEUKLIg0c65L ZHRidR5OQjdsIaGzQQaP3xbyP4jSfXIaX0pJi5knkKAjR7j+nJOgusWz3ZiwTcj94zX6 Sc8stgED187TT6TbsIhRuZADQ4kJUMxsBwx14Hm44Dry5quEJ6gUQIEXGoGEM6wwpYhm UG+DqPDmELgBxqMjU9WMf9+U/8GqS/U+/eH9TzrYq+GJRLa3D6LQBfbaX3436obcQUHQ sSuw== X-Gm-Message-State: AOAM533hTJhroOcyATPueYVwzrRJa69BtCOifI9hLOk89BiMZcyDjo5n h/X7EoVxqljkiX3sojtpI4C3sFUh6w057XaZJV4= X-Google-Smtp-Source: ABdhPJxYQDaw0FFWrTXZCk3OvnKpy6mSdQ8Z9qbCWYQ2FvSetamSp4Rz90y2uoGU7tjomvOtre1MYsL9s+rZuYttBVs= X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr22765912plg.47.1646083147399; Mon, 28 Feb 2022 13:19:07 -0800 (PST) MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> In-Reply-To: From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Message-ID: To: James Bottomley Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Tue, 01 Mar 2022 09:19:22 +0000 Subject: Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Cc: linux-wireless , alsa-devel@alsa-project.org, KVM list , "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , "Bos, H.J." , linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , linux-aspeed@lists.ozlabs.org, linux-scsi , linux-rdma , linux-staging@lists.linux.dev, amd-gfx list , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , linuxppc-dev , Brian Johannesmeyer , Nathan Chancellor , dma , Christophe JAILLET , Jakob Koschel , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, samba-technical@lists.samba.org, Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , linux-fsdevel , linux-mediatek@lists.infradead.org, Andrew Morton , Linus Torvalds , =?UTF-8?Q?Christian_K=C3=B6nig?= , Mike Rapoport Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey Walton Date: Mon, 28 Feb 2022 16:18:56 -0500 Subject: [Intel-wired-lan] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr In-Reply-To: References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: On Mon, Feb 28, 2022 at 3:45 PM James Bottomley wrote: > ... > > Just from skimming over the patches to change this and experience > > with the drivers/subsystems I help to maintain I think the primary > > pattern looks something like this: > > > > list_for_each_entry(entry, head, member) { > > if (some_condition_checking(entry)) > > break; > > } > > do_something_with(entry); > > > Actually, we usually have a check to see if the loop found anything, > but in that case it should something like > > if (list_entry_is_head(entry, head, member)) { > return with error; > } > do_somethin_with(entry); Borrowing from c++, perhaps an explicit end should be used: if (list_entry_not_end(entry)) do_somethin_with(entry) It is modelled after c++ and the 'while(begin != end) {}' pattern. Jeff