public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Quentin Lambert <lambert.quentin@gmail.com>
Cc: Nagalakshmi Nandigama <nagalakshmi.nandigama@avagotech.com>,
	Praveen Krishnamoorthy <praveen.krishnamoorthy@avagotech.com>,
	Sreekanth Reddy <sreekanth.reddy@avagotech.com>,
	Abhijit Mahajan <abhijit.mahajan@avagotech.com>,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	MPT-FusionLinux.pdl@avagotech.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] [SCSI] mpt2sas: Convert non-returned local variable to boolean when relevant
Date: Wed, 17 Dec 2014 10:52:40 -0800	[thread overview]
Message-ID: <1418842360.14140.29.camel@perches.com> (raw)
In-Reply-To: <20141217145618.GA2812@sloth>

On Wed, 2014-12-17 at 15:56 +0100, Quentin Lambert wrote:
> This patch was produced using Coccinelle. A simplified version of the
> semantic patch is:

[...]

Interesting.

Some of these conversions show what I think is
relatively poor logic.  For instance:

> diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
[]
> @@ -1414,10 +1414,10 @@ _base_enable_msix(struct MPT2SAS_ADAPTER *ioc)
>  	struct msix_entry *entries, *a;
>  	int r;
>  	int i;
> -	u8 try_msix = 0;
> +	bool try_msix = false;
>  
>  	if (msix_disable == -1 || msix_disable == 0)
> -		try_msix = 1;
> +		try_msix = true;
>  
>  	if (!try_msix)
>  		goto try_ioapic;

This might as well remove the try_msix variable
and become:

	if (msix_disable != -1 && msix_disable != 0)
		goto try_ioapic;

> @@ -3236,7 +3236,7 @@ mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
>  	u16 smid;
>  	u32 ioc_state;
>  	unsigned long timeleft;
> -	u8 issue_reset;
> +	bool issue_reset;
>  	int rc;
>  	void *request;
>  	u16 wait_state_count;
> @@ -3300,7 +3300,7 @@ mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
>  		_debug_dump_mf(mpi_request,
>  		    sizeof(Mpi2SasIoUnitControlRequest_t)/4);
>  		if (!(ioc->base_cmds.status & MPT2_CMD_RESET))
> -			issue_reset = 1;
> +			issue_reset = true;
>  		goto issue_host_reset;
>  	}
>  	if (ioc->base_cmds.status & MPT2_CMD_REPLY_VALID)

It seems like issue_reset should be initialized to false.
issue_reset can be an arbitrary value before the goto issue_host_reset
which is:

 issue_host_reset:
	if (issue_reset)
		mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
		    FORCE_BIG_HAMMER);

> @@ -3341,7 +3341,7 @@ mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
>  	u16 smid;
>  	u32 ioc_state;p
>  	unsigned long timeleft;
> -	u8 issue_reset;
> +	bool issue_reset;
>  	int rc;
>  	void *request;
>  	u16 wait_state_count;
> @@ -3398,7 +3398,7 @@ mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
>  		_debug_dump_mf(mpi_request,
>  		    sizeof(Mpi2SepRequest_t)/4);
>  		if (!(ioc->base_cmds.status & MPT2_CMD_RESET))
> -			issue_reset = 1;
> +			issue_reset = true;
>  		goto issue_host_reset;
>  	}

same

I stopped looking here.



      reply	other threads:[~2014-12-17 18:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-17 14:56 [PATCH 1/1] [SCSI] mpt2sas: Convert non-returned local variable to boolean when relevant Quentin Lambert
2014-12-17 18:52 ` Joe Perches [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=1418842360.14140.29.camel@perches.com \
    --to=joe@perches.com \
    --cc=JBottomley@parallels.com \
    --cc=MPT-FusionLinux.pdl@avagotech.com \
    --cc=abhijit.mahajan@avagotech.com \
    --cc=lambert.quentin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nagalakshmi.nandigama@avagotech.com \
    --cc=praveen.krishnamoorthy@avagotech.com \
    --cc=sreekanth.reddy@avagotech.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox