[OPW,kernel] Staging: rts5139: replacing an if with else
diff mbox

Message ID 20131022131332.GA8145@Ashvini
State Changes Requested
Headers show

Commit Message

Ashvini Varatharaj Oct. 22, 2013, 1:13 p.m. UTC
drivers/staging/rts5139/ms.c:2390 ms_build_l2p_tbl() error: we
previously assumed 'ms_card->segment' could be null (see line 2384)

Signed-off-by: Ashvini Varatharaj <ashvinivaratharaj@gmail.com>
---
 drivers/staging/rts5139/ms.c           |    2 +-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Rusty Russell Oct. 24, 2013, 2:25 a.m. UTC | #1
Ashvini Varatharaj <ashvinivaratharaj@gmail.com> writes:
> drivers/staging/rts5139/ms.c:2390 ms_build_l2p_tbl() error: we
> previously assumed 'ms_card->segment' could be null (see line 2384)
>
> Signed-off-by: Ashvini Varatharaj <ashvinivaratharaj@gmail.com>
> ---
>  drivers/staging/rts5139/ms.c           |    2 +-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c
> index a27f7e2..fbd688c 100644
> --- a/drivers/staging/rts5139/ms.c
> +++ b/drivers/staging/rts5139/ms.c
> @@ -2387,7 +2387,7 @@ static int ms_build_l2p_tbl(struct rts51x_chip *chip, int seg_no)
>  			TRACE_RET(chip, retval);
>  	}
>  
> -	if (ms_card->segment[seg_no].build_flag) {
> +	else {
>  		RTS51X_DEBUGP("l2p table of segment %d has been built\n",
>  			       seg_no);
>  		return STATUS_SUCCESS;

Hi Ashvini,

        This isn't quite right: if ms_card->segment is NULL, the code
above initializes it:

	if (ms_card->segment == NULL) {
		retval = ms_init_l2p_tbl(chip);
		if (retval != STATUS_SUCCESS)
			TRACE_RET(chip, retval);
	}

So it's supposed to fall through: if ms_init_l2p_tbl() returns
STATUS_SUCCESS, then it has allocated ms_card->segment.

If that error is coming from sparse, it's a false positive.  The code is
actually OK.

Cheers,
Rusty.

Patch
diff mbox

diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c
index a27f7e2..fbd688c 100644
--- a/drivers/staging/rts5139/ms.c
+++ b/drivers/staging/rts5139/ms.c
@@ -2387,7 +2387,7 @@  static int ms_build_l2p_tbl(struct rts51x_chip *chip, int seg_no)
 			TRACE_RET(chip, retval);
 	}
 
-	if (ms_card->segment[seg_no].build_flag) {
+	else {
 		RTS51X_DEBUGP("l2p table of segment %d has been built\n",
 			       seg_no);
 		return STATUS_SUCCESS;