Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 3bacee1839e6f355100ab4ea86bb211e9ecf19ed)
+++ uspace/srv/loader/main.c	(revision 63d46341182c752620dcc5a2233d205cee1075dd)
@@ -90,7 +90,7 @@
 static bool connected = false;
 
-static void ldr_get_taskid(cap_call_handle_t req_handle, ipc_call_t *request)
-{
-	cap_call_handle_t chandle;
+static void ldr_get_taskid(ipc_call_t *req)
+{
+	ipc_call_t call;
 	task_id_t task_id;
 	size_t len;
@@ -98,7 +98,7 @@
 	task_id = task_get_id();
 
-	if (!async_data_read_receive(&chandle, &len)) {
-		async_answer_0(chandle, EINVAL);
-		async_answer_0(req_handle, EINVAL);
+	if (!async_data_read_receive(&call, &len)) {
+		async_answer_0(&call, EINVAL);
+		async_answer_0(req, EINVAL);
 		return;
 	}
@@ -107,14 +107,12 @@
 		len = sizeof(task_id);
 
-	async_data_read_finalize(chandle, &task_id, len);
-	async_answer_0(req_handle, EOK);
+	async_data_read_finalize(&call, &task_id, len);
+	async_answer_0(req, EOK);
 }
 
 /** Receive a call setting the current working directory.
  *
- * @param req_handle
- * @param request
- */
-static void ldr_set_cwd(cap_call_handle_t req_handle, ipc_call_t *request)
+ */
+static void ldr_set_cwd(ipc_call_t *req)
 {
 	char *buf;
@@ -128,25 +126,25 @@
 	}
 
-	async_answer_0(req_handle, rc);
+	async_answer_0(req, rc);
 }
 
 /** Receive a call setting the program to execute.
  *
- * @param req_handle
- * @param request
- */
-static void ldr_set_program(cap_call_handle_t req_handle, ipc_call_t *request)
-{
-	cap_call_handle_t write_chandle;
+ */
+static void ldr_set_program(ipc_call_t *req)
+{
+	ipc_call_t call;
 	size_t namesize;
-	if (!async_data_write_receive(&write_chandle, &namesize)) {
-		async_answer_0(req_handle, EINVAL);
+	if (!async_data_write_receive(&call, &namesize)) {
+		async_answer_0(req, EINVAL);
 		return;
 	}
 
 	char *name = malloc(namesize);
-	errno_t rc = async_data_write_finalize(write_chandle, name, namesize);
+	// FIXME: check return value
+
+	errno_t rc = async_data_write_finalize(&call, name, namesize);
 	if (rc != EOK) {
-		async_answer_0(req_handle, EINVAL);
+		async_answer_0(req, EINVAL);
 		return;
 	}
@@ -155,5 +153,5 @@
 	rc = vfs_receive_handle(true, &file);
 	if (rc != EOK) {
-		async_answer_0(req_handle, EINVAL);
+		async_answer_0(req, EINVAL);
 		return;
 	}
@@ -161,13 +159,11 @@
 	progname = name;
 	program_fd = file;
-	async_answer_0(req_handle, EOK);
+	async_answer_0(req, EOK);
 }
 
 /** Receive a call setting arguments of the program to execute.
  *
- * @param req_handle
- * @param request
- */
-static void ldr_set_args(cap_call_handle_t req_handle, ipc_call_t *request)
+ */
+static void ldr_set_args(ipc_call_t *req)
 {
 	char *buf;
@@ -194,5 +190,5 @@
 		if (_argv == NULL) {
 			free(buf);
-			async_answer_0(req_handle, ENOMEM);
+			async_answer_0(req, ENOMEM);
 			return;
 		}
@@ -226,30 +222,28 @@
 	}
 
-	async_answer_0(req_handle, rc);
+	async_answer_0(req, rc);
 }
 
 /** Receive a call setting inbox files of the program to execute.
  *
- * @param req_handle
- * @param request
- */
-static void ldr_add_inbox(cap_call_handle_t req_handle, ipc_call_t *request)
+ */
+static void ldr_add_inbox(ipc_call_t *req)
 {
 	if (inbox_entries == INBOX_MAX_ENTRIES) {
-		async_answer_0(req_handle, ERANGE);
-		return;
-	}
-
-	cap_call_handle_t write_chandle;
+		async_answer_0(req, ERANGE);
+		return;
+	}
+
+	ipc_call_t call;
 	size_t namesize;
-	if (!async_data_write_receive(&write_chandle, &namesize)) {
-		async_answer_0(req_handle, EINVAL);
+	if (!async_data_write_receive(&call, &namesize)) {
+		async_answer_0(req, EINVAL);
 		return;
 	}
 
 	char *name = malloc(namesize);
-	errno_t rc = async_data_write_finalize(write_chandle, name, namesize);
+	errno_t rc = async_data_write_finalize(&call, name, namesize);
 	if (rc != EOK) {
-		async_answer_0(req_handle, EINVAL);
+		async_answer_0(req, EINVAL);
 		return;
 	}
@@ -258,5 +252,5 @@
 	rc = vfs_receive_handle(true, &file);
 	if (rc != EOK) {
-		async_answer_0(req_handle, EINVAL);
+		async_answer_0(req, EINVAL);
 		return;
 	}
@@ -272,19 +266,18 @@
 	inbox[inbox_entries].file = file;
 	inbox_entries++;
-	async_answer_0(req_handle, EOK);
+	async_answer_0(req, EOK);
 }
 
 /** Load the previously selected program.
  *
- * @param req_handle
- * @param request
  * @return 0 on success, !0 on error.
- */
-static int ldr_load(cap_call_handle_t req_handle, ipc_call_t *request)
+ *
+ */
+static int ldr_load(ipc_call_t *req)
 {
 	int rc = elf_load(program_fd, &prog_info);
 	if (rc != EE_OK) {
 		DPRINTF("Failed to load executable for '%s'.\n", progname);
-		async_answer_0(req_handle, EINVAL);
+		async_answer_0(req, EINVAL);
 		return 1;
 	}
@@ -300,5 +293,5 @@
 	pcb.inbox_entries = inbox_entries;
 
-	async_answer_0(req_handle, EOK);
+	async_answer_0(req, EOK);
 	return 0;
 }
@@ -306,10 +299,8 @@
 /** Run the previously loaded program.
  *
- * @param req_handle
- * @param request
  * @return 0 on success, !0 on error.
- */
-static __attribute__((noreturn)) void ldr_run(cap_call_handle_t req_handle,
-    ipc_call_t *request)
+ *
+ */
+static __attribute__((noreturn)) void ldr_run(ipc_call_t *req)
 {
 	DPRINTF("Set task name\n");
@@ -320,5 +311,5 @@
 	/* Run program */
 	DPRINTF("Reply OK\n");
-	async_answer_0(req_handle, EOK);
+	async_answer_0(req, EOK);
 	DPRINTF("Jump to entry point at %p\n", pcb.entry);
 	entry_point_jmp(prog_info.finfo.entry, &pcb);
@@ -331,11 +322,11 @@
  * Receive and carry out commands (of which the last one should be
  * to execute the loaded program).
- */
-static void ldr_connection(cap_call_handle_t icall_handle, ipc_call_t *icall,
-    void *arg)
+ *
+ */
+static void ldr_connection(ipc_call_t *icall, void *arg)
 {
 	/* Already have a connection? */
 	if (connected) {
-		async_answer_0(icall_handle, ELIMIT);
+		async_answer_0(icall, ELIMIT);
 		return;
 	}
@@ -344,5 +335,5 @@
 
 	/* Accept the connection */
-	async_answer_0(icall_handle, EOK);
+	async_answer_0(icall, EOK);
 
 	/* Ignore parameters, the connection is already open */
@@ -352,5 +343,5 @@
 		errno_t retval;
 		ipc_call_t call;
-		cap_call_handle_t chandle = async_get_call(&call);
+		async_get_call(&call);
 
 		if (!IPC_GET_IMETHOD(call))
@@ -359,23 +350,23 @@
 		switch (IPC_GET_IMETHOD(call)) {
 		case LOADER_GET_TASKID:
-			ldr_get_taskid(chandle, &call);
+			ldr_get_taskid(&call);
 			continue;
 		case LOADER_SET_CWD:
-			ldr_set_cwd(chandle, &call);
+			ldr_set_cwd(&call);
 			continue;
 		case LOADER_SET_PROGRAM:
-			ldr_set_program(chandle, &call);
+			ldr_set_program(&call);
 			continue;
 		case LOADER_SET_ARGS:
-			ldr_set_args(chandle, &call);
+			ldr_set_args(&call);
 			continue;
 		case LOADER_ADD_INBOX:
-			ldr_add_inbox(chandle, &call);
+			ldr_add_inbox(&call);
 			continue;
 		case LOADER_LOAD:
-			ldr_load(chandle, &call);
+			ldr_load(&call);
 			continue;
 		case LOADER_RUN:
-			ldr_run(chandle, &call);
+			ldr_run(&call);
 			/* Not reached */
 		default:
@@ -384,5 +375,5 @@
 		}
 
-		async_answer_0(chandle, retval);
+		async_answer_0(&call, retval);
 	}
 }
