public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* lp: too large subtraction on unsigned?
@ 2009-03-01 22:56 Roel Kluin
  2009-03-01 23:41 ` Thiago Galesi
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-03-01 22:56 UTC (permalink / raw)
  To: lkml

vi drivers/char/lp.c +705

note that count is unsigned, and we do the loop:

do {
	if (canwrite > 0) {
		...
		count -= written;
	}
	if (lf && canwrite <= 0) {
		...
		count--;
		...
	}
} while (count > 0 && (CONSOLE_LP_STRICT || written > 0));

Isn't this wrong?

Roel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: lp: too large subtraction on unsigned?
  2009-03-01 22:56 lp: too large subtraction on unsigned? Roel Kluin
@ 2009-03-01 23:41 ` Thiago Galesi
  0 siblings, 0 replies; 2+ messages in thread
From: Thiago Galesi @ 2009-03-01 23:41 UTC (permalink / raw)
  To: Roel Kluin; +Cc: lkml

Doesn't look like something is wrong, or I'm missing something...
:
> do {
>        if (canwrite > 0) {
>                ...
>                count -= written;
>        }

If there are chars left you write to the PP and take it out of the total

>        if (lf && canwrite <= 0) {
>                ...
>                count--;
>                ...
>        }
> } while (count > 0 && (CONSOLE_LP_STRICT || written > 0));

The second if is for translating \n to \r\n only if you've already
written everything (up to /n) to the PP

If count > 0 fails (that is, count == 0) you get out of the loop

-- 
-
Thiago Galesi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-01 23:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-01 22:56 lp: too large subtraction on unsigned? Roel Kluin
2009-03-01 23:41 ` Thiago Galesi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox