linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
       [not found]     ` <1cbAw-2BB-27@gated-at.bofh.it>
@ 2004-01-16 18:41       ` Bill Davidsen
  2004-01-16 18:54         ` Nigel Cunningham
  0 siblings, 1 reply; 11+ messages in thread
From: Bill Davidsen @ 2004-01-16 18:41 UTC (permalink / raw)
  To: Andries Brouwer; +Cc: Linux Kernel mailing List

Andries Brouwer wrote:
>>>Shouldn't we be using "size_t" for unsigned int
> 
> 
>>You might be right. I was just being consistent with the other definitions.
> 
> 
> These are character positions on a screen.
> When did you last see a console in text mode with a line length
> of more than 2^31 ?
> 
> If you go for a minimal patch then you should replace "char"
> in one or two places by "unsigned char" and that is all.

Are these screen positions or offsets into the string for the line? The 
reason I ask is that with a 2-byte character set no char is going to do 
the latter reliably, not only do people run 132 col mode with vt100 
windows, just hitting the "full screen" button with most WM will give 
you >127 columns.

-- 
bill davidsen <davidsen@tmr.com>
   CTO TMR Associates, Inc
   Doing interesting things with small computers since 1979

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-16 18:41       ` PATCH 1/2: Make gotoxy & siblings use unsigned variables Bill Davidsen
@ 2004-01-16 18:54         ` Nigel Cunningham
  0 siblings, 0 replies; 11+ messages in thread
From: Nigel Cunningham @ 2004-01-16 18:54 UTC (permalink / raw)
  To: Bill Davidsen; +Cc: Andries Brouwer, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

Hi.

Since we discussed this, I've produced a cut down patch and sent it to
my wide-console users. I can confirm that it is all that is needed. I'll
be posting a new patch for Andrew shortly.

Regards,

Nigel

On Sat, 2004-01-17 at 07:41, Bill Davidsen wrote:
> Andries Brouwer wrote:
> >>>Shouldn't we be using "size_t" for unsigned int
> > 
> > 
> >>You might be right. I was just being consistent with the other definitions.
> > 
> > 
> > These are character positions on a screen.
> > When did you last see a console in text mode with a line length
> > of more than 2^31 ?
> > 
> > If you go for a minimal patch then you should replace "char"
> > in one or two places by "unsigned char" and that is all.
> 
> Are these screen positions or offsets into the string for the line? The 
> reason I ask is that with a 2-byte character set no char is going to do 
> the latter reliably, not only do people run 132 col mode with vt100 
> windows, just hitting the "full screen" button with most WM will give 
> you >127 columns.
-- 
My work on Software Suspend is graciously brought to you by
LinuxFund.org.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 19:43   ` Nigel Cunningham
  2004-01-09 20:33     ` Andries Brouwer
@ 2004-01-13 21:57     ` Pavel Machek
  1 sibling, 0 replies; 11+ messages in thread
From: Pavel Machek @ 2004-01-13 21:57 UTC (permalink / raw)
  To: Nigel Cunningham
  Cc: root, Linux Kernel Mailing List, Andrew Morton, Benjamin Herrenschmidt

Hi!

> You might be right. I was just being consistent with the other
> definitions. Andrew? Benjamin?

I believe size_t is meant for file size, memory size and similar. You
should stuck with int.
								Pavel

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 21:26       ` Nigel Cunningham
@ 2004-01-10  3:34         ` Edgar Toernig
  0 siblings, 0 replies; 11+ messages in thread
From: Edgar Toernig @ 2004-01-10  3:34 UTC (permalink / raw)
  To: ncunningham
  Cc: Andries Brouwer, root, Linux Kernel Mailing List, Andrew Morton,
	Benjamin Herrenschmidt

Nigel Cunningham wrote:
>
> Andries Brouwer wrote:
>
> > When did you last see a console in text mode with a line length
> > of more than 2^31 ?
> >
> > If you go for a minimal patch then you should replace "char"
> > in one or two places by "unsigned char" and that is all.
>
> Of course you're right about 2^31 columns, but the rest of the code used
> unsigned ints as well, not because it expects 2^31 columns, but because
> (if I understand the code right), the numbers can be part of escape
> sequences... I'm looking at csi_m in vt.c.

