Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/Makefile	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -46,5 +46,4 @@
 	app/tasks \
 	app/tester \
-	app/test_serial \
 	app/tetris \
 	app/trace \
Index: uspace/app/bdsh/cmds/modules/bdd/bdd.c
===================================================================
--- uspace/app/bdsh/cmds/modules/bdd/bdd.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/bdsh/cmds/modules/bdd/bdd.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,4 +30,5 @@
 #include <stdlib.h>
 #include <str.h>
+#include <sys/typefmt.h>
 #include "config.h"
 #include "util.h"
@@ -122,5 +123,5 @@
 		rc = block_read_direct(handle, ba, 1, blk);
 		if (rc != EOK) {
-			printf("%s: Error reading block %llu\n", cmdname, ba);
+			printf("%s: Error reading block %" PRIuOFF64 "\n", cmdname, ba);
 			free(blk);
 			block_fini(handle);
Index: uspace/app/bdsh/cmds/modules/cp/cp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cp/cp.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -95,5 +95,5 @@
 
 	if (vb)
-		printf("%d bytes to copy\n", total);
+		printf("%" PRIu64 " bytes to copy\n", total);
 
 	lseek(fd1, 0, SEEK_SET);
@@ -130,5 +130,5 @@
 		 */
 		if (res != 0) {
-			printf("\n%d more bytes than actually exist were copied\n", res);
+			printf("\n%zd more bytes than actually exist were copied\n", res);
 			goto err;
 		}
@@ -187,5 +187,5 @@
 			return CMD_SUCCESS;
 		case 'v':
-			printf("%d\n", CP_VERSION);
+			printf("%s\n", CP_VERSION);
 			return CMD_SUCCESS;
 		case 'V':
@@ -223,5 +223,5 @@
 
 	if (verbose)
-		printf("%d bytes copied\n", ret);
+		printf("%" PRId64 " bytes copied\n", ret);
 
 	if (ret >= 0)
Index: uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -168,5 +168,5 @@
 		rc = write(fd, buffer, to_write);
 		if (rc <= 0) {
-			printf("%s: Error writing file (%d).\n", cmdname, rc);
+			printf("%s: Error writing file (%zd).\n", cmdname, rc);
 			close(fd);
 			return CMD_FAILURE;
@@ -177,5 +177,5 @@
 	rc = close(fd);
 	if (rc != 0) {
-		printf("%s: Error writing file (%d).\n", cmdname, rc);
+		printf("%s: Error writing file (%zd).\n", cmdname, rc);
 		return CMD_FAILURE;
 	}
Index: uspace/app/bdsh/cmds/modules/unmount/unmount.c
===================================================================
--- uspace/app/bdsh/cmds/modules/unmount/unmount.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/bdsh/cmds/modules/unmount/unmount.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -47,5 +47,5 @@
 	} else {
 		help_cmd_unmount(HELP_SHORT);
-		printf("Usage:  %s <mp>\n", cmdname);
+		printf("Usage: %s <mp>\n", cmdname);
 	}
 	return;
@@ -68,5 +68,5 @@
 	rc = unmount(argv[1]);
 	if (rc != EOK) {
-		printf("Unable to unmount %s (rc=%d)\n", argv[1]);
+		printf("Unable to unmount %s (rc=%d)\n", argv[1], rc);
 		return CMD_FAILURE;
 	}
Index: uspace/app/bdsh/exec.c
===================================================================
--- uspace/app/bdsh/exec.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/bdsh/exec.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -133,5 +133,6 @@
 	rc = task_wait(tid, &texit, &retval);
 	if (rc != EOK) {
-		printf("%s: Failed waiting for command (%s)\n", str_error(rc));
+		printf("%s: Failed waiting for command (%s)\n", progname,
+		    str_error(rc));
 	} else if (texit != TASK_EXIT_NORMAL) {
 		printf("%s: Command failed (unexpectedly terminated)\n", progname);
Index: uspace/app/edit/edit.c
===================================================================
--- uspace/app/edit/edit.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/edit/edit.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -781,5 +781,5 @@
 			c = str_decode(row_buf, &pos, size);
 			if (c != '\t') {
-				printf("%lc", c);
+				printf("%lc", (wint_t) c);
 				s_column += 1;
 			} else {
@@ -830,5 +830,7 @@
 	int n = printf(" %d, %d: File '%s'. Ctrl-Q Quit  Ctrl-S Save  "
 	    "Ctrl-E Save As", coord.row, coord.column, fname);
-	printf("%*s", scr_columns - 1 - n, "");
+	
+	int pos = scr_columns - 1 - n;
+	printf("%*s", pos, "");
 	fflush(stdout);
 	console_set_style(con, STYLE_NORMAL);
@@ -1153,5 +1155,7 @@
 	console_set_pos(con, 0, scr_rows - 1);
 	console_set_style(con, STYLE_INVERTED);
-	printf(" %*s ", -(scr_columns - 3), str);
+	
+	int pos = -(scr_columns - 3);
+	printf(" %*s ", pos, str);
 	fflush(stdout);
 	console_set_style(con, STYLE_NORMAL);
Index: uspace/app/netecho/netecho.c
===================================================================
--- uspace/app/netecho/netecho.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/netecho/netecho.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -220,5 +220,5 @@
 	// check the buffer size
 	if (size <= 0) {
-		fprintf(stderr, "Receive size too small (%d). Using 1024 bytes instead.\n", size);
+		fprintf(stderr, "Receive size too small (%zu). Using 1024 bytes instead.\n", size);
 		size = 1024;
 	}
@@ -262,5 +262,5 @@
 		// check the backlog
 		if (backlog <= 0) {
-			fprintf(stderr, "Accepted sockets queue size too small (%d). Using 3 instead.\n", size);
+			fprintf(stderr, "Accepted sockets queue size too small (%zu). Using 3 instead.\n", size);
 			backlog = 3;
 		}
@@ -325,5 +325,6 @@
 						break;
 					default:
-						fprintf(stderr, "Address family %d (0x%X) is not supported.\n", address->sa_family);
+						fprintf(stderr, "Address family %u (%#x) is not supported.\n",
+						    address->sa_family, address->sa_family);
 					}
 					// parse the source address
@@ -334,5 +335,6 @@
 						} else {
 							data[length] = '\0';
-							printf("Socket %d received %d bytes from %s:%d\n%s\n", socket_id, length, address_string, port, data);
+							printf("Socket %d received %zu bytes from %s:%d\n%s\n",
+							    socket_id, length, address_string, port, data);
 						}
 					}
