From: Dan Carpenter <dan.carpenter@oracle.com> To: Vladimir Zapolskiy <vz@mleia.com> Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, Stephen Warren <swarren@wwwdotorg.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, Jonathan Hunter <jonathanh@nvidia.com>, Thierry Reding <thierry.reding@gmail.com>, linux-tegra@vger.kernel.org, Dmitry Osipenko <digetx@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, linux-media@vger.kernel.org Subject: Re: [PATCH v4 3/5] staging: Introduce NVIDIA Tegra video decoder driver Date: Mon, 13 Nov 2017 11:16:41 +0300 [thread overview] Message-ID: <20171113081641.fhmvxrxuylge3x2f@mwanda> (raw) In-Reply-To: <2c2910bc-40d4-b4ac-cdbe-b3c670a91f1b@mleia.com> On Sat, Nov 11, 2017 at 04:06:52PM +0200, Vladimir Zapolskiy wrote: > > + if (!wait_dma) > > + return 0; > > + > > + err = readl_relaxed_poll_timeout(vde->bsev + INTR_STATUS, value, > > + !(value & BSE_DMA_BUSY), 1, 100); > > + if (err) { > > + dev_err(dev, "BSEV DMA timeout\n"); > > + return err; > > + } > > + > > + return 0; > > if (err) > dev_err(dev, "BSEV DMA timeout\n"); > > return err; > > is two lines shorter. > This is fine, but just watch out because getting clever with a last if statement is a common anti-pattern. For example, you often see it where people do success handling instead of failure handling. And it leads to static checker bugs, and makes the code slightly more subtle. > > + err = tegra_vde_attach_dmabuf(dev, source->aux_fd, > > + source->aux_offset, csize, > > + &frame->aux_dmabuf_attachment, > > + &frame->aux_addr, > > + &frame->aux_sgt, > > + NULL, dma_dir); > > + if (err) > > + goto err_release_cr; > > + } > > + > > + return 0; > > if (!err) > return 0; > > and then remove a check above. > Argh!!!! Success handling. Always do failure handling, never success handling. The rest of your comments I agree with, though. regards, dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com> To: Vladimir Zapolskiy <vz@mleia.com> Cc: Dmitry Osipenko <digetx@gmail.com>, Thierry Reding <thierry.reding@gmail.com>, Jonathan Hunter <jonathanh@nvidia.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Rob Herring <robh+dt@kernel.org>, Mauro Carvalho Chehab <mchehab@kernel.org>, Stephen Warren <swarren@wwwdotorg.org>, devel@driverdev.osuosl.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH v4 3/5] staging: Introduce NVIDIA Tegra video decoder driver Date: Mon, 13 Nov 2017 11:16:41 +0300 [thread overview] Message-ID: <20171113081641.fhmvxrxuylge3x2f@mwanda> (raw) In-Reply-To: <2c2910bc-40d4-b4ac-cdbe-b3c670a91f1b@mleia.com> On Sat, Nov 11, 2017 at 04:06:52PM +0200, Vladimir Zapolskiy wrote: > > + if (!wait_dma) > > + return 0; > > + > > + err = readl_relaxed_poll_timeout(vde->bsev + INTR_STATUS, value, > > + !(value & BSE_DMA_BUSY), 1, 100); > > + if (err) { > > + dev_err(dev, "BSEV DMA timeout\n"); > > + return err; > > + } > > + > > + return 0; > > if (err) > dev_err(dev, "BSEV DMA timeout\n"); > > return err; > > is two lines shorter. > This is fine, but just watch out because getting clever with a last if statement is a common anti-pattern. For example, you often see it where people do success handling instead of failure handling. And it leads to static checker bugs, and makes the code slightly more subtle. > > + err = tegra_vde_attach_dmabuf(dev, source->aux_fd, > > + source->aux_offset, csize, > > + &frame->aux_dmabuf_attachment, > > + &frame->aux_addr, > > + &frame->aux_sgt, > > + NULL, dma_dir); > > + if (err) > > + goto err_release_cr; > > + } > > + > > + return 0; > > if (!err) > return 0; > > and then remove a check above. > Argh!!!! Success handling. Always do failure handling, never success handling. The rest of your comments I agree with, though. regards, dan carpenter
next prev parent reply other threads:[~2017-11-13 8:16 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-10-19 21:34 [PATCH v4 0/5] NVIDIA Tegra20 video decoder driver Dmitry Osipenko 2017-10-19 21:34 ` Dmitry Osipenko 2017-10-19 21:34 ` [PATCH v4 1/5] ARM: tegra: Add device tree node to describe IRAM Dmitry Osipenko 2017-10-19 21:34 ` Dmitry Osipenko [not found] ` <8ce696bc2b4b1808f6c7f7a967a3dacd954d2a4e.1508448293.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-11-11 14:18 ` Vladimir Zapolskiy 2017-11-11 14:18 ` Vladimir Zapolskiy 2017-11-12 16:28 ` Dmitry Osipenko 2017-11-12 16:28 ` Dmitry Osipenko 2017-10-19 21:34 ` [PATCH v4 2/5] media: dt: bindings: Add binding for NVIDIA Tegra Video Decoder Engine Dmitry Osipenko 2017-10-19 21:34 ` Dmitry Osipenko [not found] ` <bf5b91666229f9e46ed8c73d6ca2e4b65f86b5ab.1508448293.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-10-27 1:01 ` Rob Herring 2017-10-27 1:01 ` Rob Herring 2017-11-11 14:21 ` Vladimir Zapolskiy 2017-11-11 14:21 ` Vladimir Zapolskiy [not found] ` <6492d1af-19fa-253f-2b75-2c37ccd44cbe-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org> 2017-11-12 16:19 ` Dmitry Osipenko 2017-11-12 16:19 ` Dmitry Osipenko 2017-10-19 21:34 ` [PATCH v4 3/5] staging: Introduce NVIDIA Tegra video decoder driver Dmitry Osipenko 2017-10-19 21:34 ` Dmitry Osipenko 2017-11-11 14:06 ` Vladimir Zapolskiy 2017-11-11 14:06 ` Vladimir Zapolskiy 2017-11-12 16:17 ` Dmitry Osipenko 2017-11-12 16:17 ` Dmitry Osipenko 2017-11-13 8:16 ` Dan Carpenter [this message] 2017-11-13 8:16 ` Dan Carpenter 2017-12-04 14:04 ` Hans Verkuil 2017-12-04 14:04 ` Hans Verkuil [not found] ` <ad2da9f4-8899-7db3-493f-5aa15297c33c-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org> 2017-12-05 12:17 ` Dmitry Osipenko 2017-12-05 12:17 ` Dmitry Osipenko 2017-12-05 13:03 ` Hans Verkuil 2017-12-05 13:03 ` Hans Verkuil 2017-12-10 18:56 ` Dmitry Osipenko 2017-12-10 18:56 ` Dmitry Osipenko 2017-12-10 19:29 ` Nicolas Dufresne [not found] ` <1512934179.4281.15.camel-dDhyB4GVkw9AFePFGvp55w@public.gmane.org> 2017-12-11 0:12 ` Dmitry Osipenko 2017-12-11 0:12 ` Dmitry Osipenko 2017-12-12 12:54 ` Hans Verkuil 2017-12-12 12:54 ` Hans Verkuil 2017-10-19 21:34 ` [PATCH v4 4/5] ARM: dts: tegra20: Add video decoder node Dmitry Osipenko 2017-10-19 21:34 ` Dmitry Osipenko 2017-10-19 21:34 ` [PATCH v4 5/5] ARM: defconfig: tegra: Enable Video Decoder driver Dmitry Osipenko 2017-10-19 21:34 ` Dmitry Osipenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20171113081641.fhmvxrxuylge3x2f@mwanda \ --to=dan.carpenter@oracle.com \ --cc=devel@driverdev.osuosl.org \ --cc=devicetree@vger.kernel.org \ --cc=digetx@gmail.com \ --cc=gregkh@linuxfoundation.org \ --cc=jonathanh@nvidia.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux-tegra@vger.kernel.org \ --cc=mchehab@kernel.org \ --cc=robh+dt@kernel.org \ --cc=swarren@wwwdotorg.org \ --cc=thierry.reding@gmail.com \ --cc=vz@mleia.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.