Now makes sure that the index get_tty_index() returns is in a valid range.

Added some more conditional debug output, turned off debug output.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9154 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-10-01 17:36:47 +00:00
parent 7740b91858
commit af91664416
2 changed files with 10 additions and 3 deletions
src/add-ons/kernel/drivers/tty

@ -9,7 +9,7 @@
#include <stdlib.h>
#define MASTER_TRACE
//#define MASTER_TRACE
#ifdef MASTER_TRACE
# define TRACE(x) dprintf x
#else
@ -42,7 +42,10 @@ static status_t
master_open(const char *name, uint32 flags, void **_cookie)
{
int32 index = get_tty_index(name);
dprintf("TTY index = %ld (name = %s)\n", index, name);
if (index >= (int32)kNumTTYs)
return B_ERROR;
TRACE(("master_open: TTY index = %ld (name = %s)\n", index, name));
if (atomic_or(&gMasterTTYs[index].open_count, 1) != 0) {
// we're already open!

@ -9,7 +9,7 @@
#include <stdlib.h>
#define SLAVE_TRACE
//#define SLAVE_TRACE
#ifdef SLAVE_TRACE
# define TRACE(x) dprintf x
#else
@ -31,6 +31,10 @@ static status_t
slave_open(const char *name, uint32 flags, void **_cookie)
{
int32 index = get_tty_index(name);
if (index >= (int32)kNumTTYs)
return B_ERROR;
TRACE(("slave_open: TTY index = %ld (name = %s)\n", index, name));
// we may only be used if our master has already been opened
if (gMasterTTYs[index].open_count == 0)