Yes, they may be part of escape sequences and that's why your patch is
wrong.  See the comment above gotoxy:

    /*
     * gotoxy() must verify all boundaries, because the arguments
     * might also be negative. If the given position is out of
     * bounds, the cursor is placed at the nearest margin.
    */

If you make the arguments unsigned it will choose the wrong
margin for negative values.  That will i.e. happen if you send
the sequence to move the cursor 10 spaces left when it is only
in column 5.

Afaics, the only thing that needs fixing is putconsxy:

 void putconsxy(int currcons, char *p)
 {
-        gotoxy(currcons, p[0], p[1]);
+        gotoxy(currcons, (unsigned char)p[0], (unsigned char)p[1]);
         set_cursor(currcons);
 }

Ciao, ET.

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 18:33 Nigel Cunningham
  2004-01-09 19:22 ` Richard B. Johnson
  2004-01-09 21:32 ` Andrew Morton
@ 2004-01-09 21:38 ` Andrew Morton
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2004-01-09 21:38 UTC (permalink / raw)
  To: ncunningham; +Cc: linux-kernel, akpm, benh

Nigel Cunningham <ncunningham@users.sourceforge.net> wrote:
>
> X-Mailer: Ximian Evolution 1.4.4-8mdk

Gack.  My MUA (sylpheed) is unable to decrypt the plain text after whatever
it is that Evolution did to it.  Please see if you can get Evolution to
play more nicely with plain text, or use attachments.

I fixed that one up by hand.

Thanks.

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 18:33 Nigel Cunningham
  2004-01-09 19:22 ` Richard B. Johnson
@ 2004-01-09 21:32 ` Andrew Morton
  2004-01-09 21:38 ` Andrew Morton
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2004-01-09 21:32 UTC (permalink / raw)
  To: ncunningham; +Cc: linux-kernel, akpm, benh

Nigel Cunningham <ncunningham@users.sourceforge.net> wrote:
>
> This patch makes console X and Y coordinates unsigned, rather than
> signed. Issues with wide (> 128 char?) consoles, seen when developing
> Software Suspend's 'nice display' are thus fixed. A brief examination of
> related code showed that this use of signed variables was the exception
> rather than the rule.

You'll probably find that all you needed to do was to convert the chars
over to unsigned, not the integers.