Index: uspace/app/nettest1/nettest1.c
===================================================================
--- uspace/app/nettest1/nettest1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/nettest1/nettest1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -356,5 +356,5 @@
 	/* Check data buffer size */
 	if (size <= 0) {
-		fprintf(stderr, "Data buffer size too small (%d). Using 1024 "
+		fprintf(stderr, "Data buffer size too small (%zu). Using 1024 "
 		    "bytes instead.\n", size);
 		size = 1024;
@@ -410,5 +410,5 @@
 	}
 
-	printf("Tested in %d microseconds\n", tv_sub(&time_after,
+	printf("Tested in %ld microseconds\n", tv_sub(&time_after,
 	    &time_before));
 
Index: uspace/app/nettest2/nettest2.c
===================================================================
--- uspace/app/nettest2/nettest2.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/nettest2/nettest2.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -302,5 +302,5 @@
 	/* Check data buffer size. */
 	if (size <= 0) {
-		fprintf(stderr, "Data buffer size too small (%d). Using 1024 "
+		fprintf(stderr, "Data buffer size too small (%zu). Using 1024 "
 		    "bytes instead.\n", size);
 		size = 1024;
@@ -375,5 +375,5 @@
 		printf("\tOK\n");
 
-	printf("sendto + recvfrom tested in %d microseconds\n",
+	printf("sendto + recvfrom tested in %ld microseconds\n",
 	    tv_sub(&time_after, &time_before));
 
@@ -403,5 +403,5 @@
 		printf("\tOK\n");
 
-	printf("sendto, recvfrom tested in %d microseconds\n",
+	printf("sendto, recvfrom tested in %ld microseconds\n",
 	    tv_sub(&time_after, &time_before));
 
Index: uspace/app/ping/ping.c
===================================================================
--- uspace/app/ping/ping.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/ping/ping.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -337,5 +337,5 @@
 	}
 	
-	printf("PING %s (%s) %u(%u) bytes of data\n", config.dest_addr,
+	printf("PING %s (%s) %zu(%zu) bytes of data\n", config.dest_addr,
 	    config.dest_str, config.size, config.size);
 	
@@ -378,9 +378,9 @@
 		switch (result) {
 		case ICMP_ECHO:
-			printf("%u bytes from ? (?): icmp_seq=%u ttl=? time=%u.%04u\n",
+			printf("%zu bytes from ? (?): icmp_seq=%u ttl=? time=%ld.%04ld\n",
 				config.size, seq, elapsed / 1000, elapsed % 1000);
 			break;
 		case ETIMEOUT:
-			printf("%u bytes from ? (?): icmp_seq=%u Timed out\n",
+			printf("%zu bytes from ? (?): icmp_seq=%u Timed out\n",
 				config.size, seq);
 			break;
Index: uspace/app/redir/redir.c
===================================================================
--- uspace/app/redir/redir.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/redir/redir.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -78,5 +78,5 @@
 {
 	const char **args;
-	task_id_t id;
+	task_id_t id = 0;
 	int rc;
 
Index: uspace/app/stats/stats.c
===================================================================
--- uspace/app/stats/stats.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/stats/stats.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -56,10 +56,12 @@
 	
 	uint64_t sec = time.tv_sec;
-	printf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64, (sec % DAY) / HOUR,
-	    (sec % HOUR) / MINUTE, sec % MINUTE);
+	printf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64,
+	    (sec % DAY) / HOUR, (sec % HOUR) / MINUTE, sec % MINUTE);
 	
 	sysarg_t uptime = stats_get_uptime();
-	printf(", up %u days, %u hours, %u minutes, %u seconds", uptime / DAY,
-	    (uptime % DAY) / HOUR, (uptime % HOUR) / MINUTE, uptime % MINUTE);
+	printf(", up %" PRIun " days, %" PRIun " hours, "
+	    "%" PRIun " minutes, %" PRIun " seconds",
+	    uptime / DAY, (uptime % DAY) / HOUR,
+	    (uptime % HOUR) / MINUTE, uptime % MINUTE);
 	
 	size_t count;
Index: uspace/app/taskdump/taskdump.c
===================================================================
--- uspace/app/taskdump/taskdump.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/taskdump/taskdump.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -85,5 +85,5 @@
 	rc = connect_task(task_id);
 	if (rc < 0) {
-		printf("Failed connecting to task %" PRIdTASKID ".\n", task_id);
+		printf("Failed connecting to task %" PRIu64 ".\n", task_id);
 		return 1;
 	}
@@ -92,5 +92,5 @@
 	app_symtab = NULL;
 
-	printf("Dumping task '%s' (task ID %" PRIdTASKID ").\n", app_name, task_id);
+	printf("Dumping task '%s' (task ID %" PRIu64 ").\n", app_name, task_id);
 	autoload_syms();
 	putchar('\n');
@@ -126,5 +126,5 @@
 	if (rc < 0) {
 		printf("Error connecting\n");
-		printf("ipc_connect_task(%" PRIdTASKID ") -> %d ", task_id, rc);
+		printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc);
 		return rc;
 	}
@@ -168,5 +168,5 @@
 				core_file_name = *argv;
 			} else {
-				printf("Uknown option '%s'\n", arg[0]);
+				printf("Uknown option '%c'\n", arg[0]);
 				print_syntax();
 				return -1;
@@ -240,5 +240,5 @@
 	printf("Threads:\n");
 	for (i = 0; i < n_threads; i++) {
-		printf(" [%d] hash: %p\n", 1+i, thash_buf[i]);
+		printf(" [%zu] hash: %p\n", 1 + i, (void *) thash_buf[i]);
 
 		thread_dump(thash_buf[i]);
@@ -284,10 +284,10 @@
 	printf("Address space areas:\n");
 	for (i = 0; i < n_areas; i++) {
-		printf(" [%d] flags: %c%c%c%c base: %p size: %p\n", 1+i,
+		printf(" [%zu] flags: %c%c%c%c base: %p size: %zu\n", 1 + i,
 		    (ainfo_buf[i].flags & AS_AREA_READ) ? 'R' : '-',
 		    (ainfo_buf[i].flags & AS_AREA_WRITE) ? 'W' : '-',
 		    (ainfo_buf[i].flags & AS_AREA_EXEC) ? 'X' : '-',
 		    (ainfo_buf[i].flags & AS_AREA_CACHEABLE) ? 'C' : '-',
-		    ainfo_buf[i].start_addr, ainfo_buf[i].size);
+		    (void *) ainfo_buf[i].start_addr, ainfo_buf[i].size);
 	}
 
@@ -326,5 +326,6 @@
 
 	sym_pc = fmt_sym_address(pc);
-	printf("Thread %p crashed at %s. FP = %p\n", thash, sym_pc, fp);
+	printf("Thread %p crashed at %s. FP = %p\n", (void *) thash,
+	    sym_pc, (void *) fp);
 	free(sym_pc);
 
@@ -334,5 +335,5 @@
 	while (stacktrace_fp_valid(&st, fp)) {
 		sym_pc = fmt_sym_address(pc);
-		printf("  %p: %s\n", fp, sym_pc);
+		printf("  %p: %s\n", (void *) fp, sym_pc);
 		free(sym_pc);
 
@@ -457,7 +458,7 @@
 
 	if (rc == EOK) {
-		rc = asprintf(&str, "%p (%s+%p)", addr, name, offs);
+		rc = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);
 	} else {
-		rc = asprintf(&str, "%p", addr);
+		rc = asprintf(&str, "%p", (void *) addr);
 	}
 
Index: uspace/app/tasks/tasks.c
===================================================================
--- uspace/app/tasks/tasks.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tasks/tasks.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -77,5 +77,5 @@
 		order_suffix(stats_tasks[i].kcycles, &kcycles, &ksuffix);
 		
-		printf("%8" PRIu64 "%8u %8" PRIu64"%c %12"
+		printf("%8" PRIu64 "%8zu %8" PRIu64 "%c %12"
 		    PRIu64 "%c %12" PRIu64 "%c %s\n", stats_tasks[i].task_id,
 		    stats_tasks[i].threads, virtmem, vmsuffix, ucycles, usuffix,
@@ -160,5 +160,5 @@
 	}
 	
-	printf("%s: %u CPU(s) detected\n", NAME, count);
+	printf("%s: %zu CPU(s) detected\n", NAME, count);
 	
 	size_t i;
Index: uspace/app/test_serial/Makefile
===================================================================
--- uspace/app/test_serial/Makefile	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../..
-BINARY = test_serial
-
-SOURCES = \
-	test_serial.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/test_serial/test_serial.c
===================================================================
--- uspace/app/test_serial/test_serial.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ 	(revision )
@@ -1,166 +1,0 @@
-/*
- * Copyright (c) 2009 Lenka Trochtova
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup test_serial
- * @brief	test the serial port driver - read from the serial port
- * @{
- */
-/**
- * @file
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ipc/ipc.h>
-#include <sys/types.h>
-#include <async.h>
-#include <ipc/services.h>
-#include <ipc/devman.h>
-#include <devman.h>
-#include <device/char.h>
-#include <str.h>
-#include <ipc/serial_ctl.h>
-
-#define NAME 		"test serial"
-
-
-static void print_usage(void)
-{
-	printf("Usage: \n test_serial count \n where count is the number of "
-	    "characters to be read\n");
-}
-
-int main(int argc, char *argv[])
-{
-	if (argc != 2) {
-		printf(NAME ": incorrect number of arguments.\n");
-		print_usage();
-		return 0;
-	}
-	
-	long int cnt = strtol(argv[1], NULL, 10);
-	
-	int res;
-	res = devman_get_phone(DEVMAN_CLIENT, IPC_FLAG_BLOCKING);
-	devman_handle_t handle;
-	
-	res = devman_device_get_handle("/hw/pci0/00:01.0/com1", &handle,
-	    IPC_FLAG_BLOCKING);
-	if (EOK != res) {
-		printf(NAME ": could not get the device handle, errno = %d.\n",
-		    -res);
-		return 1;
-	}
-	
-	printf(NAME ": trying to read %d characters from device with handle "
-	    "%d.\n", cnt, handle);
-	
-	int phone = devman_device_connect(handle, IPC_FLAG_BLOCKING);
-	if (0 > phone) {
-		printf(NAME ": could not connect to the device, errno = %d.\n",
-		    -res);
-		devman_hangup_phone(DEVMAN_CLIENT);
-		return 2;
-	}
-	
-	char *buf = (char *) malloc(cnt + 1);
-	if (NULL == buf) {
-		printf(NAME ": failed to allocate the input buffer\n");
-		ipc_hangup(phone);
-		devman_hangup_phone(DEVMAN_CLIENT);
-		return 3;
-	}
-	
-	ipcarg_t old_baud, old_par, old_stop, old_word_size;
-	
-	res = ipc_call_sync_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
-	    &old_par, &old_word_size, &old_stop);
-	if (EOK != res) {
-		printf(NAME ": failed to get old communication parameters, "
-		    "errno = %d.\n", -res);
-		devman_hangup_phone(DEVMAN_CLIENT);
-		ipc_hangup(phone);
-		free(buf);
-		return 4;
-	}
-	
-	res = ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, 1200,
-	    SERIAL_NO_PARITY, 8, 1);
-	if (EOK != res) {
-		printf(NAME ": failed to set communication parameters, errno = "
-		    "%d.\n", -res);
-		devman_hangup_phone(DEVMAN_CLIENT);
-		ipc_hangup(phone);
-		free(buf);
-		return 4;
-	}
-	
-	int total = 0;
-	int read = 0;
-	while (total < cnt) {
-		read = read_dev(phone, buf, cnt - total);
-		if (0 > read) {
-			printf(NAME ": failed read from device, errno = %d.\n",
-			    -read);
-			ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
-			    old_par, old_word_size, old_stop);
-			ipc_hangup(phone);
-			devman_hangup_phone(DEVMAN_CLIENT);
-			free(buf);
-			return 5;
-		}
-		total += read;
-		if (read > 0) {
-			buf[read] = 0;
-			printf(buf);
-			/*
-			 * Write data back to the device to test the opposite
-			 * direction of data transfer.
-			 */
-			write_dev(phone, buf, read);
-		} else {
-			usleep(100000);
-		}	
-	}
-	
-	const char *the_end = "\n---------\nTHE END\n---------\n";
-	write_dev(phone, (void *)the_end, str_size(the_end));
-	
-	/* restore original communication settings */
-	ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, old_par,
-	    old_word_size, old_stop);
-	devman_hangup_phone(DEVMAN_CLIENT);
-	ipc_hangup(phone);
-	free(buf);
-	
-	return 0;
-}
-
-/** @}
- */
Index: uspace/app/tester/Makefile
===================================================================
--- uspace/app/tester/Makefile	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/Makefile	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -38,4 +38,5 @@
 	print/print3.c \
 	print/print4.c \
+	print/print5.c \
 	console/console1.c \
 	stdio/stdio1.c \
@@ -49,5 +50,6 @@
 	ipc/connect.c \
 	loop/loop1.c \
-	mm/malloc1.c
+	mm/malloc1.c \
+	hw/serial/serial1.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
+++ uspace/app/tester/hw/serial/serial1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2009 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup tester
+ * @brief Test the serial port driver - loopback test
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <inttypes.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ipc/ipc.h>
+#include <sys/types.h>
+#include <async.h>
+#include <ipc/services.h>
+#include <ipc/devman.h>
+#include <devman.h>
+#include <device/char.h>
+#include <str.h>
+#include <ipc/serial_ctl.h>
+#include "../../tester.h"
+
+#define DEFAULT_COUNT  1024
+#define DEFAULT_SLEEP  100000
+#define EOT            "####> End of transfer <####\n"
+
+const char *test_serial1(void)
+{
+	size_t cnt;
+	
+	if (test_argc < 1)
+		cnt = DEFAULT_COUNT;
+	else
+		switch (str_size_t(test_argv[0], NULL, 0, true, &cnt)) {
+		case EOK:
+			break;
+		case EINVAL:
+			return "Invalid argument, unsigned integer expected";
+		case EOVERFLOW:
+			return "Argument size overflow";
+		default:
+			return "Unexpected argument error";
+		}
+	
+	int res = devman_get_phone(DEVMAN_CLIENT, IPC_FLAG_BLOCKING);
+	
+	devman_handle_t handle;
+	res = devman_device_get_handle("/hw/pci0/00:01.0/com1", &handle,
+	    IPC_FLAG_BLOCKING);
+	if (res != EOK)
+		return "Could not get serial device handle";
+	
+	int phone = devman_device_connect(handle, IPC_FLAG_BLOCKING);
+	if (phone < 0) {
+		devman_hangup_phone(DEVMAN_CLIENT);
+		return "Unable to connect to serial device";
+	}
+	
+	char *buf = (char *) malloc(cnt + 1);
+	if (buf == NULL) {
+		ipc_hangup(phone);
+		devman_hangup_phone(DEVMAN_CLIENT);
+		return "Failed to allocate input buffer";
+	}
+	
+	ipcarg_t old_baud;
+	ipcarg_t old_par;
+	ipcarg_t old_stop;
+	ipcarg_t old_word_size;
+	
+	res = ipc_call_sync_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
+	    &old_par, &old_word_size, &old_stop);
+	if (res != EOK) {
+		free(buf);
+		ipc_hangup(phone);
+		devman_hangup_phone(DEVMAN_CLIENT);
+		return "Failed to get old serial communication parameters";
+	}
+	
+	res = ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, 1200,
+	    SERIAL_NO_PARITY, 8, 1);
+	if (EOK != res) {
+		free(buf);
+		ipc_hangup(phone);
+		devman_hangup_phone(DEVMAN_CLIENT);
+		return "Failed to set serial communication parameters";
+	}
+	
+	TPRINTF("Trying to read %zu characters from serial device "
+	    "(handle=%" PRIun ")\n", cnt, handle);
+	
+	size_t total = 0;
+	while (total < cnt) {
+		ssize_t read = read_dev(phone, buf, cnt - total);
+		
+		if (read < 0) {
+			ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+			    old_par, old_word_size, old_stop);
+			free(buf);
+			ipc_hangup(phone);
+			devman_hangup_phone(DEVMAN_CLIENT);
+			return "Failed read from serial device";
+		}
+		
+		if ((size_t) read > cnt - total) {
+			ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+			    old_par, old_word_size, old_stop);
+			free(buf);
+			ipc_hangup(phone);
+			devman_hangup_phone(DEVMAN_CLIENT);
+			return "Read more data than expected";
+		}
+		
+		TPRINTF("Read %zd bytes\n", read);
+		
+		if (read == 0)
+			usleep(DEFAULT_SLEEP);
+		else {
+			buf[read] = 0;
+			
+			/*
+			 * Write data back to the device to test the opposite
+			 * direction of data transfer.
+			 */
+			ssize_t written = write_dev(phone, buf, read);
+			
+			if (written < 0) {
+				ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+				    old_par, old_word_size, old_stop);
+				free(buf);
+				ipc_hangup(phone);
+				devman_hangup_phone(DEVMAN_CLIENT);
+				return "Failed write to serial device";
+			}
+			
+			if (written != read) {
+				ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+				    old_par, old_word_size, old_stop);
+				free(buf);
+				ipc_hangup(phone);
+				devman_hangup_phone(DEVMAN_CLIENT);
+				return "Written less data than read from serial device";
+			}
+			
+			TPRINTF("Written %zd bytes\n", written);
+		}
+		
+		total += read;
+	}
+	
+	TPRINTF("Trying to write EOT banner to the serial device\n");
+	
+	size_t eot_size = str_size(EOT);
+	ssize_t written = write_dev(phone, (void *) EOT, eot_size);
+	
+	ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+	    old_par, old_word_size, old_stop);
+	free(buf);
+	ipc_hangup(phone);
+	devman_hangup_phone(DEVMAN_CLIENT);
+	
+	if (written < 0)
+		return "Failed to write EOT banner to serial device";
+	
+	if ((size_t) written != eot_size)
+		return "Written less data than the size of the EOT banner "
+		    "to serial device";
+	
+	return NULL;
+}
+
+/** @}
+ */
Index: uspace/app/tester/hw/serial/serial1.def
===================================================================
--- uspace/app/tester/hw/serial/serial1.def	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
+++ uspace/app/tester/hw/serial/serial1.def	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -0,0 +1,6 @@
+{
+	"serial1",
+	"Serial loopback test",
+	&test_serial1,
+	false
+},
Index: uspace/app/tester/ipc/ping_pong.c
===================================================================
--- uspace/app/tester/ipc/ping_pong.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/ipc/ping_pong.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -72,5 +72,5 @@
 	}
 	
