From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] atomisp: ensure that status values > 7 are reported as errors
Date: Tue, 06 Jun 2017 17:36:19 +0000 [thread overview]
Message-ID: <5936E813.7060400@bfs.de> (raw)
In-Reply-To: <20170606163055.16445-1-colin.king@canonical.com>
Am 06.06.2017 18:30, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current code checks if a status value is greater than 7 and
> sets the status string as "ERROR" and then over writes the
> string based on the bottom 3 bits of the value. Instead, fix this by
> only checking on the bottom 3 bits of the value if the value is less
> than 8.
>
> Detected by CoverityScan, CID#1416607 ("Unused value")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> .../css2400/runtime/debug/src/ia_css_debug.c | 141 +++++++++++----------
> 1 file changed, 72 insertions(+), 69 deletions(-)
>
> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
> index bcc0d464084f..80d6fe29f30d 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
> @@ -765,28 +765,29 @@ static void debug_print_if_state(input_formatter_state_t *state, const char *id)
>
> val = state->fsm_sync_status;
>
> - if (val > 7)
> + if (val > 7) {
> fsm_sync_status_str = "ERROR";
> -
> - switch (val & 0x7) {
> - case 0:
> - fsm_sync_status_str = "idle";
> - break;
> - case 1:
> - fsm_sync_status_str = "request frame";
> - break;
> - case 2:
> - fsm_sync_status_str = "request lines";
> - break;
> - case 3:
> - fsm_sync_status_str = "request vectors";
> - break;
> - case 4:
> - fsm_sync_status_str = "send acknowledge";
> - break;
> - default:
> - fsm_sync_status_str = "unknown";
> - break;
> + } else {
> + switch (val & 0x7) {
> + case 0:
> + fsm_sync_status_str = "idle";
> + break;
> + case 1:
> + fsm_sync_status_str = "request frame";
> + break;
> + case 2:
> + fsm_sync_status_str = "request lines";
> + break;
> + case 3:
> + fsm_sync_status_str = "request vectors";
> + break;
> + case 4:
> + fsm_sync_status_str = "send acknowledge";
> + break;
> + default:
> + fsm_sync_status_str = "unknown";
> + break;
> + }
> }
>
> ia_css_debug_dtrace(2, "\t\t%-32s: (0x%X: %s)\n",
> @@ -799,34 +800,35 @@ static void debug_print_if_state(input_formatter_state_t *state, const char *id)
>
> val = state->fsm_crop_status;
>
> - if (val > 7)
> + if (val > 7) {
> fsm_crop_status_str = "ERROR";
> -
> - switch (val & 0x7) {
> - case 0:
> - fsm_crop_status_str = "idle";
> - break;
> - case 1:
> - fsm_crop_status_str = "wait line";
> - break;
> - case 2:
> - fsm_crop_status_str = "crop line";
> - break;
> - case 3:
> - fsm_crop_status_str = "crop pixel";
> - break;
> - case 4:
> - fsm_crop_status_str = "pass pixel";
> - break;
> - case 5:
> - fsm_crop_status_str = "pass line";
> - break;
> - case 6:
> - fsm_crop_status_str = "lost line";
> - break;
> - default:
> - fsm_crop_status_str = "unknown";
> - break;
> + } else {
> + switch (val & 0x7) {
> + case 0:
> + fsm_crop_status_str = "idle";
> + break;
> + case 1:
> + fsm_crop_status_str = "wait line";
> + break;
> + case 2:
> + fsm_crop_status_str = "crop line";
> + break;
> + case 3:
> + fsm_crop_status_str = "crop pixel";
> + break;
> + case 4:
> + fsm_crop_status_str = "pass pixel";
> + break;
> + case 5:
> + fsm_crop_status_str = "pass line";
> + break;
> + case 6:
> + fsm_crop_status_str = "lost line";
> + break;
> + default:
> + fsm_crop_status_str = "unknown";
> + break;
> + }
why not:
case 7:
fsm_crop_status_str = "unknown";
break;
default:
fsm_crop_status_str = "ERROR";
break;
looks more straigth to me..
same below.
less execptions, less errors
re,
wh
> }
> ia_css_debug_dtrace(2, "\t\t%-32s: (0x%X: %s)\n",
> "FSM Crop Status", val, fsm_crop_status_str);
> @@ -852,28 +854,29 @@ static void debug_print_if_state(input_formatter_state_t *state, const char *id)
>
> val = state->fsm_padding_status;
>
> - if (val > 7)
> + if (val > 7) {
> fsm_padding_status_str = "ERROR";
> -
> - switch (val & 0x7) {
> - case 0:
> - fsm_padding_status_str = "idle";
> - break;
> - case 1:
> - fsm_padding_status_str = "left pad";
> - break;
> - case 2:
> - fsm_padding_status_str = "write";
> - break;
> - case 3:
> - fsm_padding_status_str = "right pad";
> - break;
> - case 4:
> - fsm_padding_status_str = "send end of line";
> - break;
> - default:
> - fsm_padding_status_str = "unknown";
> - break;
> + } else {
> + switch (val & 0x7) {
> + case 0:
> + fsm_padding_status_str = "idle";
> + break;
> + case 1:
> + fsm_padding_status_str = "left pad";
> + break;
> + case 2:
> + fsm_padding_status_str = "write";
> + break;
> + case 3:
> + fsm_padding_status_str = "right pad";
> + break;
> + case 4:
> + fsm_padding_status_str = "send end of line";
> + break;
> + default:
> + fsm_padding_status_str = "unknown";
> + break;
> + }
> }
>
> ia_css_debug_dtrace(2, "\t\t%-32s: (0x%X: %s)\n", "FSM Padding Status",
prev parent reply other threads:[~2017-06-06 17:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 16:30 [PATCH] atomisp: ensure that status values > 7 are reported as errors Colin King
2017-06-06 16:30 ` Colin King
2017-06-06 17:36 ` walter harms [this message]
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=5936E813.7060400@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@vger.kernel.org \
/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.