public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <12o3l@tiscali.nl>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] fix not-and/or errors
Date: Thu, 18 Oct 2007 16:38:18 +0200	[thread overview]
Message-ID: <47176FDA.2060406@tiscali.nl> (raw)
In-Reply-To: <20071017143240.GH8181@ftp.linux.org.uk>

Al Viro wrote:
> On Wed, Oct 17, 2007 at 03:46:43PM +0200, Roel Kluin wrote:
>> +++ b/drivers/misc/asus-laptop.c
>> @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int mask)
>>  
>>  	switch (mask) {
>>  	case MLED_ON:
>> -		out = !out & 0x1;
>> +		out = !(out & 0x1);
> 
> Not sure if that's what had been intended.

It seems to me if I look at the code, that it's intended to make a bool out of 'out'. That's
nonsense because of the precedence the ! will turn it into a boolean before the & 0x1.

x = !x & y behaves like x = !x for y != 0. 
for y = 1 the behavior is even the same for x = !(x & y)
so it does not matter in this case, except for clarity. I'll make it out = !out.

> 
>> @@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
>>  			    !(STp->use_pf & PF_TESTED)) {
>>  				/* Try the other possible state of Page Format if not
>>  				   already tried */
>> -				STp->use_pf = !STp->use_pf | PF_TESTED;
>> +				STp->use_pf = !(STp->use_pf | PF_TESTED);
> 
> Wrong.  This code, ugly as it is, happens to be correct.  Replacement
> isn't.  I would rewrite it as ^= PF_TESTED | USE_PF; /* remove USE_PF, set *
> 						      * PF_TESTED */
> 
> The rest is covered by Alexey's patch and one I'd posted as followup.


ok, thanks, I'll correct and omit these in my follow up patch.

Roel

  reply	other threads:[~2007-10-18 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17 13:46 [PATCH 1/4] fix not-and/or errors Roel Kluin
2007-10-17 13:49 ` [PATCH 2/4] " Roel Kluin
2007-10-17 13:54   ` Roel Kluin
2007-10-17 14:03   ` Peter Zijlstra
2007-10-17 13:53 ` [PATCH 3/4] " Roel Kluin
2007-10-17 13:55 ` [PATCH 4/4] " Roel Kluin
2007-10-17 14:05   ` Peter Zijlstra
2007-10-17 14:35   ` Al Viro
2007-10-18 14:02   ` [PATCH 4/4 returns] " Roel Kluin
2007-10-17 14:02 ` [PATCH 1/4] " Peter Zijlstra
2007-10-17 14:17 ` Andreas Schwab
2007-10-17 14:32 ` Al Viro
2007-10-18 14:38   ` Roel Kluin [this message]
2007-10-18 15:00 ` Roel Kluin

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=47176FDA.2060406@tiscali.nl \
    --to=12o3l@tiscali.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /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