add: if (index >= (int32)kNumTTYs) return B_ERROR;  TRACE(("slave_open: TTY index = %ld (name = %s)\n", index, name));
context: slave_open(const char *name, uint32 flags, void **_cookie){	int32 index = get_tty_index(name);	// we may only be used if our master has already been opened	if (gMasterTTYs[index].open_count == 0)		return B_IO_ERROR;	if (atomic_add(&gSlaveTTYs[index].open_count, 1) == 0) {		// ToDo: this is broken and must be synchronized with all		//	other open calls to that slave		// Also, tty_open() should probably be changed and always called in open().		status_t status = tty_open(&gSlaveTTYs[index], NULL);		if (status < B_OK) {			// initializing TTY failed, reset open counter			atomic_add(&gSlaveTTYs[index].open_count, -1);			return status;		}	} 	slave_cookie *cookie = (slave_cookie *)malloc(sizeof(struct slave_cookie));	if (cookie == NULL) {		atomic_add(&gSlaveTTYs[index].open_count, -1);		tty_close(&gSlaveTTYs[index]);		return B_NO_MEMORY;	}	cookie->tty = &gSlaveTTYs[index];	cookie->master = &gMasterTTYs[index];	cookie->open_mode = flags;	*_cookie = cookie;	return B_OK;}