rem: if (status == B_TIMED_OUT || status == B_WOULD_BLOCK)
add: if (status != B_OK)
context: read_port_etc(port_id id, int32 *_msgCode, void *msgBuffer, size_t bufferSize,	uint32 flags, bigtime_t timeout){	cpu_status state;	sem_id cachedSem;	status_t status;	bool userCopy = (flags & PORT_FLAG_USE_USER_MEMCPY) > 0;	port_msg *msg;	size_t size;	int slot;	if (!sPortsActive || id < 0)		return B_BAD_PORT_ID;	if (_msgCode == NULL		|| (msgBuffer == NULL && bufferSize > 0)		|| timeout < 0)		return B_BAD_VALUE;	flags = flags & (B_CAN_INTERRUPT | B_TIMEOUT);	slot = id % sMaxPorts;	state = disable_interrupts();	GRAB_PORT_LOCK(sPorts[slot]);	if (sPorts[slot].id != id) {		RELEASE_PORT_LOCK(sPorts[slot]);		restore_interrupts(state);		dprintf("read_port_etc: invalid port_id %ld\n", id);		return B_BAD_PORT_ID;	}	// store sem_id in local variable	cachedSem = sPorts[slot].read_sem;	// unlock port && enable ints/	RELEASE_PORT_LOCK(sPorts[slot]);	restore_interrupts(state);	status = acquire_sem_etc(cachedSem, 1, flags, timeout);		// get 1 entry from the queue, block if needed	if (status == B_BAD_SEM_ID || status == B_INTERRUPTED) {		/* somebody deleted the port or the sem went away */		return B_BAD_PORT_ID;	}	if (status == B_TIMED_OUT || status == B_WOULD_BLOCK)		return status;	if (status != B_NO_ERROR) {		dprintf("write_port_etc: unknown error %ld\n", status);		return status;	}	state = disable_interrupts();	GRAB_PORT_LOCK(sPorts[slot]);	// first, let's check if the port is still alive	if (sPorts[slot].id == -1) {		// the port has been deleted in the meantime		RELEASE_PORT_LOCK(sPorts[slot]);		restore_interrupts(state);		return B_BAD_PORT_ID;	}	msg = list_get_first_item(&sPorts[slot].msg_queue);	if (msg == NULL)		panic("port %ld: no messages found", sPorts[slot].id);	list_remove_link(msg);	sPorts[slot].total_count++;	cachedSem = sPorts[slot].write_sem;	RELEASE_PORT_LOCK(sPorts[slot]);	restore_interrupts(state);	// check output buffer size	size = min(bufferSize, msg->size);	// copy message	*_msgCode = msg->code;	if (size > 0) {		if (userCopy) {			if ((status = cbuf_user_memcpy_from_chain(msgBuffer, msg->buffer_chain, 0, size) < B_OK)) {				// leave the port intact, for other threads that might not crash				put_port_msg(msg);				release_sem(cachedSem);				return status;			}		} else			cbuf_memcpy_from_chain(msgBuffer, msg->buffer_chain, 0, size);	}	put_port_msg(msg);	// make one spot in queue available again for write	release_sem(cachedSem);		// ToDo: we might think about setting B_NO_RESCHEDULE here		//	from time to time (always?)	return size;}