lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 17 Dec 2014 10:52:40 -0800
From:	Joe Perches <joe@...ches.com>
To:	Quentin Lambert <lambert.quentin@...il.com>
Cc:	Nagalakshmi Nandigama <nagalakshmi.nandigama@...gotech.com>,
	Praveen Krishnamoorthy <praveen.krishnamoorthy@...gotech.com>,
	Sreekanth Reddy <sreekanth.reddy@...gotech.com>,
	Abhijit Mahajan <abhijit.mahajan@...gotech.com>,
	"James E.J. Bottomley" <JBottomley@...allels.com>,
	MPT-FusionLinux.pdl@...gotech.com, linux-scsi@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] [SCSI] mpt2sas: Convert non-returned local variable
 to boolean when relevant

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.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