[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/4] linux: fix bit tests
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 1/4] linux: fix bit tests |
Date: |
Mon, 6 Jan 2014 02:41:03 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Mon 06 Jan 2014 00:34:52 +0100, a écrit :
> The pattern is !x&y. An expression of this form is almost always
> meaningless, because it combines a boolean operator with a bit
> operator. In particular, if the rightmost bit of y is 0, the result
> will always be 0.
>
> Fixed using coccinelle.
>
> // !x&y combines boolean negation with bitwise and
> //
> // Confidence: High
> // Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2.
> // URL: http://www.emn.fr/x-info/coccinelle/rules/notand.html
> // Options:
>
> @@ expression E; constant C; @@
> (
> !E & !C
> |
> - !E & C
> + !(E & C)
> )
>
> * linux/src/drivers/net/tlan.c: Fix bit tests.
> * linux/src/drivers/scsi/AM53C974.c: Likewise.
> * linux/src/drivers/scsi/FlashPoint.c: Likewise.
> * linux/src/drivers/scsi/NCR5380.c: Likewise.
> * linux/src/drivers/scsi/t128.c: Likewise.
Ack.
Did you check whether these still appear in the Linux source code? I
have already fixed an obscure bug in Linux simply by fixing it in the
gnumach copy :)
> ---
> linux/src/drivers/net/tlan.c | 4 ++--
> linux/src/drivers/scsi/AM53C974.c | 2 +-
> linux/src/drivers/scsi/FlashPoint.c | 2 +-
> linux/src/drivers/scsi/NCR5380.c | 4 ++--
> linux/src/drivers/scsi/t128.c | 4 ++--
> 5 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/linux/src/drivers/net/tlan.c b/linux/src/drivers/net/tlan.c
> index 11e12bb..fedc11f 100644
> --- a/linux/src/drivers/net/tlan.c
> +++ b/linux/src/drivers/net/tlan.c
> @@ -1132,7 +1132,7 @@ u32 TLan_HandleTxEOF( struct device *dev, u16 host_int )
>
> if ( head_list->cStat & TLAN_CSTAT_EOC )
> eoc = 1;
> - if ( ! head_list->cStat & TLAN_CSTAT_FRM_CMP ) {
> + if (!(head_list->cStat & TLAN_CSTAT_FRM_CMP)) {
> printk( "TLAN: Received interrupt for uncompleted TX frame.\n"
> );
> }
>
> @@ -1244,7 +1244,7 @@ u32 TLan_HandleRxEOF( struct device *dev, u16 host_int )
> eoc = 1;
> }
>
> - if ( ! head_list->cStat & TLAN_CSTAT_FRM_CMP ) {
> + if (!(head_list->cStat & TLAN_CSTAT_FRM_CMP)) {
> printk( "TLAN: Received interrupt for uncompleted RX frame.\n"
> );
> } else if ( bbuf ) {
> skb = dev_alloc_skb( head_list->frameSize + 7 );
> diff --git a/linux/src/drivers/scsi/AM53C974.c
> b/linux/src/drivers/scsi/AM53C974.c
> index 5178ccf..da139ce 100644
> --- a/linux/src/drivers/scsi/AM53C974.c
> +++ b/linux/src/drivers/scsi/AM53C974.c
> @@ -1919,7 +1919,7 @@ if ((statreg & STATREG_PHASE) != PHASE_MSGIN) {
> goto EXIT_ABORT; }
>
> msg[0] = AM53C974_read_8(FFREG);
> -if (!msg[0] & 0x80) {
> +if (!(msg[0] & 0x80)) {
> printk("scsi%d: error: expecting IDENTIFY message, got ",
> instance->host_no);
> print_msg(msg);
> hostdata->aborted = 1;
> diff --git a/linux/src/drivers/scsi/FlashPoint.c
> b/linux/src/drivers/scsi/FlashPoint.c
> index aae35c0..4b96a66 100644
> --- a/linux/src/drivers/scsi/FlashPoint.c
> +++ b/linux/src/drivers/scsi/FlashPoint.c
> @@ -3845,7 +3845,7 @@ int SetDevWideMode(PSCCBcard pCurrCard,PUCB p_ucb)
> }
> else
> {
> - if(!currTar_Info->TarEEValue & EE_WIDE_SCSI)
> + if(!(currTar_Info->TarEEValue & EE_WIDE_SCSI))
> {
> return(0);
> }
> diff --git a/linux/src/drivers/scsi/NCR5380.c
> b/linux/src/drivers/scsi/NCR5380.c
> index 295f2ad..4f085e9 100644
> --- a/linux/src/drivers/scsi/NCR5380.c
> +++ b/linux/src/drivers/scsi/NCR5380.c
> @@ -1949,7 +1949,7 @@ static int do_abort (struct Scsi_Host *host) {
> * the target sees, so we just handshake.
> */
>
> - while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ);
> + while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ));
>
> NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
>
> @@ -2900,7 +2900,7 @@ static void NCR5380_reselect (struct Scsi_Host
> *instance) {
> NCR5380_transfer_pio(instance, &phase, &len, &data);
>
>
> - if (!msg[0] & 0x80) {
> + if (!(msg[0] & 0x80)) {
> printk("scsi%d : expecting IDENTIFY message, got ",
> instance->host_no);
> print_msg(msg);
> diff --git a/linux/src/drivers/scsi/t128.c b/linux/src/drivers/scsi/t128.c
> index d4c7452..198e910 100644
> --- a/linux/src/drivers/scsi/t128.c
> +++ b/linux/src/drivers/scsi/t128.c
> @@ -327,7 +327,7 @@ static inline int NCR5380_pread (struct Scsi_Host
> *instance, unsigned char *dst,
> for (; i; --i) {
> while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
> #else
> - while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
> + while (!((instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY)) barrier();
> for (; i; --i) {
> #endif
> *d++ = *reg;
> @@ -370,7 +370,7 @@ static inline int NCR5380_pwrite (struct Scsi_Host
> *instance, unsigned char *src
> for (; i; --i) {
> while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
> #else
> - while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
> + while (!((instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY)) barrier();
> for (; i; --i) {
> #endif
> *reg = *s++;
> --
> 1.8.5.2
>
--
Samuel
Accroche-toi au terminal, j'enlève le shell...
-+- nojhan -+-
Re: [PATCH 1/4] linux: fix bit tests,
Samuel Thibault <=