From: Georgiana Chelu <georgiana.chelu93@gmail.com>
To: outreachy-kernel <outreachy-kernel@googlegroups.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] media:atomisp:pci: Use error codes instead of bool variables
Date: Tue, 7 Mar 2017 23:32:41 +0200 [thread overview]
Message-ID: <CALta04xHwx5RZbGDrPV6mQmkYh_gej2ts1YHAvspSjMB85Q5cw@mail.gmail.com> (raw)
In-Reply-To: <20170307213044.GA11835@fireworks>
[-- Attachment #1: Type: text/plain, Size: 4000 bytes --]
On 7 March 2017 at 23:30, Georgiana Rodica Chelu <
georgiana.chelu93@gmail.com> wrote:
> Show the reason of failure by using the corresponding error code.
> It helps to better understand why something failed.
>
> ---
> .../css2400/runtime/isys/src/virtual_isys.c | 26
++++++++++------------
> 1 file changed, 12 insertions(+), 14 deletions(-)
>
> diff --git
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/virtual_isys.c
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/virtual_isys.c
> index f1fc3b5..cf97a9e 100644
> ---
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/virtual_isys.c
> +++
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/virtual_isys.c
> @@ -48,7 +48,7 @@ more details.
> #ifndef ISP2401
>
> #endif
> -static bool create_input_system_channel(
> +static input_system_err_t create_input_system_channel(
> input_system_cfg_t *cfg,
> bool metadata,
> input_system_channel_t *channel);
> @@ -198,7 +198,7 @@ ia_css_isys_error_t ia_css_isys_stream_create(
> return false;
>
> rc = create_input_system_channel(isys_stream_descr, false,
&(isys_stream->channel));
> - if (rc == false) {
> + if (!rc) {
> destroy_input_system_input_port(&isys_stream->input_port);
> return false;
> }
> @@ -217,7 +217,7 @@ ia_css_isys_error_t ia_css_isys_stream_create(
> /* create metadata channel */
> if (isys_stream_descr->metadata.enable) {
> rc = create_input_system_channel(isys_stream_descr, true,
&isys_stream->md_channel);
> - if (rc == false) {
> + if (!rc) {
>
destroy_input_system_input_port(&isys_stream->input_port);
>
destroy_input_system_channel(&isys_stream->channel);
> return false;
> @@ -299,12 +299,11 @@ ia_css_isys_error_t
ia_css_isys_stream_calculate_cfg(
> * Private Methods
> *
> **************************************************/
> -static bool create_input_system_channel(
> +static input_system_err_t create_input_system_channel(
> input_system_cfg_t *cfg,
> bool metadata,
> input_system_channel_t *me)
> {
> - bool rc = true;
>
> me->dma_id = ISYS2401_DMA0_ID;
>
> @@ -327,15 +326,11 @@ static bool create_input_system_channel(
> me->ibuf_ctrl_id = IBUF_CTRL2_ID;
> break;
> default:
> - rc = false;
> - break;
> + goto exit;
> }
>
> - if (!rc)
> - return false;
> -
> if (!acquire_sid(me->stream2mmio_id, &(me->stream2mmio_sid_id))) {
> - return false;
> + goto exit;
> }
>
> if (!acquire_ib_buffer(
> @@ -346,16 +341,19 @@ static bool create_input_system_channel(
> cfg->online,
> &(me->ib_buffer))) {
> release_sid(me->stream2mmio_id,
&(me->stream2mmio_sid_id));
> - return false;
> + goto exit;
> }
>
> if (!acquire_dma_channel(me->dma_id, &(me->dma_channel))) {
> release_sid(me->stream2mmio_id,
&(me->stream2mmio_sid_id));
> release_ib_buffer(&(me->ib_buffer));
> - return false;
> + goto exit;
> }
>
> - return true;
> + return INPUT_SYSTEM_ERR_NO_ERROR;
> +
> +exit:
> + return INPUT_SYSTEM_ERR_CREATE_CHANNEL_FAIL;
> }
>
> static void destroy_input_system_channel(
> --
> 2.7.4
>
Hi Julia,
I tried to follow your advice regarding the boolean variables.
The exploration of the code revealed me that there are some
error messages that can be used instead of the bool variables.
This patch is the improved version of this patch (link
<https://groups.google.com/forum/#%21topic/outreachy-kernel/l67ua6JYA9A>).
Regards,
Georgiana
[-- Attachment #2: Type: text/html, Size: 5241 bytes --]
next prev parent reply other threads:[~2017-03-07 21:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 21:30 [PATCH] media:atomisp:pci: Use error codes instead of bool variables Georgiana Rodica Chelu
2017-03-07 21:32 ` Georgiana Chelu [this message]
2017-03-07 21:39 ` [Outreachy kernel] " Julia Lawall
2017-03-07 22:02 ` Georgiana Chelu
2017-03-07 22:05 ` Julia Lawall
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=CALta04xHwx5RZbGDrPV6mQmkYh_gej2ts1YHAvspSjMB85Q5cw@mail.gmail.com \
--to=georgiana.chelu93@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=outreachy-kernel@googlegroups.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: link
Be 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.