Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision 75ebb5b6271b6a2c74a51ea695d73085ed9b97db)
+++ kernel/generic/src/ipc/sysipc.c	(revision e1da7ec0aef03e61c7634e6b41960aa3385d4e82)
@@ -58,10 +58,17 @@
 #define DATA_XFER_LIMIT		(64 * 1024)
 
-#define GET_CHECK_PHONE(phone, phoneid, err) \
-{ \
-	if ((unative_t) (phoneid) >= IPC_MAX_PHONES) { \
-		err \
-	} \
-	phone = &TASK->phones[(phoneid)]; \
+/** Get phone from the current task by ID.
+ *
+ * @param phoneid	Phone ID.
+ * @param phone		Place to store pointer to phone.
+ * @return		EOK on success, EINVAL if ID is invalid.
+ */
+static int phone_get(unative_t phoneid, phone_t **phone)
+{
+	if (phoneid >= IPC_MAX_PHONES)
+		return EINVAL;
+
+	*phone = &TASK->phones[phoneid];
+	return EOK;
 }
 
@@ -374,7 +381,9 @@
 	case IPC_M_CONNECTION_CLONE: {
 		phone_t *cloned_phone;
-		GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data),
-		    return ENOENT;);
+
+		if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
+			return ENOENT;
 		phones_lock(cloned_phone, phone);
+
 		if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
 		    phone->state != IPC_PHONE_CONNECTED) {
@@ -534,6 +543,7 @@
 	int res;
 	int rc;
-	
-	GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
+
+	if (phone_get(phoneid, &phone) != EOK)
+		return ENOENT;
 
 	call = ipc_call_alloc(0);
@@ -591,5 +601,6 @@
 	int rc;
 
-	GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
+	if (phone_get(phoneid, &phone) != EOK)
+		return ENOENT;
 
 	call = ipc_call_alloc(0);
@@ -666,5 +677,6 @@
 		return IPC_CALLRET_TEMPORARY;
 
-	GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
+	if (phone_get(phoneid, &phone) != EOK)
+		return IPC_CALLRET_FATAL;
 
 	call = ipc_call_alloc(0);
@@ -705,5 +717,6 @@
 		return IPC_CALLRET_TEMPORARY;
 
-	GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
+	if (phone_get(phoneid, &phone) != EOK)
+		return IPC_CALLRET_FATAL;
 
 	call = ipc_call_alloc(0);
@@ -755,9 +768,9 @@
 	call->flags |= IPC_CALL_FORWARDED;
 
-	GET_CHECK_PHONE(phone, phoneid, {
+	if (phone_get(phoneid, &phone) != EOK) {
 		IPC_SET_RETVAL(call->data, EFORWARD);
 		ipc_answer(&TASK->answerbox, call);
 		return ENOENT;
-	});
+	}
 
 	if (!method_is_forwardable(IPC_GET_METHOD(call->data))) {
@@ -960,5 +973,6 @@
 	phone_t *phone;
 
-	GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
+	if (phone_get(phoneid, &phone) != EOK)
+		return ENOENT;
 
 	if (ipc_phone_hangup(phone))
