bug in termios?

joel at oarcorp.com joel at oarcorp.com
Fri Aug 21 12:38:11 UTC 1998



On Fri, 21 Aug 1998, Thomas Doerfler wrote:

> first of all: Thanks to Eric Norum for the termios support in RTEMS 
> (and for KA9Q aswell!).

And for replacing it with the FreeBSD TCP/IP stack. Which is much
faster and has easy to understand licensing with no problematic
restrictions!!!

> Now the bad news :-<

Not that bad.  I found this and fixed it which working on a BSP.  The fix
just did not get back before beta3.

> - anybody already experienced this bug?
> - is it a bug at all or did I do anything fundamentally wrong?
> - is there already a common bugfix for that?

Yes. No. Yes.

> I don't like poking around in other people code, as long as I am not 
> absolutely sure, what I do...

In situations like this the simplest thing is to change malloc() to
calloc().  

> is there a sample device driver using "termios" together with 
> XON/XOFF support? I found some definitions for XON/XOFF, but as 
> far as I understand, termios will NOT manage that (up to now :->?) 
> and I will need XON/XOFF for my application...

Eric will have to answer this specifically.  But I think termios handles
the SW flow control and it is up to the device driver hooks to
specifically provide handlers for HW RTS/CTS flow control.

Patch to termios.c initialization is attached.

--joel
Joel Sherrill                    Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (205) 722-9985



-------------- next part --------------
Index: termios.c
===================================================================
RCS file: /usr1/rtems/CVS/rtems/c/src/lib/libc/termios.c,v
retrieving revision 1.19
diff -c -r1.19 termios.c
*** termios.c	1998/07/28 16:49:36	1.19
--- termios.c	1998/08/21 12:37:10
***************
*** 206,212 ****
  		/*
  		 * Create a new device
  		 */
! 		tty = malloc (sizeof (struct rtems_termios_tty));
  		if (tty == NULL) {
  			rtems_semaphore_release (ttyMutex);
  			return RTEMS_NO_MEMORY;
--- 206,212 ----
  		/*
  		 * Create a new device
  		 */
! 		tty = calloc (1, sizeof (struct rtems_termios_tty));
  		if (tty == NULL) {
  			rtems_semaphore_release (ttyMutex);
  			return RTEMS_NO_MEMORY;
***************
*** 219,225 ****
  
  		tty->minor = minor;
  		tty->major = major;
- 		tty->refcount = 0;
  
  		/*
  		 * Set up mutex semaphores
--- 219,224 ----
***************
*** 250,255 ****
--- 249,256 ----
  			rtems_fatal_error_occurred (sc);
  		tty->rawOutBufHead = 0;
  		tty->rawOutBufTail = 0;
+ 		tty->refcount = 0;
+ 		tty->rawOutBufState = rob_idle;
  
  		/*
  		 * Set callbacks


More information about the users mailing list