But whatever.


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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 20:33     ` Andries Brouwer
@ 2004-01-09 21:26       ` Nigel Cunningham
  2004-01-10  3:34         ` Edgar Toernig
  0 siblings, 1 reply; 11+ messages in thread
From: Nigel Cunningham @ 2004-01-09 21:26 UTC (permalink / raw)
  To: Andries Brouwer
  Cc: root, Linux Kernel Mailing List, Andrew Morton, Benjamin Herrenschmidt

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

Hi.

Of course you're right about 2^31 columns, but the rest of the code used
unsigned ints as well, not because it expects 2^31 columns, but because
(if I understand the code right), the numbers can be part of escape
sequences... I'm looking at csi_m in vt.c.

Regards,

Nigel

On Sat, 2004-01-10 at 09:33, Andries Brouwer wrote:
> >> Shouldn't we be using "size_t" for unsigned int
> 
> > You might be right. I was just being consistent with the other definitions.
> 
> These are character positions on a screen.
> When did you last see a console in text mode with a line length
> of more than 2^31 ?
> 
> If you go for a minimal patch then you should replace "char"
> in one or two places by "unsigned char" and that is all.
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
-- 
My work on Software Suspend is graciously brought to you by
LinuxFund.org.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 19:43   ` Nigel Cunningham
@ 2004-01-09 20:33     ` Andries Brouwer
  2004-01-09 21:26       ` Nigel Cunningham
  2004-01-13 21:57     ` Pavel Machek
  1 sibling, 1 reply; 11+ messages in thread
From: Andries Brouwer @ 2004-01-09 20:33 UTC (permalink / raw)
  To: Nigel Cunningham
  Cc: root, Linux Kernel Mailing List, Andrew Morton, Benjamin Herrenschmidt

>> Shouldn't we be using "size_t" for unsigned int

> You might be right. I was just being consistent with the other definitions.

These are character positions on a screen.
When did you last see a console in text mode with a line length
of more than 2^31 ?

If you go for a minimal patch then you should replace "char"
in one or two places by "unsigned char" and that is all.


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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 19:22 ` Richard B. Johnson
@ 2004-01-09 19:43   ` Nigel Cunningham
  2004-01-09 20:33     ` Andries Brouwer
  2004-01-13 21:57     ` Pavel Machek
  0 siblings, 2 replies; 11+ messages in thread
From: Nigel Cunningham @ 2004-01-09 19:43 UTC (permalink / raw)
  To: root; +Cc: Linux Kernel Mailing List, Andrew Morton, Benjamin Herrenschmidt

[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]

You might be right. I was just being consistent with the other
definitions. Andrew? Benjamin?

Regards,

Nigel

On Sat, 2004-01-10 at 08:22, Richard B. Johnson wrote:
> On Sat, 10 Jan 2004, Nigel Cunningham wrote:
> 
> > This patch makes console X and Y coordinates unsigned, rather than
> > signed. Issues with wide (> 128 char?) consoles, seen when developing
> > Software Suspend's 'nice display' are thus fixed. A brief examination of
> > related code showed that this use of signed variables was the exception
> > rather than the rule.
> >
> > Regards,
> >
> > Nigel
> [SNIPPED...]
> 
> Question: Shouldn't we be using "size_t" for unsigned int, and
> "ssize_t" for signed? If the "ints" are going to be changed,
> they probably should be changed only once. As I recall, size_t
> was the largest unsigned int that would fit into a register and
> ssize_t was the largest signed int that would fit.
> 
> Cheers,
> 
> Dick Johnson
> Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
>             Note 96.31% of all statistics are fiction.
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
-- 
My work on Software Suspend is graciously brought to you by
LinuxFund.org.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: PATCH 1/2: Make gotoxy & siblings use unsigned variables
  2004-01-09 18:33 Nigel Cunningham
@ 2004-01-09 19:22 ` Richard B. Johnson
  2004-01-09 19:43   ` Nigel Cunningham
  2004-01-09 21:32 ` Andrew Morton
  2004-01-09 21:38 ` Andrew Morton
  2 siblings, 1 reply; 11+ messages in thread
From: Richard B. Johnson @ 2004-01-09 19:22 UTC (permalink / raw)
  To: Nigel Cunningham
  Cc: Linux Kernel Mailing List, Andrew Morton, Benjamin Herrenschmidt

On Sat, 10 Jan 2004, Nigel Cunningham wrote:

> This patch makes console X and Y coordinates unsigned, rather than
> signed. Issues with wide (> 128 char?) consoles, seen when developing
> Software Suspend's 'nice display' are thus fixed. A brief examination of
> related code showed that this use of signed variables was the exception
> rather than the rule.
>
> Regards,
>
> Nigel
[SNIPPED...]

Question: Shouldn't we be using "size_t" for unsigned int, and
"ssize_t" for signed? If the "ints" are going to be changed,
they probably should be changed only once. As I recall, size_t
was the largest unsigned int that would fit into a register and
ssize_t was the largest signed int that would fit.

Cheers,

Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



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

* PATCH 1/2: Make gotoxy & siblings use unsigned variables
@ 2004-01-09 18:33 Nigel Cunningham
  2004-01-09 19:22 ` Richard B. Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Nigel Cunningham @ 2004-01-09 18:33 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Andrew Morton, Benjamin Herrenschmidt

