The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@saeurebad.de>
To: Roel Kluin <12o3l@tiscali.nl>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dz: test after postfix decrement fails in dz_console_putchar()
Date: Wed, 09 Apr 2008 15:41:13 +0200	[thread overview]
Message-ID: <87ve2rqh6u.fsf@saeurebad.de> (raw)
In-Reply-To: <47FC93BC.5020201@tiscali.nl> (Roel Kluin's message of "Wed, 09 Apr 2008 12:00:28 +0200")

Hi,

Roel Kluin <12o3l@tiscali.nl> writes:

> When loops reaches 0 the postfix decrement still subtracts, so the test fails
>
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
> index 116211f..0dddd68 100644
> --- a/drivers/serial/dz.c
> +++ b/drivers/serial/dz.c
> @@ -819,7 +819,7 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
>  		dz_out(dport, DZ_TCR, mask);
>  		iob();
>  		udelay(2);
> -	} while (loops--);
> +	} while (--loops);

It will run loops + 1 times.  After your change it does run loops times.

>  	if (loops)				/* Cannot send otherwise. */
>  		dz_out(dport, DZ_TDR, ch);

The intention was probably that this gets executed if the break in the
loop (trdy == dport->port.line) is reached.  Without your fix, this
branch is also taken if the while-loop terminates with loops == -1
because of the postfix dec.

Your fix is correct but your changelog entry is wrong.

	Hannes

  parent reply	other threads:[~2008-04-09 13:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-09 10:00 [PATCH] dz: test after postfix decrement fails in dz_console_putchar() Roel Kluin
2008-04-09 13:37 ` Maciej W. Rozycki
2008-04-09 13:41 ` Johannes Weiner [this message]
2008-04-09 14:35   ` Maciej W. Rozycki

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=87ve2rqh6u.fsf@saeurebad.de \
    --to=hannes@saeurebad.de \
    --cc=12o3l@tiscali.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@linux-mips.org \
    /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