-	TPRINTF("OK\nCompleted %llu round trips in %u seconds, %llu rt/s.\n",
+	TPRINTF("OK\nCompleted %" PRIu64 " round trips in %u seconds, %" PRIu64 " rt/s.\n",
 	    count, DURATION_SECS, count / DURATION_SECS);
 	
Index: uspace/app/tester/ipc/register.c
===================================================================
--- uspace/app/tester/ipc/register.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/ipc/register.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -27,4 +27,5 @@
  */
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -41,5 +42,5 @@
 	unsigned int i;
 	
-	TPRINTF("Connected phone %#x accepting\n", icall->in_phone_hash);
+	TPRINTF("Connected phone %" PRIun " accepting\n", icall->in_phone_hash);
 	ipc_answer_0(iid, EOK);
 	for (i = 0; i < MAX_CONNECTIONS; i++) {
@@ -57,14 +58,14 @@
 		switch (IPC_GET_METHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
-			TPRINTF("Phone %#x hung up\n", icall->in_phone_hash);
+			TPRINTF("Phone %" PRIun " hung up\n", icall->in_phone_hash);
 			retval = 0;
 			break;
 		case IPC_TEST_METHOD:
-			TPRINTF("Received well known message from %#x: %#x\n",
+			TPRINTF("Received well known message from %" PRIun ": %" PRIun "\n",
 			    icall->in_phone_hash, callid);
 			ipc_answer_0(callid, EOK);
 			break;
 		default:
-			TPRINTF("Received unknown message from %#x: %#x\n",
+			TPRINTF("Received unknown message from %" PRIun ": %" PRIun "\n",
 			    icall->in_phone_hash, callid);
 			ipc_answer_0(callid, ENOENT);
Index: uspace/app/tester/print/print1.c
===================================================================
--- uspace/app/tester/print/print1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/print/print1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -49,8 +49,4 @@
 	TPRINTF("Real output:     \"%8.10s\"\n\n", "very long text");
 	
-	TPRINTF("Testing printf(\"%%s\", NULL):\n");
-	TPRINTF("Expected output: \"(NULL)\"\n");
-	TPRINTF("Real output:     \"%s\"\n\n", NULL);
-	
 	return NULL;
 }
Index: uspace/app/tester/print/print2.c
===================================================================
--- uspace/app/tester/print/print2.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/print/print2.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -33,7 +33,7 @@
 const char *test_print2(void)
 {
-	TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
-	TPRINTF("Expected output: [a] [  b] [c  ] [ d] [e ]\n");
-	TPRINTF("Real output:     [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e');
+	TPRINTF("Testing printf(\"%%c\", 'a'):\n");
+	TPRINTF("Expected output: [a]\n");
+	TPRINTF("Real output:     [%c]\n\n", 'a');
 	
 	TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n");
Index: uspace/app/tester/print/print4.c
===================================================================
--- uspace/app/tester/print/print4.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/print/print4.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -45,5 +45,5 @@
 		TPRINTF("  ");
 		for (index = 0; index < 32; index++)
-			TPRINTF("%lc", (wchar_t) ((group << 5) + index));
+			TPRINTF("%lc", (wint_t) ((group << 5) + index));
 		
 		TPRINTF("\n");
@@ -57,5 +57,5 @@
 		uint8_t index;
 		for (index = 0; index < 32; index++)
-			TPRINTF("%lc", (wchar_t) ((group << 5) + index));
+			TPRINTF("%lc", (wint_t) ((group << 5) + index));
 		
 		TPRINTF("\n");
Index: uspace/app/tester/print/print5.c
===================================================================
--- uspace/app/tester/print/print5.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
+++ uspace/app/tester/print/print5.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This test tests several features of the HelenOS
+ * printf() implementation which go beyond the POSIX
+ * specification and GNU printf() behaviour.
+ *
+ * Therefore we disable printf() argument checking by
+ * the GCC compiler in this source file to avoid false
+ * positives.
+ *
+ */
+#define NVERIFY_PRINTF
+
+#include <stdio.h>
+#include <unistd.h>
+#include "../tester.h"
+
+const char *test_print5(void)
+{
+	TPRINTF("Testing printf(\"%%s\", NULL):\n");
+	TPRINTF("Expected output: \"(NULL)\"\n");
+	TPRINTF("Real output:     \"%s\"\n\n", (char *) NULL);
+	
+	TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
+	TPRINTF("Expected output: [a] [  b] [c  ] [ d] [e ]\n");
+	TPRINTF("Real output:     [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e');
+	
+	return NULL;
+}
Index: uspace/app/tester/print/print5.def
===================================================================
--- uspace/app/tester/print/print5.def	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
+++ uspace/app/tester/print/print5.def	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -0,0 +1,6 @@
+{
+	"print1",
+	"String printf test",
+	&test_print1,
+	true
+},
Index: uspace/app/tester/stdio/stdio1.c
===================================================================
--- uspace/app/tester/stdio/stdio1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/stdio/stdio1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -60,5 +60,5 @@
 	
 	buf[cnt] = '\0';
-	TPRINTF("Read %u bytes, string \"%s\"\n", cnt, buf);
+	TPRINTF("Read %zu bytes, string \"%s\"\n", cnt, buf);
 	
 	TPRINTF("Seek to beginning...");
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/tester.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -51,4 +51,5 @@
 #include "print/print3.def"
 #include "print/print4.def"
+#include "print/print5.def"
 #include "console/console1.def"
 #include "stdio/stdio1.def"
@@ -63,4 +64,5 @@
 #include "loop/loop1.def"
 #include "mm/malloc1.def"
+#include "hw/serial/serial1.def"
 	{NULL, NULL, NULL, false}
 };
@@ -110,8 +112,15 @@
 	}
 	
+	unsigned int _len = (unsigned int) len;
+	if ((_len != len) || (((int) _len) < 0)) {
+		printf("Command length overflow\n");
+		return;
+	}
+	
 	for (test = tests; test->name != NULL; test++)
-		printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
+		printf("%-*s %s%s\n", _len, test->name, test->desc,
+		    (test->safe ? "" : " (unsafe)"));
 	
-	printf("%-*s Run all safe tests\n", len, "*");
+	printf("%-*s Run all safe tests\n", _len, "*");
 }
 
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/tester.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -68,4 +68,5 @@
 extern const char *test_print3(void);
 extern const char *test_print4(void);
+extern const char *test_print5(void);
 extern const char *test_console1(void);
 extern const char *test_stdio1(void);
@@ -80,4 +81,5 @@
 extern const char *test_loop1(void);
 extern const char *test_malloc1(void);
+extern const char *test_serial1(void);
 
 extern test_t tests[];
Index: uspace/app/tester/thread/thread1.c
===================================================================
--- uspace/app/tester/thread/thread1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/thread/thread1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -35,4 +35,5 @@
 #include <stdio.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include "../tester.h"
 
@@ -74,5 +75,6 @@
 	atomic_set(&finish, 0);
 	while (atomic_get(&threads_finished) < total) {
-		TPRINTF("Threads left: %u\n", total - atomic_get(&threads_finished));
+		TPRINTF("Threads left: %" PRIua "\n",
+		    total - atomic_get(&threads_finished));
 		sleep(1);
 	}
Index: uspace/app/tester/vfs/vfs1.c
===================================================================
--- uspace/app/tester/vfs/vfs1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/tester/vfs/vfs1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -105,5 +105,5 @@
 	if (cnt < 0)
 		return "write() failed";
-	TPRINTF("Written %d bytes\n", cnt);
+	TPRINTF("Written %zd bytes\n", cnt);
 	
 	if (lseek(fd0, 0, SEEK_SET) != 0)
@@ -116,5 +116,11 @@
 			return "read() failed";
 		
-		TPRINTF("Read %d bytes: \".*s\"\n", cnt, cnt, buf);
+		int _cnt = (int) cnt;
+		if (_cnt != cnt) {
+			/* Count overflow, just to be sure. */
+			TPRINTF("Read %zd bytes\n", cnt);
+		} else {
+			TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf);
+		}
 	}
 	
Index: uspace/app/top/screen.c
===================================================================
--- uspace/app/top/screen.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/top/screen.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -150,11 +150,15 @@
 	screen_get_pos(&c, &r);
 	
-	if (c < cols)
-		printf("%.*s", cols - c - 1, str);
+	if (c < cols) {
+		int pos = cols - c - 1;
+		printf("%.*s", pos, str);
+	}
 }
 
 static inline void print_global_head(data_t *data)
 {
-	printf("top - %02lu:%02lu:%02lu up %u days, %02u:%02u:%02u, load average:",
+	printf("top - %02lu:%02lu:%02lu up "
+	    "%" PRIun " days, %02" PRIun ":%02" PRIun ":%02" PRIun ", "
+	    "load average:",
 	    data->hours, data->minutes, data->seconds,
 	    data->udays, data->uhours, data->uminutes, data->useconds);
@@ -171,5 +175,5 @@
 static inline void print_task_summary(data_t *data)
 {
-	printf("tasks: %u total", data->tasks_count);
+	printf("tasks: %zu total", data->tasks_count);
 	screen_newline();
 }
@@ -211,6 +215,6 @@
 	}
 	
-	printf("threads: %u total, %u running, %u ready, %u sleeping, %u lingering, "
-	    "%u other, %u invalid",
+	printf("threads: %zu total, %zu running, %zu ready, "
+	    "%zu sleeping, %zu lingering, %zu other, %zu invalid",
 	    total, running, ready, sleeping, lingering, other, invalid);
 	screen_newline();
@@ -295,5 +299,5 @@
 		order_suffix(task->virtmem, &virtmem, &virtmem_suffix);
 		
-		printf("%-8" PRIu64 " %9u %8" PRIu64 "%c ", task->task_id,
+		printf("%-8" PRIu64 " %9zu %8" PRIu64 "%c ", task->task_id,
 		    task->threads, virtmem, virtmem_suffix);
 		print_percent(perc->virtmem, 2);
Index: uspace/app/trace/ipcp.c
===================================================================
--- uspace/app/trace/ipcp.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/trace/ipcp.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -137,9 +137,9 @@
 
 	if (oper != NULL) {
-		printf("%s (%ld)", oper->name, method);
+		printf("%s (%" PRIun ")", oper->name, method);
 		return;
 	}
 
-	printf("%ld", method);
+	printf("%" PRIun, method);
 }
 
@@ -201,10 +201,11 @@
 
 	if ((display_mask & DM_IPC) != 0) {
-		printf("Call ID: %p, phone: %d, proto: %s, method: ", hash,
-			phone, (proto ? proto->name : "n/a"));
+		printf("Call ID: %p, phone: %d, proto: %s, method: ",
+		    (void *) hash, phone,
+		    (proto ? proto->name : "n/a"));
 		ipc_m_print(proto, IPC_GET_METHOD(*call));
-		printf(" args: (%" PRIuIPCARG ", %" PRIuIPCARG ", %" PRIuIPCARG
-		    ", %" PRIuIPCARG ", %" PRIuIPCARG ")\n", args[1], args[2],
-		    args[3], args[4], args[5]);
+		printf(" args: (%" PRIun ", %" PRIun ", %" PRIun ", "
+		    "%" PRIun ", %" PRIun ")\n",
+		    args[1], args[2], args[3], args[4], args[5]);
 	}
 
@@ -281,8 +282,7 @@
 
 	if ((display_mask & DM_IPC) != 0) {
-		printf("Response to %p: retval=%ld, args = (%" PRIuIPCARG
-		    ", %" PRIuIPCARG ", %" PRIuIPCARG ", %" PRIuIPCARG
-		    ", %" PRIuIPCARG ")\n",
-		    hash, retval, IPC_GET_ARG1(*answer),
+		printf("Response to %p: retval=%" PRIdn ", args = (%" PRIun ", "
+		    "%" PRIun ", %" PRIun ", %" PRIun ", %" PRIun ")\n",
+		    (void *) hash, retval, IPC_GET_ARG1(*answer),
 		    IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer),
 		    IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer));
@@ -340,5 +340,5 @@
 		/* Not a response */
 		if ((display_mask & DM_IPC) != 0) {
-			printf("Not a response (hash %p)\n", hash);
+			printf("Not a response (hash %p)\n", (void *) hash);
 		}
 		return;
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/trace/trace.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -161,5 +161,5 @@
 	if (rc < 0) {
 		printf("Error connecting\n");
-		printf("ipc_connect_task(%" PRIdTASKID ") -> %d ", task_id, rc);
+		printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc);
 		return rc;
 	}
@@ -200,7 +200,7 @@
 	printf("Threads:");
 	for (i = 0; i < n_threads; i++) {
-		printf(" [%d] (hash %p)", 1+i, thread_hash_buf[i]);
-	}
-	printf("\ntotal of %u threads\n", tb_needed / sizeof(uintptr_t));
+		printf(" [%d] (hash %p)", 1 + i, (void *) thread_hash_buf[i]);
+	}
+	printf("\ntotal of %zu threads\n", tb_needed / sizeof(uintptr_t));
 
 	return 0;
@@ -224,5 +224,5 @@
 	case V_HASH:
 	case V_PTR:
-		printf("%p", val);
+		printf("%p", (void *) val);
 		break;
 
@@ -248,5 +248,5 @@
 	case V_CHAR:
 		if (sval >= 0x20 && sval < 0x7f) {
-			printf("'%c'", sval);
+			printf("'%c'", (char) sval);
 		} else {
 			switch (sval) {
@@ -257,5 +257,5 @@
 			case '\t': printf("'\\t'"); break;
 			case '\\': printf("'\\\\'"); break;
-			default: printf("'\\x%02lX'", val); break;
+			default: printf("'\\x%02" PRIxn "'", val); break;
 			}
 		}
@@ -277,7 +277,7 @@
 
 	putchar('(');
-	if (n > 0) printf("%" PRIdSYSARG, sc_args[0]);
+	if (n > 0) printf("%" PRIun, sc_args[0]);
 	for (i = 1; i < n; i++) {
-		printf(", %" PRIdSYSARG, sc_args[i]);
+		printf(", %" PRIun, sc_args[i]);
 	}
 	putchar(')');
@@ -489,5 +489,5 @@
 {
 	async_serialize_start();
-	printf("New thread, hash 0x%lx\n", hash);
+	printf("New thread, hash %p\n", (void *) hash);
 	async_serialize_end();
 
@@ -510,5 +510,6 @@
 	}
 
-	printf("Start tracing thread [%d] (hash %p).\n", thread_id, thread_hash);
+	printf("Start tracing thread [%u] (hash %p).\n",
+	    thread_id, (void *) thread_hash);
 
 	while (!abort_trace) {
@@ -516,5 +517,5 @@
 		fibril_mutex_lock(&state_lock);
 		if (paused) {
-			printf("Thread [%d] paused. Press R to resume.\n",
+			printf("Thread [%u] paused. Press R to resume.\n",
 			    thread_id);
 
@@ -522,5 +523,5 @@
 				fibril_condvar_wait(&state_cv, &state_lock);
 
-			printf("Thread [%d] resumed.\n", thread_id);
+			printf("Thread [%u] resumed.\n", thread_id);
 		}
 		fibril_mutex_unlock(&state_lock);
@@ -554,5 +555,5 @@
 				break;
 			case UDEBUG_EVENT_THREAD_E:
-				printf("Thread %p exited.\n", val0);
+				printf("Thread %" PRIun " exited.\n", val0);
 				fibril_mutex_lock(&state_lock);
 				abort_trace = true;
@@ -927,5 +928,5 @@
 				}
 			} else {
-				printf("Uknown option '%s'\n", arg[0]);
+				printf("Uknown option '%c'\n", arg[0]);
 				print_syntax();
 				return -1;
@@ -984,9 +985,9 @@
 	rc = connect_task(task_id);
 	if (rc < 0) {
-		printf("Failed connecting to task %" PRIdTASKID ".\n", task_id);
+		printf("Failed connecting to task %" PRIu64 ".\n", task_id);
 		return 1;
 	}
 
-	printf("Connected to task %" PRIdTASKID ".\n", task_id);
+	printf("Connected to task %" PRIu64 ".\n", task_id);
 
 	if (task_ldr != NULL)
Index: uspace/app/virtusbkbd/virtusbkbd.c
===================================================================
--- uspace/app/virtusbkbd/virtusbkbd.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/app/virtusbkbd/virtusbkbd.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -170,5 +170,5 @@
 static void on_keyboard_change(kb_status_t *status)
 {
-	printf("%s: Current keyboard status: %08hhb", NAME, status->modifiers);
+	printf("%s: Current keyboard status: %02hhx", NAME, status->modifiers);
 	size_t i;
 	for (i = 0; i < KB_MAX_KEYS_AT_ONCE; i++) {
Index: uspace/drv/isa/isa.c
===================================================================
--- uspace/drv/isa/isa.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/drv/isa/isa.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -493,6 +493,5 @@
 	/* Add child devices. */
 	add_legacy_children(dev);
-	printf(NAME ": finished the enumeration of legacy devices\n",
-	    dev->handle);
+	printf(NAME ": finished the enumeration of legacy devices\n");
 
 	return EOK;
Index: uspace/drv/ns8250/ns8250.c
===================================================================
--- uspace/drv/ns8250/ns8250.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/drv/ns8250/ns8250.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -276,5 +276,5 @@
 	if (pio_enable((void *) data->io_addr, REG_COUNT,
 	    (void **) &data->port)) {
-		printf(NAME ": error - cannot gain the port %lx for device "
+		printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
 		    "%s.\n", data->io_addr, dev->name);
 		return false;
Index: uspace/drv/pciintel/pci.c
===================================================================
--- uspace/drv/pciintel/pci.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/drv/pciintel/pci.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -323,5 +323,5 @@
 	if (range_addr != 0) {
 		printf(NAME ": device %s : ", dev->name);
-		printf("address = %x", range_addr);
+		printf("address = %" PRIx64, range_addr);
 		printf(", size = %x\n", range_size);
 	}
@@ -479,5 +479,5 @@
 	}	
 	
-	printf(NAME ": conf_addr = %x.\n",
+	printf(NAME ": conf_addr = %" PRIx64 ".\n",
 	    hw_resources.resources[0].res.io_range.address);
 	
Index: uspace/drv/root/root.c
===================================================================
--- uspace/drv/root/root.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/drv/root/root.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -45,4 +45,5 @@
 #include <ctype.h>
 #include <macros.h>
+#include <inttypes.h>
 
 #include <driver.h>
@@ -180,5 +181,6 @@
 static int root_add_device(device_t *dev)
 {
-	printf(NAME ": root_add_device, device handle = %d\n", dev->handle);
+	printf(NAME ": root_add_device, device handle=%" PRIun "\n",
+	    dev->handle);
 	
 	/* Register root device's children. */
Index: uspace/lib/block/libblock.c
===================================================================
--- uspace/lib/block/libblock.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/block/libblock.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -816,6 +816,6 @@
 	    UPPER32(ba), cnt);
 	if (rc != EOK) {
-		printf("Error %d reading %d blocks starting at block %" PRIuOFF64
-		    " from device handle %d\n", rc, cnt, ba,
+		printf("Error %d reading %zu blocks starting at block %" PRIuOFF64
+		    " from device handle %" PRIun "\n", rc, cnt, ba,
 		    devcon->devmap_handle);
 #ifndef NDEBUG
@@ -843,6 +843,6 @@
 	    UPPER32(ba), cnt);
 	if (rc != EOK) {
-		printf("Error %d writing %d blocks starting at block %" PRIuOFF64
-		    " to device handle %d\n", rc, cnt, ba, devcon->devmap_handle);
+		printf("Error %d writing %zu blocks starting at block %" PRIuOFF64
+		    " to device handle %" PRIun "\n", rc, cnt, ba, devcon->devmap_handle);
 #ifndef NDEBUG
 		stacktrace_print();
Index: uspace/lib/c/arch/abs32le/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/abs32le/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -34,33 +34,8 @@
 #define LIBC_abs32le_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "d"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "o"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "X"
+#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/amd64/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/amd64/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/amd64/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_amd64_INTTYPES_H_
 #define LIBC_amd64_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "lld"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "llo"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "llu"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "llx"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "llX"
+#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/arm32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/arm32/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/arm32/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_arm32_INTTYPES_H_
 #define LIBC_arm32_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "d"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "o"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "X"
+#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/ia32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/ia32/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/ia32/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_ia32_INTTYPES_H_
 #define LIBC_ia32_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "d"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "o"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "X"
+#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/ia64/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/ia64/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/ia64/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_ia64_INTTYPES_H_
 #define LIBC_ia64_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "ld"
-#define PRIdPTR "ld"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "lo"
-#define PRIoPTR "lo"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "lu"
-#define PRIuPTR "lu"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "lx"
-#define PRIxPTR "lx"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "lX"
-#define PRIXPTR "lX"
+#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/mips32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/mips32/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/mips32/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_mips32_INTTYPES_H_
 #define LIBC_mips32_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "d"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "o"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "x"
+#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/ppc32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/ppc32/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_ppc32_INTTYPES_H_
 #define LIBC_ppc32_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "d"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "o"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "X"
+#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/arch/sparc64/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/inttypes.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/arch/sparc64/include/inttypes.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,44 +30,12 @@
  * @{
  */
-/** @file Macros for format specifiers.
- *
- * Macros for formatting stdint types as specified in section
- * 7.8.1 Macros for format specifiers of the C99 draft specification
- * (ISO/IEC 9899:201x). Only some macros from the specification are
- * implemented.
- */
 
 #ifndef LIBC_sparc64_INTTYPES_H_
 #define LIBC_sparc64_INTTYPES_H_
 
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "lld"
-#define PRIdPTR "lld"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "llo"
-#define PRIoPTR "llo"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "llu"
-#define PRIuPTR "llu"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "llx"
-#define PRIxPTR "llx"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "llX"
-#define PRIXPTR "llX"
+#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
 #endif
Index: uspace/lib/c/generic/device/char.c
===================================================================
--- uspace/lib/c/generic/device/char.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/generic/device/char.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
- 
+
  /** @addtogroup libc
  * @{
@@ -40,44 +40,48 @@
 #include <stdio.h>
 
-/** Read to or write from the device using its character interface.
- * 
- * Helper function.
- * 
- * @param dev_phone phone to the device.
- * @param buf the buffer for the data read from or written to the device.
- * @param len the maximum length of the data to be read or written.
- * @param read read from the device if true, write to it otherwise.
- * 
- * @return non-negative number of bytes actually read from or written to the device on success,
- * negative error number otherwise.
- * 
+/** Read to or write from device.
+ *
+ * Helper function to read to or write from a device
+ * using its character interface.
+ *
+ * @param dev_phone Phone to the device.
+ * @param buf       Buffer for the data read
+ *                  from or written to the device.
+ * @param len       Maximum length of the data to be
+ *                  read or written.
+ * @param read      Read from the device if true,
+ *                  write to it otherwise.
+ *
+ * @return Non-negative number of bytes actually read
+ *         from or written to the device on success,
+ *         negative error number otherwise.
+ *
  */
-static int rw_dev(int dev_phone, void *buf, size_t len, bool read) 
+static ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)
 {
-	ipc_call_t answer;
-	
 	async_serialize_start();
 	
+	ipc_call_t answer;
 	aid_t req;
 	int ret;
 	
 	if (read) {
-		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_READ_DEV, &answer);
-		ret = async_data_read_start(dev_phone, buf, len);		
+		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
+		    CHAR_READ_DEV, &answer);
+		ret = async_data_read_start(dev_phone, buf, len);
 	} else {
-		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_WRITE_DEV, &answer);
+		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
+		    CHAR_WRITE_DEV, &answer);
 		ret = async_data_write_start(dev_phone, buf, len);
 	}
 	
 	ipcarg_t rc;
-	if (ret != EOK) {		
+	if (ret != EOK) {
 		async_wait_for(req, &rc);
 		async_serialize_end();
-		if (rc == EOK) {
-			return ret;
-		}
-		else {
-			return (int) rc;
-		}
+		if (rc == EOK)
+			return (ssize_t) ret;
+			
+		return (ssize_t) rc;
 	}
 	
@@ -85,39 +89,45 @@
 	async_serialize_end();
 	
-	ret = (int)rc;
-	if (EOK != ret) {
-		return ret;
-	}
+	ret = (int) rc;
+	if (ret != EOK)
+		return (ssize_t) ret;
 	
-	return IPC_GET_ARG1(answer);	
+	return (ssize_t) IPC_GET_ARG1(answer);
 }
 
-/** Read from the device using its character interface.
- * 
- * @param dev_phone phone to the device.
- * @param buf the output buffer for the data read from the device.
- * @param len the maximum length of the data to be read.
- * 
- * @return non-negative number of bytes actually read from the device on success, negative error number otherwise.
+/** Read from device using its character interface.
+ *
+ * @param dev_phone Phone to the device.
+ * @param buf       Output buffer for the data
+ *                  read from the device.
+ * @param len       Maximum length of the data to be read.
+ *
+ * @return Non-negative number of bytes actually read
+ *         from the device on success, negative error
+ *         number otherwise.
+ *
  */
-int read_dev(int dev_phone, void *buf, size_t len)
-{	
+ssize_t read_dev(int dev_phone, void *buf, size_t len)
+{
 	return rw_dev(dev_phone, buf, len, true);
 }
 
-/** Write to the device using its character interface.
- * 
- * @param dev_phone phone to the device.
- * @param buf the input buffer containg the data to be written to the device.
- * @param len the maximum length of the data to be written.
- * 
- * @return non-negative number of bytes actually written to the device on success, negative error number otherwise.
+/** Write to device using its character interface.
+ *
+ * @param dev_phone Phone to the device.
+ * @param buf       Input buffer containg the data
+ *                  to be written to the device.
+ * @param len       Maximum length of the data to be written.
+ *
+ * @return Non-negative number of bytes actually written
+ *         to the device on success, negative error number
+ *         otherwise.
+ *
  */
-int write_dev(int dev_phone, void *buf, size_t len)
+ssize_t write_dev(int dev_phone, void *buf, size_t len)
 {
 	return rw_dev(dev_phone, buf, len, false);
 }
 
-  
- /** @}
+/** @}
  */
Index: uspace/lib/c/generic/io/printf_core.c
===================================================================
--- uspace/lib/c/generic/io/printf_core.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/generic/io/printf_core.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -82,5 +82,6 @@
 	PrintfQualifierLong,
 	PrintfQualifierLongLong,
-	PrintfQualifierPointer
+	PrintfQualifierPointer,
+	PrintfQualifierSize
 } qualifier_t;
 
@@ -552,7 +553,8 @@
  *  - ""   Signed or unsigned int (default value).@n
  *  - "l"  Signed or unsigned long int.@n
- *         If conversion is "c", the character is wchar_t (wide character).@n
+ *         If conversion is "c", the character is wint_t (wide character).@n
  *         If conversion is "s", the string is wchar_t * (wide string).@n
  *  - "ll" Signed or unsigned long long int.@n
+ *  - "z"  Signed or unsigned ssize_t or site_t.@n
  *
  * CONVERSION:@n
@@ -736,4 +738,9 @@
 				}
 				break;
+			case 'z':
+				qualifier = PrintfQualifierSize;
+				i = nxt;
+				uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
+				break;
 			default:
 				/* Default type */
@@ -763,5 +770,5 @@
 			case 'c':
 				if (qualifier == PrintfQualifierLong)
-					retval = print_wchar(va_arg(ap, wchar_t), width, flags, ps);
+					retval = print_wchar(va_arg(ap, wint_t), width, flags, ps);
 				else
 					retval = print_char(va_arg(ap, unsigned int), width, flags, ps);
@@ -849,4 +856,8 @@
 				precision = size << 1;
 				number = (uint64_t) (uintptr_t) va_arg(ap, void *);
+				break;
+			case PrintfQualifierSize:
+				size = sizeof(size_t);
+				number = (uint64_t) va_arg(ap, size_t);
 				break;
 			default:
Index: uspace/lib/c/generic/stacktrace.c
===================================================================
--- uspace/lib/c/generic/stacktrace.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/generic/stacktrace.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -50,5 +50,5 @@
 
 	while (stacktrace_fp_valid(&st, fp)) {
-		printf("%p: %p()\n", fp, pc);
+		printf("%p: %p()\n", (void *) fp, (void *) pc);
 		(void) stacktrace_ra_get(&st, fp, &pc);
 		(void) stacktrace_fp_prev(&st, fp, &nfp);
Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/generic/str.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -1005,4 +1005,210 @@
 	*end = '\0';
 	return start;
+}
+
+/** Convert string to uint64_t (internal variant).
+ *
+ * @param nptr   Pointer to string.
+ * @param endptr Pointer to the first invalid character is stored here.
+ * @param base   Zero or number between 2 and 36 inclusive.
+ * @param neg    Indication of unary minus is stored here.
+ * @apram result Result of the conversion.
+ *
+ * @return EOK if conversion was successful.
+ *
+ */
+static int str_uint(const char *nptr, char **endptr, unsigned int base,
+    bool *neg, uint64_t *result)
+{
+	assert(endptr != NULL);
+	assert(neg != NULL);
+	assert(result != NULL);
+	
+	*neg = false;
+	const char *str = nptr;
+	
+	/* Ignore leading whitespace */
+	while (isspace(*str))
+		str++;
+	
+	if (*str == '-') {
+		*neg = true;
+		str++;
+	} else if (*str == '+')
+		str++;
+	
+	if (base == 0) {
+		/* Decode base if not specified */
+		base = 10;
+		
+		if (*str == '0') {
+			base = 8;
+			str++;
+			
+			switch (*str) {
+			case 'b':
+			case 'B':
+				base = 2;
+				str++;
+				break;
+			case 'o':
+			case 'O':
+				base = 8;
+				str++;
+				break;
+			case 'd':
+			case 'D':
+			case 't':
+			case 'T':
+				base = 10;
+				str++;
+				break;
+			case 'x':
+			case 'X':
+				base = 16;
+				str++;
+				break;
+			default:
+				str--;
+			}
+		}
+	} else {
+		/* Check base range */
+		if ((base < 2) || (base > 36)) {
+			*endptr = (char *) str;
+			return EINVAL;
+		}
+	}
+	
+	*result = 0;
+	const char *startstr = str;
+	
+	while (*str != 0) {
+		unsigned int digit;
+		
+		if ((*str >= 'a') && (*str <= 'z'))
+			digit = *str - 'a' + 10;
+		else if ((*str >= 'A') && (*str <= 'Z'))
+			digit = *str - 'A' + 10;
+		else if ((*str >= '0') && (*str <= '9'))
+			digit = *str - '0';
+		else
+			break;
+		
+		if (digit >= base)
+			break;
+		
+		uint64_t prev = *result;
+		*result = (*result) * base + digit;
+		
+		if (*result < prev) {
+			/* Overflow */
+			*endptr = (char *) str;
+			return EOVERFLOW;
+		}
+		
+		str++;
+	}
+	
+	if (str == startstr) {
+		/*
+		 * No digits were decoded => first invalid character is
+		 * the first character of the string.
+		 */
+		str = nptr;
+	}
+	
+	*endptr = (char *) str;
+	
+	if (str == nptr)
+		return EINVAL;
+	
+	return EOK;
+}
+
+/** Convert string to uint64_t.
+ *
+ * @param nptr   Pointer to string.
+ * @param endptr If not NULL, pointer to the first invalid character
+ *               is stored here.
+ * @param base   Zero or number between 2 and 36 inclusive.
+ * @param strict Do not allow any trailing characters.
+ * @param result Result of the conversion.
+ *
+ * @return EOK if conversion was successful.
+ *
+ */
+int str_uint64(const char *nptr, char **endptr, unsigned int base,
+    bool strict, uint64_t *result)
+{
+	assert(result != NULL);
+	
+	bool neg;
+	char *lendptr;
+	int ret = str_uint(nptr, &lendptr, base, &neg, result);
+	
+	if (endptr != NULL)
+		*endptr = (char *) lendptr;
+	
+	if (ret != EOK)
+		return ret;
+	
+	/* Do not allow negative values */
+	if (neg)
+		return EINVAL;
+	
+	/* Check whether we are at the end of
+	   the string in strict mode */
+	if ((strict) && (*lendptr != 0))
+		return EINVAL;
+	
+	return EOK;
+}
+
+/** Convert string to size_t.
+ *
+ * @param nptr   Pointer to string.
+ * @param endptr If not NULL, pointer to the first invalid character
+ *               is stored here.
+ * @param base   Zero or number between 2 and 36 inclusive.
+ * @param strict Do not allow any trailing characters.
+ * @param result Result of the conversion.
+ *
+ * @return EOK if conversion was successful.
+ *
+ */
+int str_size_t(const char *nptr, char **endptr, unsigned int base,
+    bool strict, size_t *result)
+{
+	assert(result != NULL);
+	
+	bool neg;
+	char *lendptr;
+	uint64_t res;
+	int ret = str_uint(nptr, &lendptr, base, &neg, &res);
+	
+	if (endptr != NULL)
+		*endptr = (char *) lendptr;
+	
+	if (ret != EOK)
+		return ret;
+	
+	/* Do not allow negative values */
+	if (neg)
+		return EINVAL;
+	
+	/* Check whether we are at the end of
+	   the string in strict mode */
+	if ((strict) && (*lendptr != 0))
+		return EINVAL;
+	
+	/* Check for overflow */
+	size_t _res = (size_t) res;
+	if (_res != res)
+		return EOVERFLOW;
+	
+	*result = _res;
+	
+	return EOK;
 }
 
Index: uspace/lib/c/include/assert.h
===================================================================
--- uspace/lib/c/include/assert.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/assert.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -51,15 +51,19 @@
 
 #ifndef NDEBUG
-#	define assert(expr) \
-		do { \
-			if (!(expr)) { \
-				printf("Assertion failed (%s) at file '%s', " \
-				    "line %d.\n", #expr, __FILE__, __LINE__); \
-				abort(); \
-			} \
-		} while (0)
-#else
-#	define assert(expr)
-#endif
+
+#define assert(expr) \
+	do { \
+		if (!(expr)) { \
+			printf("Assertion failed (%s) at file '%s', " \
+			    "line %d.\n", #expr, __FILE__, __LINE__); \
+			abort(); \
+		} \
+	} while (0)
+
+#else /* NDEBUG */
+
+#define assert(expr)
+
+#endif /* NDEBUG */
 
 #endif
Index: uspace/lib/c/include/device/char.h
===================================================================
--- uspace/lib/c/include/device/char.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/device/char.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
- 
+
  /** @addtogroup libc
  * @{
@@ -32,5 +32,5 @@
 /** @file
  */
- 
+
 #ifndef LIBC_DEVICE_HW_RES_H_
 #define LIBC_DEVICE_HW_RES_H_
@@ -38,9 +38,9 @@
 typedef enum {
 	CHAR_READ_DEV = 0,
-	CHAR_WRITE_DEV	
+	CHAR_WRITE_DEV
 } hw_res_funcs_t;
 
-int read_dev(int dev_phone, void *buf, size_t len);
-int write_dev(int dev_phone, void *buf, size_t len);
+ssize_t read_dev(int dev_phone, void *buf, size_t len);
+ssize_t write_dev(int dev_phone, void *buf, size_t len);
 
 #endif
Index: uspace/lib/c/include/err.h
===================================================================
--- uspace/lib/c/include/err.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/err.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -38,8 +38,9 @@
 #include <stdio.h>
 
-#define errx(status, fmt, ...) { \
-	printf((fmt), ##__VA_ARGS__); \
-	_exit(status); \
-}
+#define errx(status, fmt, ...) \
+	{ \
+		printf((fmt), ##__VA_ARGS__); \
+		_exit(status); \
+	}
 
 #endif
@@ -47,3 +48,2 @@
 /** @}
  */
-
Index: uspace/lib/c/include/malloc.h
===================================================================
--- uspace/lib/c/include/malloc.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/malloc.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -41,7 +41,10 @@
 extern uintptr_t get_max_heap_addr(void);
 
-extern void *malloc(const size_t size);
-extern void *calloc(const size_t nmemb, const size_t size);
-extern void *memalign(const size_t align, const size_t size);
+extern void *malloc(const size_t size)
+    __attribute__((malloc));
+extern void *calloc(const size_t nmemb, const size_t size)
+    __attribute__((malloc));
+extern void *memalign(const size_t align, const size_t size)
+    __attribute__((malloc));
 extern void *realloc(const void *addr, const size_t size);
 extern void free(const void *addr);
Index: uspace/lib/c/include/stdint.h
===================================================================
--- uspace/lib/c/include/stdint.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/stdint.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,27 +36,27 @@
 #define LIBC_STDINT_H_
 
-#define INT8_MIN  (0x80)
-#define INT8_MAX  (0x7F)
+#define INT8_MIN  INT8_C(0x80)
+#define INT8_MAX  INT8_C(0x7F)
 
-#define UINT8_MIN  (0u)
-#define UINT8_MAX  (0xFFu)
+#define UINT8_MIN  UINT8_C(0)
+#define UINT8_MAX  UINT8_C(0xFF)
 
-#define INT16_MIN  (0x8000)
-#define INT16_MAX  (0x7FFF)
+#define INT16_MIN  INT16_C(0x8000)
+#define INT16_MAX  INT16_C(0x7FFF)
 
-#define UINT16_MIN  (0u)
-#define UINT16_MAX  (0xFFFFu)
+#define UINT16_MIN  UINT16_C(0)
+#define UINT16_MAX  UINT16_C(0xFFFF)
 
-#define INT32_MIN  (0x80000000l)
-#define INT32_MAX  (0x7FFFFFFFl)
+#define INT32_MIN  INT32_C(0x80000000)
+#define INT32_MAX  INT32_C(0x7FFFFFFF)
 
-#define UINT32_MIN  (0ul)
-#define UINT32_MAX  (0xFFFFFFFFul)
+#define UINT32_MIN  UINT32_C(0)
+#define UINT32_MAX  UINT32_C(0xFFFFFFFF)
 
-#define INT64_MIN  (0x8000000000000000ll)
-#define INT64_MAX  (0x7FFFFFFFFFFFFFFFll)
+#define INT64_MIN  INT64_C(0x8000000000000000)
+#define INT64_MAX  INT64_C(0x7FFFFFFFFFFFFFFF)
 
-#define UINT64_MIN  (0ull)
-#define UINT64_MAX  (0xFFFFFFFFFFFFFFFFull)
+#define UINT64_MIN  UINT64_C(0)
+#define UINT64_MAX  UINT64_C(0xFFFFFFFFFFFFFFFF)
 
 #include <libarch/types.h>
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/stdio.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -41,4 +41,15 @@
 #include <adt/list.h>
 
+#ifndef NVERIFY_PRINTF
+
+#define PRINTF_ATTRIBUTE(start, end) \
+	__attribute__((format(gnu_printf, start, end)))
+
+#else /* NVERIFY_PRINTF */
+
+#define PRINTF_ATTRIBUTE(start, end)
+
+#endif /* NVERIFY_PRINTF */
+
 #define EOF  (-1)
 
@@ -149,12 +160,16 @@
 
 /* Formatted string output functions */
-extern int fprintf(FILE *, const char*, ...);
+extern int fprintf(FILE *, const char*, ...)
+    PRINTF_ATTRIBUTE(2, 3);
 extern int vfprintf(FILE *, const char *, va_list);
 
-extern int printf(const char *, ...);
+extern int printf(const char *, ...)
+    PRINTF_ATTRIBUTE(1, 2);
 extern int vprintf(const char *, va_list);
 
-extern int snprintf(char *, size_t , const char *, ...);
-extern int asprintf(char **, const char *, ...);
+extern int snprintf(char *, size_t , const char *, ...)
+    PRINTF_ATTRIBUTE(3, 4);
+extern int asprintf(char **, const char *, ...)
+    PRINTF_ATTRIBUTE(2, 3);
 extern int vsnprintf(char *, size_t, const char *, va_list);
 
Index: uspace/lib/c/include/str.h
===================================================================
--- uspace/lib/c/include/str.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/str.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -86,4 +86,7 @@
 extern char *str_ndup(const char *, size_t max_size);
 
+extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
+extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
+
 extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix);
 
Index: uspace/lib/c/include/sys/typefmt.h
===================================================================
--- uspace/lib/c/include/sys/typefmt.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/sys/typefmt.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -39,5 +39,5 @@
 #include <inttypes.h>
 
-/* off64_t */
+/* off64_t, aoff64_t */
 #define PRIdOFF64 PRId64
 #define PRIuOFF64 PRIu64
@@ -45,28 +45,4 @@
 #define PRIXOFF64 PRIX64
 
-/* (s)size_t */
-#define PRIdSIZE PRIdPTR
-#define PRIuSIZE PRIuPTR
-#define PRIxSIZE PRIxPTR
-#define PRIXSIZE PRIXPTR
-
-/* sysarg_t */
-#define PRIdSYSARG PRIdPTR
-#define PRIuSYSARG PRIuPTR
-#define PRIxSYSARG PRIxPTR
-#define PRIXSYSARG PRIxPTR
-
-/* ipcarg_t */
-#define PRIdIPCARG PRIdPTR
-#define PRIuIPCARG PRIuPTR
-#define PRIxIPCARG PRIxPTR
-#define PRIXIPCARG PRIXPTR
-
-/* taskid_t */
-#define PRIdTASKID PRId64
-#define PRIuTASKID PRIu64
-#define PRIxTASKID PRIx64
-#define PRIXTASKID PRIx64
-
 #endif
 
Index: uspace/lib/c/include/sys/types.h
===================================================================
--- uspace/lib/c/include/sys/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/c/include/sys/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -46,7 +46,4 @@
 typedef uint64_t aoff64_t;
 
-/** Unicode code point */
-typedef int32_t wchar_t;
-
 typedef volatile uint8_t ioport8_t;
 typedef volatile uint16_t ioport16_t;
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/drv/generic/driver.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -48,4 +48,5 @@
 #include <ctype.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include <ipc/driver.h>
@@ -164,4 +165,6 @@
 	
 	devman_handle_t dev_handle =  IPC_GET_ARG1(*icall);
+    	devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall);
+    
 	device_t *dev = create_device();
 	dev->handle = dev_handle;
@@ -171,10 +174,12 @@
 	
 	add_to_devices_list(dev);
+	dev->parent = driver_get_device(&devices, parent_dev_handle);
+	
 	res = driver->driver_ops->add_device(dev);
 	if (0 == res) {
-		printf("%s: new device with handle = %x was added.\n",
+		printf("%s: new device with handle=%" PRIun " was added.\n",
 		    driver->name, dev_handle);
 	} else {
-		printf("%s: failed to add a new device with handle = %d.\n",
+		printf("%s: failed to add a new device with handle = %" PRIun ".\n",
 		    driver->name, dev_handle);
 		remove_from_devices_list(dev);
@@ -203,6 +208,5 @@
 			break;
 		default:
-			if (!(callid & IPC_CALLID_NOTIFICATION))
-				ipc_answer_0(callid, ENOENT);
+			ipc_answer_0(callid, ENOENT);
 		}
 	}
@@ -226,5 +230,5 @@
 	if (dev == NULL) {
 		printf("%s: driver_connection_gen error - no device with handle"
-		    " %x was found.\n", driver->name, handle);
+		    " %" PRIun " was found.\n", driver->name, handle);
 		ipc_answer_0(iid, ENOENT);
 		return;
@@ -290,5 +294,5 @@
 				printf("%s: driver_connection_gen error - ",
 				    driver->name);
-				printf("device with handle %d has no interface "
+				printf("device with handle %" PRIun " has no interface "
 				    "with id %d.\n", handle, iface_idx);
 				ipc_answer_0(callid, ENOTSUP);
Index: uspace/lib/usb/include/usb/classes/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,4 +37,5 @@
 
 #include <sys/types.h>
+#include <usb/hcdhubd.h>
 
 
@@ -148,29 +149,5 @@
 } usb_hub_descriptor_t;
 
-/**
- *	Maximum size of usb hub descriptor in bytes
- */
-extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
-
-/**
- *	hub descriptor type
- */
-extern uint8_t USB_HUB_DESCRIPTOR_TYPE;
-
-/**
- * @brief create uint8_t array with serialized descriptor
- *
- * @param descriptor
- */
-void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
-
-/**
- * @brief create deserialized desriptor structure out of serialized descriptor
- *
- * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.
- *
- * @param sdescriptor serialized descriptor
- */
-usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
+
 
 /**	@brief usb hub specific request types.
@@ -215,4 +192,33 @@
 } usb_hub_request_t;
 
+/**
+ *	Maximum size of usb hub descriptor in bytes
+ */
+extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
+
+/**
+ * @brief create uint8_t array with serialized descriptor
+ *
+ * @param descriptor
+ */
+void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
+
+/**
+ * @brief create deserialized desriptor structure out of serialized descriptor
+ *
+ * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.
+ *
+ * @param sdescriptor serialized descriptor
+ */
+usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
+
+/**
+ * @brief create hub structure instance
+ * 
+ * @param device
+ * @return
+ */
+usb_hcd_hub_info_t * usb_create_hub_info(device_t * device);
+
 
 
Index: uspace/lib/usb/src/hcdhubd.c
===================================================================
--- uspace/lib/usb/src/hcdhubd.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/usb/src/hcdhubd.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,4 +36,5 @@
 #include <usb/devreq.h>
 #include <usbhc_iface.h>
+#include <usb/descriptor.h>
 #include <driver.h>
 #include <bool.h>
@@ -42,4 +43,9 @@
 
 #define USB_HUB_DEVICE_NAME "usbhub"
+
+#define USB_KBD_DEVICE_NAME "hid"
+
+
+
 
 /** List of handled host controllers. */
@@ -68,49 +74,48 @@
 //*********************************************
 
-
-void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor){
+void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor) {
 	//base size
 	size_t size = 7;
 	//variable size according to port count
-	size_t var_size = descriptor->ports_count / 8 + ((descriptor->ports_count % 8>0)?1:0);
+	size_t var_size = descriptor->ports_count / 8 + ((descriptor->ports_count % 8 > 0) ? 1 : 0);
 	size += 2 * var_size;
 	uint8_t * result = (uint8_t*) malloc(size);
 	//size
-	result[0]=size;
+	result[0] = size;
 	//descriptor type
-	result[1]=USB_HUB_DESCRIPTOR_TYPE;
-	result[2]=descriptor->ports_count;
+	result[1] = USB_DESCTYPE_HUB;
+	result[2] = descriptor->ports_count;
 	/// @fixme handling of endianness??
-	result[3]=descriptor->hub_characteristics / 256;
-	result[4]=descriptor->hub_characteristics % 256;
-	result[5]=descriptor->pwr_on_2_good_time;
-	result[6]=descriptor->current_requirement;
-
-        size_t i;
-	for(i=0;i<var_size;++i){
-		result[7+i]=descriptor->devices_removable[i];
-	}
-	for(i=0;i<var_size;++i){
-		result[7+var_size+i]=255;
+	result[3] = descriptor->hub_characteristics / 256;
+	result[4] = descriptor->hub_characteristics % 256;
+	result[5] = descriptor->pwr_on_2_good_time;
+	result[6] = descriptor->current_requirement;
+
+	size_t i;
+	for (i = 0; i < var_size; ++i) {
+		result[7 + i] = descriptor->devices_removable[i];
+	}
+	for (i = 0; i < var_size; ++i) {
+		result[7 + var_size + i] = 255;
 	}
 	return result;
 }
 
-usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor){
-        uint8_t * sdescriptor = (uint8_t*)serialized_descriptor;
-	if(sdescriptor[1]!=USB_HUB_DESCRIPTOR_TYPE) return NULL;
-	usb_hub_descriptor_t * result = (usb_hub_descriptor_t*) malloc(sizeof(usb_hub_descriptor_t));
+usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor) {
+	uint8_t * sdescriptor = (uint8_t*) serialized_descriptor;
+	if (sdescriptor[1] != USB_DESCTYPE_HUB) return NULL;
+	usb_hub_descriptor_t * result = (usb_hub_descriptor_t*) malloc(sizeof (usb_hub_descriptor_t));
 	//uint8_t size = sdescriptor[0];
 	result->ports_count = sdescriptor[2];
 	/// @fixme handling of endianness??
 	result->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
-	result->pwr_on_2_good_time=sdescriptor[5];
-	result->current_requirement=sdescriptor[6];
-	size_t var_size = result->ports_count / 8 + ((result->ports_count % 8>0)?1:0);
-	result->devices_removable = (uint8_t*)malloc(var_size);
-
-        size_t i;
-	for(i=0;i<var_size;++i){
-		result->devices_removable[i] = sdescriptor[7+i];
+	result->pwr_on_2_good_time = sdescriptor[5];
+	result->current_requirement = sdescriptor[6];
+	size_t var_size = result->ports_count / 8 + ((result->ports_count % 8 > 0) ? 1 : 0);
+	result->devices_removable = (uint8_t*) malloc(var_size);
+
+	size_t i;
+	for (i = 0; i < var_size; ++i) {
+		result->devices_removable[i] = sdescriptor[7 + i];
 	}
 	return result;
@@ -124,7 +129,24 @@
 //*********************************************
 
-
-
 static void set_hub_address(usb_hc_device_t *hc, usb_address_t address);
+
+usb_hcd_hub_info_t * usb_create_hub_info(device_t * device) {
+	usb_hcd_hub_info_t* result = (usb_hcd_hub_info_t*) malloc(sizeof (usb_hcd_hub_info_t));
+	//get parent device
+	/// @TODO this code is not correct
+	device_t * my_hcd = device;
+	while (my_hcd->parent)
+		my_hcd = my_hcd->parent;
+	//dev->
+	printf("%s: owner hcd found: %s\n", hc_driver->name, my_hcd->name);
+	//we add the hub into the first hc
+	//link_t *link_hc = hc_list.next;
+	//usb_hc_device_t *hc = list_get_instance(link_hc,
+	//		usb_hc_device_t, link);
+	//must get generic device info
+
+
+	return result;
+}
 
 /** Callback when new device is detected and must be handled by this driver.
@@ -133,6 +155,5 @@
  * @return Error code.hub added, hurrah!\n"
  */
-static int add_device(device_t *dev)
-{
+static int add_device(device_t *dev) {
 	/*
 	 * FIXME: use some magic to determine whether hub or another HC
@@ -146,5 +167,5 @@
 		 * We are the HC itself.
 		 */
-		usb_hc_device_t *hc_dev = malloc(sizeof(usb_hc_device_t));
+		usb_hc_device_t *hc_dev = malloc(sizeof (usb_hc_device_t));
 		list_initialize(&hc_dev->link);
 		hc_dev->transfer_ops = NULL;
@@ -168,5 +189,47 @@
 		list_append(&hc_dev->link, &hc_list);
 
+		//add keyboard
+		/// @TODO this is not correct code
+		
+		/*
+		 * Announce presence of child device.
+		 */
+		device_t *kbd = NULL;
+		match_id_t *match_id = NULL;
+
+		kbd = create_device();
+		if (kbd == NULL) {
+			printf("ERROR: enomem\n");
+		}
+		kbd->name = USB_KBD_DEVICE_NAME;
+
+		match_id = create_match_id();
+		if (match_id == NULL) {
+			printf("ERROR: enomem\n");
+		}
+
+		char *id;
+		rc = asprintf(&id, USB_KBD_DEVICE_NAME);
+		if (rc <= 0) {
+			printf("ERROR: enomem\n");
+			return rc;
+		}
+
+		match_id->id = id;
+		match_id->score = 30;
+
+		add_match_id(&kbd->match_ids, match_id);
+
+		rc = child_device_register(kbd, dev);
+		if (rc != EOK) {
+			printf("ERROR: cannot register kbd\n");
+			return rc;
+		}
+
+		printf("%s: registered root hub\n", dev->name);
 		return EOK;
+
+
+
 	} else {
 		usb_hc_device_t *hc = list_get_instance(hc_list.next, usb_hc_device_t, link);
@@ -178,14 +241,30 @@
 		 * connected devices.
 		 */
-                //insert hub into list
-                //find owner hcd
-                device_t * my_hcd = dev;
-                while(my_hcd->parent)
-                    my_hcd = my_hcd->parent;
-                //dev->
-                printf("%s: owner hcd found: %s\n",hc_driver->name, my_hcd->name);
-
-
-		return ENOTSUP;
+		//insert hub into list
+		//find owner hcd
+		device_t * my_hcd = dev;
+		while (my_hcd->parent)
+			my_hcd = my_hcd->parent;
+		//dev->
+		printf("%s: owner hcd found: %s\n", hc_driver->name, my_hcd->name);
+		my_hcd = dev;
+		while (my_hcd->parent)
+			my_hcd = my_hcd->parent;
+		//dev->
+
+		printf("%s: owner hcd found: %s\n", hc_driver->name, my_hcd->name);
+		
+		//create the hub structure
+		usb_hcd_hub_info_t * hub_info = usb_create_hub_info(dev);
+
+
+		//append into the list
+		//we add the hub into the first hc
+		list_append(&hub_info->link, &hc->hubs);
+
+
+
+		return EOK;
+		//return ENOTSUP;
 	}
 }
@@ -200,6 +279,5 @@
  * @param address New hub address.
  */
-static void set_hub_address(usb_hc_device_t *hc, usb_address_t address)
-{
+static void set_hub_address(usb_hc_device_t *hc, usb_address_t address) {
 	printf("%s: setting hub address to %d\n", hc->generic->name, address);
 	usb_target_t target = {0, 0};
@@ -216,5 +294,5 @@
 
 	rc = usb_hc_async_control_write_setup(hc, target,
-	    &setup_packet, sizeof(setup_packet), &handle);
+			&setup_packet, sizeof (setup_packet), &handle);
 	if (rc != EOK) {
 		return;
@@ -241,6 +319,5 @@
 /** Check changes on all known hubs.
  */
-static void check_hub_changes(void)
-{
+static void check_hub_changes(void) {
 	/*
 	 * Iterate through all HCs.
@@ -248,8 +325,8 @@
 	link_t *link_hc;
 	for (link_hc = hc_list.next;
-	    link_hc != &hc_list;
-	    link_hc = link_hc->next) {
+			link_hc != &hc_list;
+			link_hc = link_hc->next) {
 		usb_hc_device_t *hc = list_get_instance(link_hc,
-		    usb_hc_device_t, link);
+				usb_hc_device_t, link);
 		/*
 		 * Iterate through all their hubs.
@@ -257,8 +334,8 @@
 		link_t *link_hub;
 		for (link_hub = hc->hubs.next;
-		    link_hub != &hc->hubs;
-		    link_hub = link_hub->next) {
+				link_hub != &hc->hubs;
+				link_hub = link_hub->next) {
 			usb_hcd_hub_info_t *hub = list_get_instance(link_hub,
-			    usb_hcd_hub_info_t, link);
+					usb_hcd_hub_info_t, link);
 
 			/*
@@ -282,6 +359,6 @@
 			 */
 			usb_hc_async_interrupt_in(hc, target,
-			    change_bitmap, byte_length, &actual_size,
-			    &handle);
+					change_bitmap, byte_length, &actual_size,
+					&handle);
 
 			usb_hc_async_wait_for(handle);
@@ -311,6 +388,5 @@
  * @return Error code.
  */
-int usb_hcd_main(usb_hc_driver_t *hc)
-{
+int usb_hcd_main(usb_hc_driver_t *hc) {
 	hc_driver = hc;
 	hc_driver_generic.name = hc->name;
@@ -338,6 +414,5 @@
  * @return Error code.
  */
-int usb_hcd_add_root_hub(usb_hc_device_t *dev)
-{
+int usb_hcd_add_root_hub(usb_hc_device_t *dev) {
 	int rc;
 
Index: uspace/lib/usbvirt/debug.c
===================================================================
--- uspace/lib/usbvirt/debug.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/lib/usbvirt/debug.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -60,5 +60,5 @@
 	
 	if (print_prefix) {
-		printf("[vusb]: ", level);
+		printf("[vusb]: ");
 		while (--level > 0) {
 			printf(" ");
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -113,5 +113,6 @@
 	printf(NAME ": ATA disk driver\n");
 
-	printf("I/O address %p/%p\n", ctl_physical, cmd_physical);
+	printf("I/O address %p/%p\n", (void *) ctl_physical,
+	    (void *) cmd_physical);
 
 	if (ata_bd_init() != EOK)
@@ -181,5 +182,5 @@
 	}
 
-	printf(" %" PRIu64 " blocks", d->blocks, d->blocks / (2 * 1024));
+	printf(" %" PRIu64 " blocks", d->blocks);
 
 	mbytes = d->blocks / (2 * 1024);
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -155,5 +155,5 @@
 
 	if (block_size < 512 || (block_size % 512) != 0) {
-		printf(NAME ": invalid block size %d.\n");
+		printf(NAME ": invalid block size %zu.\n", block_size);
 		return ENOTSUP;
 	}
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -206,5 +206,5 @@
 
 	if (block_size < 512 || (block_size % 512) != 0) {
-		printf(NAME ": invalid block size %d.\n");
+		printf(NAME ": invalid block size %zu.\n", block_size);
 		return ENOTSUP;
 	}
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/bd/rd/rd.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -230,5 +230,6 @@
 	}
 	
-	printf("%s: Found RAM disk at %p, %d bytes\n", NAME, rd_ph_addr, rd_size);
+	printf("%s: Found RAM disk at %p, %zu bytes\n", NAME,
+	    (void *) rd_ph_addr, rd_size);
 	
 	int rc = devmap_driver_register(NAME, rd_connection);
Index: uspace/srv/clip/clip.c
===================================================================
--- uspace/srv/clip/clip.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/clip/clip.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -172,6 +172,5 @@
 			break;
 		default:
-			if (!(callid & IPC_CALLID_NOTIFICATION))
-				ipc_answer_0(callid, ENOENT);
+			ipc_answer_0(callid, ENOENT);
 		}
 	}
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/devman/devman.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -651,6 +651,12 @@
 	
 	/* Send the device to the driver. */
-	aid_t req = async_send_1(phone, DRIVER_ADD_DEVICE, node->handle,
-	    &answer);
+	devman_handle_t parent_handle;
+	if (node->parent) {
+		parent_handle = node->parent->handle;
+	} else {
+		parent_handle = 0;
+	}
+	aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, node->handle,
+	    parent_handle, &answer);
 	
 	/* Send the device's name to the driver. */
@@ -1022,5 +1028,5 @@
 	
 	size_t idx = get_new_class_dev_idx(cl);
-	asprintf(&dev_name, "%s%d", base_name, idx);
+	asprintf(&dev_name, "%s%zu", base_name, idx);
 	
 	return dev_name;
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/devman/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,4 +36,5 @@
  */
 
+#include <inttypes.h>
 #include <assert.h>
 #include <ipc/services.h>
@@ -405,6 +406,5 @@
 			break;
 		default:
-			if (!(callid & IPC_CALLID_NOTIFICATION))
-				ipc_answer_0(callid, ENOENT);
+			ipc_answer_0(callid, ENOENT);
 		}
 	}
@@ -418,6 +418,6 @@
 	node_t *dev = find_dev_node(&device_tree, handle);
 	if (dev == NULL) {
-		printf(NAME ": devman_forward error - no device with handle %x "
-		    "was found.\n", handle);
+		printf(NAME ": devman_forward error - no device with handle %" PRIun
+		    " was found.\n", handle);
 		ipc_answer_0(iid, ENOENT);
 		return;
@@ -435,6 +435,6 @@
 	
 	if (driver == NULL) {
-		printf(NAME ": devman_forward error - the device is not in "
-		    "usable state.\n", handle);
+		printf(NAME ": devman_forward error - the device is not in %" PRIun
+		    " usable state.\n", handle);
 		ipc_answer_0(iid, ENOENT);
 		return;
@@ -450,5 +450,5 @@
 		printf(NAME ": devman_forward: cound not forward to driver %s ",
 		    driver->name);
-		printf("the driver's phone is %x).\n", driver->phone);
+		printf("the driver's phone is %" PRIun ").\n", driver->phone);
 		ipc_answer_0(iid, EINVAL);
 		return;
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/devman/match.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -35,4 +35,26 @@
 #include "devman.h"
 
+/** Compute compound score of driver and device.
+ *
+ * @param driver Match id of the driver.
+ * @param device Match id of the device.
+ * @return Compound score.
+ * @retval 0 No match at all.
+ */
+static int compute_match_score(match_id_t *driver, match_id_t *device)
+{
+	if (str_cmp(driver->id, device->id) == 0) {
+		/*
+		 * The strings matches, return their score multiplied.
+		 */
+		return driver->score * device->score;
+	} else {
+		/*
+		 * Different strings, return zero.
+		 */
+		return 0;
+	}
+}
+
 int get_match_score(driver_t *drv, node_t *dev)
 {
@@ -44,27 +66,27 @@
 	
 	/*
-	 * Find first matching pair.
+	 * Go through all pairs, return the highest score obtainetd.
 	 */
+	int highest_score = 0;
+	
 	link_t *drv_link = drv->match_ids.ids.next;
 	while (drv_link != drv_head) {
-		link_t *dev_link = dev->match_ids.ids.next;
+		link_t *dev_link = dev_head->next;
 		while (dev_link != dev_head) {
 			match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link);
 			match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link);
-
-			if (str_cmp(drv_id->id, dev_id->id) == 0) {
-				/*
-				 * We found a match.
-				 * Return the score of the match.
-				 */
-				return drv_id->score * dev_id->score;
+			
+			int score = compute_match_score(drv_id, dev_id);
+			if (score > highest_score) {
+				highest_score = score;
 			}
 
 			dev_link = dev_link->next;
 		}
+		
 		drv_link = drv_link->next;
 	}
 	
-	return 0;
+	return highest_score;
 }
 
Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/devmap/devmap.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -555,5 +555,5 @@
 	if (devmap_device_find_name(namespace->name, device->name) != NULL) {
 		printf("%s: Device '%s/%s' already registered\n", NAME,
-		    device->namespace, device->name);
+		    device->namespace->name, device->name);
 		devmap_namespace_destroy(namespace);
 		fibril_mutex_unlock(&devices_list_mutex);
@@ -1052,6 +1052,5 @@
 			break;
 		default:
-			if (!(callid & IPC_CALLID_NOTIFICATION))
-				ipc_answer_0(callid, ENOENT);
+			ipc_answer_0(callid, ENOENT);
 		}
 	}
@@ -1111,6 +1110,5 @@
 			break;
 		default:
-			if (!(callid & IPC_CALLID_NOTIFICATION))
-				ipc_answer_0(callid, ENOENT);
+			ipc_answer_0(callid, ENOENT);
 		}
 	}
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hid/console/console.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -804,5 +804,5 @@
 			if (screenbuffer_init(&consoles[i].scr,
 			    fb_info.cols, fb_info.rows) == NULL) {
-				printf(NAME ": Unable to allocate screen buffer %u\n", i);
+				printf(NAME ": Unable to allocate screen buffer %zu\n", i);
 				return false;
 			}
@@ -813,5 +813,5 @@
 			
 			char vc[DEVMAP_NAME_MAXLEN + 1];
-			snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%u", NAMESPACE, i);
+			snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
 			
 			if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
Index: uspace/srv/hid/console/gcons.c
===================================================================
--- uspace/srv/hid/console/gcons.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hid/console/gcons.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -157,5 +157,5 @@
 		
 		char data[5];
-		snprintf(data, 5, "%u", index + 1);
+		snprintf(data, 5, "%zu", index + 1);
 		
 		size_t i;
Index: uspace/srv/hid/fb/serial_console.c
===================================================================
--- uspace/srv/hid/fb/serial_console.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hid/fb/serial_console.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -47,4 +47,5 @@
 #include <io/style.h>
 #include <str.h>
+#include <inttypes.h>
 #include <io/screenbuffer.h>
 
@@ -135,5 +136,6 @@
 	
 	char control[MAX_CONTROL];
-	snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
+	snprintf(control, MAX_CONTROL, "\033[%" PRIun ";%" PRIun "f",
+	    row + 1, col + 1);
 	serial_puts(control);
 }
@@ -253,5 +255,5 @@
 {
 	char control[MAX_CONTROL];
-	snprintf(control, MAX_CONTROL, "\033[0;%ur", last_row);
+	snprintf(control, MAX_CONTROL, "\033[0;%" PRIun "r", last_row);
 	serial_puts(control);
 }
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -50,4 +50,5 @@
 #include <sysinfo.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include "s3c24xx_ts.h"
@@ -136,6 +137,6 @@
 	ts->last_y = 0;
 
-	printf(NAME ": device at physical address 0x%x, inr %d.\n",
-	    ts->paddr, inr);
+	printf(NAME ": device at physical address %p, inr %" PRIun ".\n",
+	    (void *) ts->paddr, inr);
 
 	async_set_interrupt_received(s3c24xx_ts_irq_handler);
Index: uspace/srv/hw/char/i8042/i8042.c
===================================================================
--- uspace/srv/hw/char/i8042/i8042.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hw/char/i8042/i8042.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -46,4 +46,5 @@
 #include <stdio.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include "i8042.h"
@@ -201,5 +202,6 @@
 	ipc_register_irq(inr_a, device_assign_devno(), 0, &i8042_kbd);
 	ipc_register_irq(inr_b, device_assign_devno(), 0, &i8042_kbd);
-	printf("%s: registered for interrupts %d and %d\n", NAME, inr_a, inr_b);
+	printf("%s: registered for interrupts %" PRIun " and %" PRIun "\n",
+	    NAME, inr_a, inr_b);
 
 	wait_ready();
@@ -262,5 +264,5 @@
 			break;
 		case IPC_FIRST_USER_METHOD:
-			printf(NAME ": write %d to devid %d\n",
+			printf(NAME ": write %" PRIun " to devid %d\n",
 			    IPC_GET_ARG1(call), dev_id);
 			i8042_port_write(dev_id, IPC_GET_ARG1(call));
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -48,4 +48,5 @@
 #include <sysinfo.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include "s3c24xx_uart.h"
@@ -95,5 +96,6 @@
 	if (rc != EOK) {
 		devmap_hangup_phone(DEVMAP_DRIVER);
-		printf(NAME ": Unable to register device %s.\n");
+		printf(NAME ": Unable to register device %s.\n",
+		    NAMESPACE "/" NAME);
 		return -1;
 	}
@@ -134,5 +136,5 @@
 			break;
 		case CHAR_WRITE_BYTE:
-			printf(NAME ": write %d to device\n",
+			printf(NAME ": write %" PRIun " to device\n",
 			    IPC_GET_ARG1(call));
 			s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call));
@@ -185,6 +187,6 @@
 	uart->client_phone = -1;
 
-	printf(NAME ": device at physical address 0x%x, inr %d.\n",
-	    uart->paddr, inr);
+	printf(NAME ": device at physical address %p, inr %" PRIun ".\n",
+	    (void *) uart->paddr, inr);
 
 	async_set_interrupt_received(s3c24xx_uart_irq_handler);
Index: uspace/srv/hw/cir/fhc/fhc.c
===================================================================
--- uspace/srv/hw/cir/fhc/fhc.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hw/cir/fhc/fhc.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -129,5 +129,5 @@
 	}
 	
-	printf(NAME ": FHC UART registers at %p, %d bytes\n", fhc_uart_phys,
+	printf(NAME ": FHC UART registers at %p, %zu bytes\n", fhc_uart_phys,
 	    fhc_uart_size);
 	
Index: uspace/srv/hw/netif/dp8390/dp8390.c
===================================================================
--- uspace/srv/hw/netif/dp8390/dp8390.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hw/netif/dp8390/dp8390.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -1516,6 +1516,6 @@
 	if (!wdeth_probe(dep) && !ne_probe(dep) && !el2_probe(dep))
 	{
-		printf("%s: No ethernet card found at 0x%x\n", 
-			dep->de_name, dep->de_base_port);
+		printf("%s: No ethernet card found at %#lx\n",
+		    dep->de_name, dep->de_base_port);
 		dep->de_mode= DEM_DISABLED;
 		return;
Index: uspace/srv/hw/netif/dp8390/ne2000.c
===================================================================
--- uspace/srv/hw/netif/dp8390/ne2000.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/hw/netif/dp8390/ne2000.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -267,14 +267,14 @@
 	if (!debug)
 	{
-		printf("%s: NE%d000 at %X:%d\n",
-			dep->de_name, dep->de_16bit ? 2 : 1,
-			dep->de_base_port, dep->de_irq);
+		printf("%s: NE%d000 at %#lx:%d\n",
+		    dep->de_name, dep->de_16bit ? 2 : 1,
+		    dep->de_base_port, dep->de_irq);
 	}
 	else
 	{
 		printf("%s: Novell NE%d000 ethernet card at I/O address "
-			"0x%X, memory size 0x%X, irq %d\n",
-			dep->de_name, dep->de_16bit ? 2 : 1,
-			dep->de_base_port, dep->de_ramsize, dep->de_irq);
+		    "%#lx, memory size %#lx, irq %d\n",
+		    dep->de_name, dep->de_16bit ? 2 : 1,
+		    dep->de_base_port, dep->de_ramsize, dep->de_irq);
 	}
 }
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/loader/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -411,6 +411,5 @@
 			break;
 		}
-		if ((callid & IPC_CALLID_NOTIFICATION) == 0 &&
-		    IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) {
+		if (IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) {
 			DPRINTF("Responding EINVAL to method %d.\n",
 			    IPC_GET_METHOD(call));
Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/net/il/arp/arp.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -391,5 +391,5 @@
 	device->packet_dimension.content = mtu;
 	fibril_rwlock_write_unlock(&arp_globals.lock);
-	printf("arp - device %d changed mtu to %d\n\n", device_id, mtu);
+	printf("arp - device %d changed mtu to %zu\n\n", device_id, mtu);
 	return EOK;
 }
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/net/il/ip/ip.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -461,5 +461,5 @@
 	
 	if (ip_netif->packet_dimension.content < IP_MIN_CONTENT) {
-		printf("Maximum transmission unit %d bytes is too small, at "
+		printf("Maximum transmission unit %zu bytes is too small, at "
 		    "least %d bytes are needed\n",
 		    ip_netif->packet_dimension.content, IP_MIN_CONTENT);
@@ -502,5 +502,5 @@
 	fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
 
-	printf("%s: Device %d changed MTU to %d\n", NAME, device_id, mtu);
+	printf("%s: Device %d changed MTU to %zu\n", NAME, device_id, mtu);
 
 	return EOK;
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/net/nil/eth/eth.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -315,5 +315,5 @@
 			device->mtu = ETH_MAX_TAGGED_CONTENT(device->flags);
 		
-		printf("Device %d already exists:\tMTU\t= %d\n",
+		printf("Device %d already exists:\tMTU\t= %zu\n",
 		    device->device_id, device->mtu);
 		fibril_rwlock_write_unlock(&eth_globals.devices_lock);
@@ -407,5 +407,5 @@
 	}
 	
-	printf("%s: Device registered (id: %d, service: %d: mtu: %d, "
+	printf("%s: Device registered (id: %d, service: %d: mtu: %zu, "
 	    "mac: %x:%x:%x:%x:%x:%x, flags: 0x%x)\n",
 	    NAME, device->device_id, device->service, device->mtu,
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -175,5 +175,5 @@
 			device->mtu = NET_DEFAULT_MTU;
 		
-		printf("Device %d already exists:\tMTU\t= %d\n",
+		printf("Device %d already exists:\tMTU\t= %zu\n",
 		    device->device_id, device->mtu);
 		fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
@@ -232,5 +232,5 @@
 	}
 	
-	printf("%s: Device registered (id: %d, service: %d, mtu: %d)\n",
+	printf("%s: Device registered (id: %d, service: %d, mtu: %zu)\n",
 	    NAME, device->device_id, device->service, device->mtu);
 	fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/ns/task.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -262,6 +262,6 @@
 	if (ht == NULL) {
 		/* No such task exists. */
-		retval = ENOENT;
-		goto out;
+		ipc_answer_0(callid, ENOENT);
+		return;
 	}
 
Index: uspace/srv/taskmon/taskmon.c
===================================================================
--- uspace/srv/taskmon/taskmon.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/taskmon/taskmon.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -60,10 +60,11 @@
 	thread = IPC_GET_ARG3(*call);
 
-	if (asprintf(&s_taskid, "%" PRIuTASKID, taskid) < 0) {
+	if (asprintf(&s_taskid, "%" PRIu64, taskid) < 0) {
 		printf("Memory allocation failed.\n");
 		return;
 	}
 
-	printf(NAME ": Task %" PRIuTASKID " fault in thread %p.\n", taskid, thread);
+	printf(NAME ": Task %" PRIu64 " fault in thread %p.\n", taskid,
+	    (void *) thread);
 
 	fname = "/app/taskdump";
@@ -72,14 +73,14 @@
 	char *dump_fname;
 
-	if (asprintf(&dump_fname, "/data/core%" PRIuTASKID, taskid) < 0) {
+	if (asprintf(&dump_fname, "/data/core%" PRIu64, taskid) < 0) {
 		printf("Memory allocation failed.\n");
 		return;
 	}
 
-	printf(NAME ": Executing %s -c %s -t %s\n", dump_fname, s_taskid);
+	printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid);
 	rc = task_spawnl(NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
 	    NULL);
 #else
-	printf(NAME ": Executing %s -t %s\n", s_taskid);
+	printf(NAME ": Executing %s -t %s\n", fname, s_taskid);
 	rc = task_spawnl(NULL, fname, fname, "-t", s_taskid, NULL);
 #endif
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ uspace/srv/vfs/vfs_ops.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -55,5 +55,6 @@
 
 /* Forward declarations of static functions. */
-static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t, aoff64_t);
+static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t,
+    aoff64_t);
 
 /**
@@ -250,4 +251,6 @@
 void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
 {
+	devmap_handle_t devmap_handle;
+
 	/*
 	 * We expect the library to do the device-name to device-handle
@@ -255,5 +258,5 @@
 	 * in the request.
 	 */
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
 	
 	/*
@@ -291,6 +294,6 @@
 	 */
 	char *fs_name;
-	rc = async_data_write_accept((void **) &fs_name, true, 0, FS_NAME_MAXLEN,
-	    0, NULL);
+	rc = async_data_write_accept((void **) &fs_name, true, 0,
+	    FS_NAME_MAXLEN, 0, NULL);
 	if (rc != EOK) {
 		free(mp);
@@ -458,6 +461,6 @@
 
 		phone = vfs_grab_phone(mp_node->fs_handle);
-		rc = async_req_2_0(phone, VFS_OUT_UNMOUNT, mp_node->devmap_handle,
-		    mp_node->index);
+		rc = async_req_2_0(phone, VFS_OUT_UNMOUNT,
+		    mp_node->devmap_handle, mp_node->index);
 		vfs_release_phone(mp_node->fs_handle, phone);
 		if (rc != EOK) {
@@ -740,6 +743,6 @@
 		aid_t msg;
 		ipc_call_t answer;
-		msg = async_send_2(fs_phone, VFS_OUT_CLOSE, file->node->devmap_handle,
-		    file->node->index, &answer);
+		msg = async_send_2(fs_phone, VFS_OUT_CLOSE,
+		    file->node->devmap_handle, file->node->index, &answer);
 		
 		/* Wait for reply from the FS server. */
@@ -834,11 +837,11 @@
 	ipc_call_t answer;
 	if (read) {
-		if (file->append)
-			file->pos = file->node->size;
-		
 		rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ,
 		    file->node->devmap_handle, file->node->index, file->pos,
 		    &answer);
 	} else {
+		if (file->append)
+			file->pos = file->node->size;
+		
 		rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE,
 		    file->node->devmap_handle, file->node->index, file->pos,
@@ -888,6 +891,6 @@
 {
 	int fd = (int) IPC_GET_ARG1(*request);
-	off64_t off =
-	    (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
+	off64_t off = (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
+	    IPC_GET_ARG3(*request));
 	int whence = (int) IPC_GET_ARG4(*request);
 	
@@ -903,56 +906,57 @@
 	off64_t newoff;
 	switch (whence) {
-		case SEEK_SET:
-			if (off >= 0) {
-				file->pos = (aoff64_t) off;
-				fibril_mutex_unlock(&file->lock);
-				ipc_answer_1(rid, EOK, off);
-				return;
-			}
-			break;
-		case SEEK_CUR:
-			if ((off >= 0) && (file->pos + off < file->pos)) {
-				fibril_mutex_unlock(&file->lock);
-				ipc_answer_0(rid, EOVERFLOW);
-				return;
-			}
-			
-			if ((off < 0) && (file->pos < (aoff64_t) -off)) {
-				fibril_mutex_unlock(&file->lock);
-				ipc_answer_0(rid, EOVERFLOW);
-				return;
-			}
-			
-			file->pos += off;
-			newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
-			
+	case SEEK_SET:
+		if (off >= 0) {
+			file->pos = (aoff64_t) off;
 			fibril_mutex_unlock(&file->lock);
-			ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
-			return;
-		case SEEK_END:
-			fibril_rwlock_read_lock(&file->node->contents_rwlock);
-			aoff64_t size = file->node->size;
-			
-			if ((off >= 0) && (size + off < size)) {
-				fibril_rwlock_read_unlock(&file->node->contents_rwlock);
-				fibril_mutex_unlock(&file->lock);
-				ipc_answer_0(rid, EOVERFLOW);
-				return;
-			}
-			
-			if ((off < 0) && (size < (aoff64_t) -off)) {
-				fibril_rwlock_read_unlock(&file->node->contents_rwlock);
-				fibril_mutex_unlock(&file->lock);
-				ipc_answer_0(rid, EOVERFLOW);
-				return;
-			}
-			
-			file->pos = size + off;
-			newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
-			
+			ipc_answer_1(rid, EOK, off);
+			return;
+		}
+		break;
+	case SEEK_CUR:
+		if ((off >= 0) && (file->pos + off < file->pos)) {
+			fibril_mutex_unlock(&file->lock);
+			ipc_answer_0(rid, EOVERFLOW);
+			return;
+		}
+		
+		if ((off < 0) && (file->pos < (aoff64_t) -off)) {
+			fibril_mutex_unlock(&file->lock);
+			ipc_answer_0(rid, EOVERFLOW);
+			return;
+		}
+		
+		file->pos += off;
+		newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
+		
+		fibril_mutex_unlock(&file->lock);
+		ipc_answer_2(rid, EOK, LOWER32(newoff),
+		    UPPER32(newoff));
+		return;
+	case SEEK_END:
+		fibril_rwlock_read_lock(&file->node->contents_rwlock);
+		aoff64_t size = file->node->size;
+		
+		if ((off >= 0) && (size + off < size)) {
 			fibril_rwlock_read_unlock(&file->node->contents_rwlock);
 			fibril_mutex_unlock(&file->lock);
-			ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
-			return;
+			ipc_answer_0(rid, EOVERFLOW);
+			return;
+		}
+		
+		if ((off < 0) && (size < (aoff64_t) -off)) {
+			fibril_rwlock_read_unlock(&file->node->contents_rwlock);
+			fibril_mutex_unlock(&file->lock);
+			ipc_answer_0(rid, EOVERFLOW);
+			return;
+		}
+		
+		file->pos = size + off;
+		newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
+		
+		fibril_rwlock_read_unlock(&file->node->contents_rwlock);
+		fibril_mutex_unlock(&file->lock);
+		ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
+		return;
 	}
 	
@@ -977,6 +981,6 @@
 {
 	int fd = IPC_GET_ARG1(*request);
-	aoff64_t size =
-	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
+	aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
+	    IPC_GET_ARG3(*request));
 	int rc;
 