[-- Attachment #1: Type: text/plain, Size: 2859 bytes --]

This patch makes console X and Y coordinates unsigned, rather than
signed. Issues with wide (> 128 char?) consoles, seen when developing
Software Suspend's 'nice display' are thus fixed. A brief examination of
related code showed that this use of signed variables was the exception
rather than the rule.

Regards,

Nigel

diff -ruN linux-2.6.1-rc3/drivers/char/vt.c console-patch-1/drivers/char/vt.c
--- linux-2.6.1-rc3/drivers/char/vt.c	2004-01-09 14:24:45.000000000 +1300
+++ console-patch-1/drivers/char/vt.c	2004-01-10 07:17:08.000000000 +1300
@@ -149,7 +149,7 @@
 static void vc_init(unsigned int console, unsigned int rows,
 		    unsigned int cols, int do_clear);
 static void blank_screen(unsigned long dummy);
-static void gotoxy(int currcons, int new_x, int new_y);
+static void gotoxy(int currcons, unsigned int new_x, unsigned int new_y);
 static void save_cur(int currcons);
 static void reset_terminal(int currcons, int do_clear);
 static void con_flush_chars(struct tty_struct *tty);
@@ -859,9 +859,9 @@
  * might also be negative. If the given position is out of
  * bounds, the cursor is placed at the nearest margin.
  */
-static void gotoxy(int currcons, int new_x, int new_y)
+static void gotoxy(int currcons, unsigned int new_x, unsigned int new_y)
 {
-	int min_y, max_y;
+	unsigned int min_y, max_y;
 
 	if (new_x < 0)
 		x = 0;
@@ -888,7 +888,7 @@
 }
 
 /* for absolute user moves, when decom is set */
-static void gotoxay(int currcons, int new_x, int new_y)
+static void gotoxay(int currcons, unsigned int new_x, unsigned int new_y)
 {
 	gotoxy(currcons, new_x, decom ? (top+new_y) : new_y);
 }
@@ -2996,13 +2996,13 @@
 	return screenpos(currcons, 2 * w_offset, viewed);
 }
 
-void getconsxy(int currcons, char *p)
+void getconsxy(int currcons, unsigned char *p)
 {
 	p[0] = x;
 	p[1] = y;
 }
 
-void putconsxy(int currcons, char *p)
+void putconsxy(int currcons, unsigned char *p)
 {
 	gotoxy(currcons, p[0], p[1]);
 	set_cursor(currcons);
diff -ruN linux-2.6.1-rc3/include/linux/selection.h console-patch-1/include/linux/selection.h
--- linux-2.6.1-rc3/include/linux/selection.h	2004-01-09 14:22:25.000000000 +1300
+++ console-patch-1/include/linux/selection.h	2004-01-10 07:17:08.000000000 +1300
@@ -36,8 +36,8 @@
 extern void complement_pos(int currcons, int offset);
 extern void invert_screen(int currcons, int offset, int count, int shift);
 
-extern void getconsxy(int currcons, char *p);
-extern void putconsxy(int currcons, char *p);
+extern void getconsxy(int currcons, unsigned char *p);
+extern void putconsxy(int currcons, unsigned char *p);
 
 extern u16 vcs_scr_readw(int currcons, const u16 *org);
 extern void vcs_scr_writew(int currcons, u16 val, u16 *org);

-- 
My work on Software Suspend is graciously brought to you by
LinuxFund.org.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2004-01-16 18:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1c9S3-75-23@gated-at.bofh.it>
     [not found] ` <1cauN-131-17@gated-at.bofh.it>
     [not found]   ` <1cb7n-1Z6-17@gated-at.bofh.it>
     [not found]     ` <1cbAw-2BB-27@gated-at.bofh.it>
2004-01-16 18:41       ` PATCH 1/2: Make gotoxy & siblings use unsigned variables Bill Davidsen
2004-01-16 18:54         ` Nigel Cunningham
2004-01-09 18:33 Nigel Cunningham
2004-01-09 19:22 ` Richard B. Johnson
2004-01-09 19:43   ` Nigel Cunningham
2004-01-09 20:33     ` Andries Brouwer
2004-01-09 21:26       ` Nigel Cunningham
2004-01-10  3:34         ` Edgar Toernig
2004-01-13 21:57     ` Pavel Machek
2004-01-09 21:32 ` Andrew Morton
2004-01-09 21:38 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).