public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: linux-input@atrey.karlin.mff.cuni.cz
Cc: Adrian Bunk <bunk@stusta.de>,
	vojtech@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [2.6 patch] drivers/input/serio/libps2.c: ps2_command: add a missing check
Date: Thu, 24 Mar 2005 00:13:16 -0500	[thread overview]
Message-ID: <200503240013.16573.dtor_core@ameritech.net> (raw)
In-Reply-To: <20050324031447.GY1948@stusta.de>

On Wednesday 23 March 2005 22:14, Adrian Bunk wrote:
> The Coverity checker noted that while all other uses of param in 
> ps2_command() were guarded by a NULL check, this one wasn't.
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> --- linux-2.6.12-rc1-mm1-full/drivers/input/serio/libps2.c.old	2005-03-24 02:37:08.000000000 +0100
> +++ linux-2.6.12-rc1-mm1-full/drivers/input/serio/libps2.c	2005-03-24 02:38:28.000000000 +0100
> @@ -106,9 +106,10 @@ int ps2_command(struct ps2dev *ps2dev, u
>  			command == PS2_CMD_RESET_BAT ? 1000 : 200))
>  			goto out;
>  
> -	for (i = 0; i < send; i++)
> -		if (ps2_sendbyte(ps2dev, param[i], 200))
> -			goto out;
> +	if (param)
> +		for (i = 0; i < send; i++)
> +			if (ps2_sendbyte(ps2dev, param[i], 200))
> +				goto out;
>  

I somewhat disagree on this one. If caller specified that command requires
arguments to be sent and it does not provide them I'd rather had it OOPS on
the spot. With receiving, however, caller does not really have control over
number of characters coming from the device so specifying NULL allows just
ignore whatever response there is.

-- 
Dmitry

  reply	other threads:[~2005-03-24  6:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-24  3:14 [2.6 patch] drivers/input/serio/libps2.c: ps2_command: add a missing check Adrian Bunk
2005-03-24  5:13 ` Dmitry Torokhov [this message]
2005-03-24 21:26   ` Adrian Bunk
2005-03-24 21:39     ` Dmitry Torokhov
2005-03-25  0:11       ` Adrian Bunk

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=200503240013.16573.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=bunk@stusta.de \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vojtech@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox