Index: boot/arch/arm32/src/main.c
===================================================================
--- boot/arch/arm32/src/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/arch/arm32/src/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -61,5 +61,6 @@
 	printf(" %p|%p: bootstrap page table\n", &boot_pt, &boot_pt);
 	printf(" %p|%p: boot info structure\n", &bootinfo, &bootinfo);
-	printf(" %p|%p: kernel entry point\n", PA2KA(BOOT_OFFSET), BOOT_OFFSET);
+	printf(" %p|%p: kernel entry point\n",
+	    (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET);
 	
 	size_t i;
Index: boot/arch/ia64/src/main.c
===================================================================
--- boot/arch/ia64/src/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/arch/ia64/src/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -62,10 +62,12 @@
 	
 	printf(" %p|%p: boot info structure\n", &bootinfo, &bootinfo);
-	printf(" %p|%p: kernel entry point\n", KERNEL_ADDRESS, KERNEL_ADDRESS);
-	printf(" %p|%p: loader entry point\n", LOADER_ADDRESS, LOADER_ADDRESS);
+	printf(" %p|%p: kernel entry point\n",
+	    (void *) KERNEL_ADDRESS, (void *) KERNEL_ADDRESS);
+	printf(" %p|%p: loader entry point\n",
+	    (void *) LOADER_ADDRESS, (void *) LOADER_ADDRESS);
 	
 	size_t i;
 	for (i = 0; i < COMPONENTS; i++)
-		printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
+		printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].start,
 		    components[i].start, components[i].name,
 		    components[i].inflated, components[i].size);
Index: boot/arch/mips32/src/main.c
===================================================================
--- boot/arch/mips32/src/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/arch/mips32/src/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -51,14 +51,19 @@
 	
 	printf("\nMemory statistics\n");
-	printf(" %p|%p: CPU map\n", PA2KA(CPUMAP_OFFSET), CPUMAP_OFFSET);
-	printf(" %p|%p: bootstrap stack\n", PA2KA(STACK_OFFSET), STACK_OFFSET);
-	printf(" %p|%p: boot info structure\n", PA2KA(BOOTINFO_OFFSET), BOOTINFO_OFFSET);
-	printf(" %p|%p: kernel entry point\n", PA2KA(BOOT_OFFSET), BOOT_OFFSET);
-	printf(" %p|%p: bootloader entry point\n", PA2KA(LOADER_OFFSET), LOADER_OFFSET);
+	printf(" %p|%p: CPU map\n", (void *) PA2KA(CPUMAP_OFFSET),
+	    (void *) CPUMAP_OFFSET);
+	printf(" %p|%p: bootstrap stack\n", (void *) PA2KA(STACK_OFFSET),
+	    (void *) STACK_OFFSET);
+	printf(" %p|%p: boot info structure\n",
+	    (void *) PA2KA(BOOTINFO_OFFSET), (void *) BOOTINFO_OFFSET);
+	printf(" %p|%p: kernel entry point\n", (void *) PA2KA(BOOT_OFFSET),
+	    (void *) BOOT_OFFSET);
+	printf(" %p|%p: bootloader entry point\n",
+	    (void *) PA2KA(LOADER_OFFSET), (void *) LOADER_OFFSET);
 	
 	size_t i;
 	for (i = 0; i < COMPONENTS; i++)
-		printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
-		    KSEG2PA(components[i].start), components[i].name,
+		printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].start,
+		    (void *) KSEG2PA(components[i].start), components[i].name,
 		    components[i].inflated, components[i].size);
 	
@@ -91,5 +96,5 @@
 		if (tail >= ((void *) PA2KA(LOADER_OFFSET))) {
 			printf("\n%s: Image too large to fit (%p >= %p), halting.\n",
-			    components[i].name, tail, PA2KA(LOADER_OFFSET));
+			    components[i].name, tail, (void *) PA2KA(LOADER_OFFSET));
 			halt();
 		}
Index: boot/arch/ppc32/src/main.c
===================================================================
--- boot/arch/ppc32/src/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/arch/ppc32/src/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -68,10 +68,12 @@
 	printf(" %p|%p: real mode trampoline\n", &real_mode, real_mode_pa);
 	printf(" %p|%p: boot info structure\n", &bootinfo, bootinfo_pa);
-	printf(" %p|%p: kernel entry point\n", PA2KA(BOOT_OFFSET), BOOT_OFFSET);
-	printf(" %p|%p: loader entry point\n", LOADER_ADDRESS, loader_address_pa);
+	printf(" %p|%p: kernel entry point\n",
+	    (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET);
+	printf(" %p|%p: loader entry point\n",
+	    (void *) LOADER_ADDRESS, loader_address_pa);
 	
 	size_t i;
 	for (i = 0; i < COMPONENTS; i++)
-		printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
+		printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].start,
 		    ofw_translate(components[i].start), components[i].name,
 		    components[i].inflated, components[i].size);
Index: boot/arch/sparc64/src/main.c
===================================================================
--- boot/arch/sparc64/src/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/arch/sparc64/src/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -209,13 +209,15 @@
 	void *loader_address_pa = ofw_translate((void *) LOADER_ADDRESS);
 	
-	printf("\nMemory statistics (total %llu MB, starting at %p)\n",
-	    bootinfo.memmap.total >> 20, bootinfo.physmem_start);
-	printf(" %p|%p: boot info structure\n", &bootinfo, bootinfo_pa);
-	printf(" %p|%p: kernel entry point\n", KERNEL_ADDRESS, kernel_address_pa);
-	printf(" %p|%p: loader entry point\n", LOADER_ADDRESS, loader_address_pa);
+	printf("\nMemory statistics (total %" PRIu64 " MB, starting at %p)\n",
+	    bootinfo.memmap.total >> 20, (void *) bootinfo.physmem_start);
+	printf(" %p|%p: boot info structure\n", &bootinfo, (void *) bootinfo_pa);
+	printf(" %p|%p: kernel entry point\n",
+	    (void *) KERNEL_ADDRESS, (void *) kernel_address_pa);
+	printf(" %p|%p: loader entry point\n",
+	    (void *) LOADER_ADDRESS, (void *) loader_address_pa);
 	
 	size_t i;
 	for (i = 0; i < COMPONENTS; i++)
-		printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
+		printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].start,
 		    ofw_translate(components[i].start), components[i].name,
 		    components[i].inflated, components[i].size);
Index: boot/genarch/src/ofw.c
===================================================================
--- boot/genarch/src/ofw.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/genarch/src/ofw.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -243,5 +243,5 @@
 	void *addr = ofw_claim_virt_internal(virt, len, 0);
 	if (addr != virt) {
-		printf("Error: Unable to claim virtual memory %p (size %u), halting.\n",
+		printf("Error: Unable to claim virtual memory %p (size %zu), halting.\n",
 		    virt, len);
 		halt();
@@ -254,5 +254,5 @@
 	
 	if (addr == NULL) {
-		printf("Error: Unable to claim %u bytes in virtual memory, halting.\n",
+		printf("Error: Unable to claim %zu bytes in virtual memory, halting.\n",
 		    len);
 		halt();
@@ -305,5 +305,5 @@
 	void *addr = ofw_claim_phys_internal(phys, len, 0);
 	if (addr != phys) {
-		printf("Error: Unable to claim physical memory %p (size %u), halting.\n",
+		printf("Error: Unable to claim physical memory %p (size %zu), halting.\n",
 		    phys, len);
 		halt();
@@ -315,5 +315,5 @@
 	void *addr = ofw_claim_phys_internal(NULL, len, alignment);
 	if (addr == NULL) {
-		printf("Error: Unable to claim %u bytes in physical memory, halting.\n",
+		printf("Error: Unable to claim %zu bytes in physical memory, halting.\n",
 		    len);
 		halt();
@@ -343,5 +343,5 @@
 	
 	if (ret != 0) {
-		printf("Error: Unable to map %p to %p (size %u), halting.\n",
+		printf("Error: Unable to map %p to %p (size %zu), halting.\n",
 		    virt, phys, size);
 		halt();
Index: boot/generic/include/printf.h
===================================================================
--- boot/generic/include/printf.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/generic/include/printf.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,8 +36,20 @@
 #include <stdarg.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)
 
 extern int puts(const char *);
-extern int printf(const char *, ...);
+extern int printf(const char *, ...)
+    PRINTF_ATTRIBUTE(1, 2);
 extern int vprintf(const char *, va_list);
 
Index: boot/generic/include/stdint.h
===================================================================
--- boot/generic/include/stdint.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/generic/include/stdint.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -33,27 +33,27 @@
 #define BOOT_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)
 
 #endif
Index: boot/generic/include/typedefs.h
===================================================================
--- boot/generic/include/typedefs.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/generic/include/typedefs.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,5 +37,5 @@
 #include <arch/types.h>
 
-#define NULL	((void *) 0)
+#define NULL  ((void *) 0)
 
 #define false  0
@@ -43,5 +43,4 @@
 
 typedef uint8_t bool;
-typedef int32_t wchar_t;
 
 #endif
Index: boot/generic/src/printf_core.c
===================================================================
--- boot/generic/src/printf_core.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ boot/generic/src/printf_core.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -79,5 +79,6 @@
 	PrintfQualifierLong,
 	PrintfQualifierLongLong,
-	PrintfQualifierPointer
+	PrintfQualifierPointer,
+	PrintfQualifierSize
 } qualifier_t;
 
@@ -431,6 +432,4 @@
  *  - ""   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 "s", the string is wchar_t * (wide string).@n
  *  - "ll" Signed or unsigned long long int.@n
  *
@@ -612,4 +611,9 @@
 				}
 				break;
+			case 'z':
+				qualifier = PrintfQualifierSize;
+				i = nxt;
+				uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
+				break;
 			default:
 				/* Default type */
@@ -720,4 +724,8 @@
 				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:
 				/* Unknown qualifier */
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/Makefile	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -313,4 +313,5 @@
 		test/print/print3.c \
 		test/print/print4.c \
+		test/print/print5.c \
 		test/thread/thread1.c
 	
Index: kernel/arch/abs32le/include/istate.h
===================================================================
--- kernel/arch/abs32le/include/istate.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/abs32le/include/istate.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,13 +37,18 @@
 
 #ifdef KERNEL
+
 #include <typedefs.h>
 #include <verify.h>
 #include <trace.h>
-#else
+
+#else /* KERNEL */
+
 #include <sys/types.h>
+
 #define NO_TRACE
 #define REQUIRES_EXTENT_MUTABLE(arg)
 #define WRITES(arg)
-#endif
+
+#endif /* KERNEL */
 
 /*
@@ -63,5 +68,5 @@
 	   context originated from user space. */
 	
-	return !(istate->ip & 0x80000000);
+	return !(istate->ip & UINT32_C(0x80000000));
 }
 
Index: kernel/arch/abs32le/include/mm/as.h
===================================================================
--- kernel/arch/abs32le/include/mm/as.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/abs32le/include/mm/as.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -38,8 +38,8 @@
 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
 
-#define KERNEL_ADDRESS_SPACE_START_ARCH  ((unsigned long) 0x80000000)
-#define KERNEL_ADDRESS_SPACE_END_ARCH    ((unsigned long) 0xffffffff)
-#define USER_ADDRESS_SPACE_START_ARCH    ((unsigned long) 0x00000000)
-#define USER_ADDRESS_SPACE_END_ARCH      ((unsigned long) 0x7fffffff)
+#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
+#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT32_C(0xffffffff)
+#define USER_ADDRESS_SPACE_START_ARCH    UINT32_C(0x00000000)
+#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
 
 #define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
Index: kernel/arch/abs32le/include/mm/page.h
===================================================================
--- kernel/arch/abs32le/include/mm/page.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/abs32le/include/mm/page.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -44,6 +44,6 @@
 #ifdef KERNEL
 
-#define KA2PA(x)  (((uintptr_t) (x)) - 0x80000000)
-#define PA2KA(x)  (((uintptr_t) (x)) + 0x80000000)
+#define KA2PA(x)  (((uintptr_t) (x)) - UINT32_C(0x80000000))
+#define PA2KA(x)  (((uintptr_t) (x)) + UINT32_C(0x80000000))
 
 /*
@@ -65,8 +65,8 @@
 
 /* Macros calculating indices for each level. */
-#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 22) & 0x3ff)
+#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 22) & 0x3ffU)
 #define PTL1_INDEX_ARCH(vaddr)  0
 #define PTL2_INDEX_ARCH(vaddr)  0
-#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x3ff)
+#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x3ffU)
 
 /* Get PTE address accessors for each level. */
Index: kernel/arch/abs32le/include/types.h
===================================================================
--- kernel/arch/abs32le/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/abs32le/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -53,24 +53,11 @@
 } fncptr_t;
 
-#define PRIp  "x"  /**< Format for uintptr_t. */
-#define PRIs  "u"  /**< Format for size_t. */
+#define INTN_C(c)   INT32_C(c)
+#define UINTN_C(c)  UINT32_C(c)
 
-#define PRId8   "d"    /**< Format for int8_t. */
-#define PRId16  "d"    /**< Format for int16_t. */
-#define PRId32  "d"    /**< Format for int32_t. */
-#define PRId64  "lld"  /**< Format for int64_t. */
-#define PRIdn   "d"    /**< Format for native_t. */
-
-#define PRIu8   "u"    /**< Format for uint8_t. */
-#define PRIu16  "u"    /**< Format for uint16_t. */
-#define PRIu32  "u"    /**< Format for uint32_t. */
-#define PRIu64  "llu"  /**< Format for uint64_t. */
-#define PRIun   "u"    /**< Format for unative_t. */
-
-#define PRIx8   "x"    /**< Format for hexadecimal (u)int8_t. */
-#define PRIx16  "x"    /**< Format for hexadecimal (u)int16_t. */
-#define PRIx32  "x"    /**< Format for hexadecimal (u)uint32_t. */
-#define PRIx64  "llx"  /**< Format for hexadecimal (u)int64_t. */
-#define PRIxn   "x"    /**< Format for hexadecimal (u)native_t. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for unative_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/amd64/include/context.h
===================================================================
--- kernel/arch/amd64/include/context.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/context.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup amd64	
+/** @addtogroup amd64
  * @{
  */
@@ -44,5 +44,5 @@
  * panic sooner or later
  */
-#define SP_DELTA     16
+#define SP_DELTA  16
 
 #define context_set(c, _pc, stack, size) \
Index: kernel/arch/amd64/include/context_offset.h
===================================================================
--- kernel/arch/amd64/include/context_offset.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/context_offset.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -30,22 +30,22 @@
 #define KERN_amd64_CONTEXT_OFFSET_H_
 
-#define OFFSET_SP  0x0
-#define OFFSET_PC  0x8
-#define OFFSET_RBX 0x10
-#define OFFSET_RBP 0x18
-#define OFFSET_R12 0x20
-#define OFFSET_R13 0x28
-#define OFFSET_R14 0x30
-#define OFFSET_R15 0x38
+#define OFFSET_SP   0x00
+#define OFFSET_PC   0x08
+#define OFFSET_RBX  0x10
+#define OFFSET_RBP  0x18
+#define OFFSET_R12  0x20
+#define OFFSET_R13  0x28
+#define OFFSET_R14  0x30
+#define OFFSET_R15  0x38
 
 #ifdef KERNEL
-# define OFFSET_IPL 0x40
+	#define OFFSET_IPL  0x40
 #else
-# define OFFSET_TLS 0x40
+	#define OFFSET_TLS  0x40
 #endif
 
 #ifdef __ASM__
 
-# ctx: address of the structure with saved context 
+# ctx: address of the structure with saved context
 # pc: return address
 .macro CONTEXT_SAVE_ARCH_CORE ctx:req pc:req
@@ -61,5 +61,5 @@
 .endm
 
-# ctx: address of the structure with saved context 
+# ctx: address of the structure with saved context
 .macro CONTEXT_RESTORE_ARCH_CORE ctx:req pc:req
 	movq OFFSET_R15(\ctx), %r15
@@ -68,5 +68,5 @@
 	movq OFFSET_R12(\ctx), %r12
 	movq OFFSET_RBP(\ctx), %rbp
-	movq OFFSET_RBX(\ctx), %rbx	
+	movq OFFSET_RBX(\ctx), %rbx
 	
 	movq OFFSET_SP(\ctx), %rsp   # ctx->sp -> %rsp
Index: kernel/arch/amd64/include/cpu.h
===================================================================
--- kernel/arch/amd64/include/cpu.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/cpu.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,15 +36,15 @@
 #define KERN_amd64_CPU_H_
 
-#define RFLAGS_CF	(1 << 0)
-#define RFLAGS_PF	(1 << 2)
-#define RFLAGS_AF	(1 << 4)
-#define RFLAGS_ZF	(1 << 6)
-#define RFLAGS_SF	(1 << 7)
-#define RFLAGS_TF	(1 << 8)
-#define RFLAGS_IF	(1 << 9)
-#define RFLAGS_DF	(1 << 10)
-#define RFLAGS_OF	(1 << 11)
-#define RFLAGS_NT	(1 << 14)
-#define RFLAGS_RF	(1 << 16)
+#define RFLAGS_CF  (1 << 0)
+#define RFLAGS_PF  (1 << 2)
+#define RFLAGS_AF  (1 << 4)
+#define RFLAGS_ZF  (1 << 6)
+#define RFLAGS_SF  (1 << 7)
+#define RFLAGS_TF  (1 << 8)
+#define RFLAGS_IF  (1 << 9)
+#define RFLAGS_DF  (1 << 10)
+#define RFLAGS_OF  (1 << 11)
+#define RFLAGS_NT  (1 << 14)
+#define RFLAGS_RF  (1 << 16)
 
 #define EFER_MSR_NUM    0xc0000080
Index: kernel/arch/amd64/include/debugger.h
===================================================================
--- kernel/arch/amd64/include/debugger.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/debugger.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -41,9 +41,9 @@
 
 /* Flags that are passed to breakpoint_add function */
-#define BKPOINT_INSTR       0x1
-#define BKPOINT_WRITE       0x2
-#define BKPOINT_READ_WRITE  0x4
+#define BKPOINT_INSTR       0x1U
+#define BKPOINT_WRITE       0x2U
+#define BKPOINT_READ_WRITE  0x4U
 
-#define BKPOINT_CHECK_ZERO  0x8
+#define BKPOINT_CHECK_ZERO  0x8U
 
 
Index: kernel/arch/amd64/include/istate.h
===================================================================
--- kernel/arch/amd64/include/istate.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/istate.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,10 +37,15 @@
 
 #ifdef KERNEL
+
 #include <typedefs.h>
 #include <trace.h>
-#else
+
+#else /* KERNEL */
+
 #include <sys/types.h>
+
 #define NO_TRACE
-#endif
+
+#endif /* KERNEL */
 
 /** This is passed to interrupt handlers */
@@ -61,13 +66,13 @@
 	uint64_t r14;
 	uint64_t r15;
-	uint64_t alignment;	/* align rbp_frame on multiple of 16 */
-	uint64_t rbp_frame;	/* imitation of frame pointer linkage */
-	uint64_t rip_frame;	/* imitation of return address linkage */
-	uint64_t error_word;	/* real or fake error word */
+	uint64_t alignment;   /* align rbp_frame on multiple of 16 */
+	uint64_t rbp_frame;   /* imitation of frame pointer linkage */
+	uint64_t rip_frame;   /* imitation of return address linkage */
+	uint64_t error_word;  /* real or fake error word */
 	uint64_t rip;
 	uint64_t cs;
 	uint64_t rflags;
-	uint64_t rsp;		/* only if istate_t is from uspace */
-	uint64_t ss;		/* only if istate_t is from uspace */
+	uint64_t rsp;         /* only if istate_t is from uspace */
+	uint64_t ss;          /* only if istate_t is from uspace */
 } istate_t;
 
@@ -75,5 +80,5 @@
 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
 {
-	return !(istate->rip & 0x8000000000000000);
+	return !(istate->rip & UINT64_C(0x8000000000000000));
 }
 
Index: kernel/arch/amd64/include/mm/as.h
===================================================================
--- kernel/arch/amd64/include/mm/as.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/mm/as.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,14 +36,14 @@
 #define KERN_amd64_AS_H_
 
-#define ADDRESS_SPACE_HOLE_START	0x0000800000000000ULL
-#define ADDRESS_SPACE_HOLE_END		0xffff7fffffffffffULL
+#define ADDRESS_SPACE_HOLE_START  UINT64_C(0x0000800000000000)
+#define ADDRESS_SPACE_HOLE_END    UINT64_C(0xffff7fffffffffff)
 
 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
 
-#define KERNEL_ADDRESS_SPACE_START_ARCH	0xffff800000000000ULL
-#define KERNEL_ADDRESS_SPACE_END_ARCH	0xffffffffffffffffULL
+#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xffff800000000000)
+#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT64_C(0xffffffffffffffff)
 
-#define USER_ADDRESS_SPACE_START_ARCH	0x0000000000000000ULL
-#define USER_ADDRESS_SPACE_END_ARCH	0x00007fffffffffffULL
+#define USER_ADDRESS_SPACE_START_ARCH  UINT64_C(0x0000000000000000)
+#define USER_ADDRESS_SPACE_END_ARCH    UINT64_C(0x00007fffffffffff)
 
 #define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
Index: kernel/arch/amd64/include/mm/page.h
===================================================================
--- kernel/arch/amd64/include/mm/page.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/mm/page.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -55,6 +55,6 @@
 #ifndef __ASM__
 
-#define KA2PA(x)  (((uintptr_t) (x)) - 0xffff800000000000)
-#define PA2KA(x)  (((uintptr_t) (x)) + 0xffff800000000000)
+#define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffff800000000000))
+#define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffff800000000000))
 
 #else /* __ASM__ */
@@ -78,8 +78,8 @@
 
 /* Macros calculating indices into page tables in each level. */
-#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 39) & 0x1ff)
-#define PTL1_INDEX_ARCH(vaddr)  (((vaddr) >> 30) & 0x1ff)
-#define PTL2_INDEX_ARCH(vaddr)  (((vaddr) >> 21) & 0x1ff)
-#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x1ff)
+#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 39) & 0x1ffU)
+#define PTL1_INDEX_ARCH(vaddr)  (((vaddr) >> 30) & 0x1ffU)
+#define PTL2_INDEX_ARCH(vaddr)  (((vaddr) >> 21) & 0x1ffU)
+#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x1ffU)
 
 /* Get PTE address accessors for each level. */
@@ -205,5 +205,5 @@
 	pte_t *p = &pt[i];
 	
-	p->addr_12_31 = (a >> 12) & 0xfffff;
+	p->addr_12_31 = (a >> 12) & UINT32_C(0xfffff);
 	p->addr_32_51 = a >> 32;
 }
Index: kernel/arch/amd64/include/pm.h
===================================================================
--- kernel/arch/amd64/include/pm.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/pm.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -75,7 +75,7 @@
 #define AR_WRITABLE   (1 << 1)
 #define AR_READABLE   (1 << 1)
-#define AR_TSS        (0x09)
-#define AR_INTERRUPT  (0x0e)
-#define AR_TRAP       (0x0f)
+#define AR_TSS        (0x09U)
+#define AR_INTERRUPT  (0x0eU)
+#define AR_TRAP       (0x0fU)
 
 #define DPL_KERNEL  (PL_KERNEL << 5)
Index: kernel/arch/amd64/include/types.h
===================================================================
--- kernel/arch/amd64/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -50,26 +50,11 @@
 } fncptr_t;
 
-/* Formats for uintptr_t, size_t */
-#define PRIp  "llx"
-#define PRIs  "llu"
+#define INTN_C(c)   INT64_C(c)
+#define UINTN_C(c)  UINT64_C(c)
 
-/* Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */
-#define PRId8   "d"
-#define PRId16  "d"
-#define PRId32  "d"
-#define PRId64  "lld"
-#define PRIdn   "lld"
-
-#define PRIu8   "u"
-#define PRIu16  "u"
-#define PRIu32  "u"
-#define PRIu64  "llu"
-#define PRIun   "llu"
-
-#define PRIx8   "x"
-#define PRIx16  "x"
-#define PRIx32  "x"
-#define PRIx64  "llx"
-#define PRIxn   "llx"
+#define PRIdn  PRId64  /**< Format for native_t. */
+#define PRIun  PRIu64  /**< Format for unative_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/amd64/src/boot/memmap.c
===================================================================
--- kernel/arch/amd64/src/boot/memmap.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/src/boot/memmap.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -35,5 +35,5 @@
 #include <arch/boot/memmap.h>
 
-uint8_t e820counter = 0xff;
+uint8_t e820counter = 0xffU;
 e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
 
Index: kernel/arch/amd64/src/cpu/cpu.c
===================================================================
--- kernel/arch/amd64/src/cpu/cpu.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/src/cpu/cpu.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -47,12 +47,11 @@
  * Contains only non-MP-Specification specific SMP code.
  */
-#define AMD_CPUID_EBX  0x68747541
-#define AMD_CPUID_ECX  0x444d4163
-#define AMD_CPUID_EDX  0x69746e65
+#define AMD_CPUID_EBX  UINT32_C(0x68747541)
+#define AMD_CPUID_ECX  UINT32_C(0x444d4163)
+#define AMD_CPUID_EDX  UINT32_C(0x69746e65)
 
-#define INTEL_CPUID_EBX  0x756e6547
-#define INTEL_CPUID_ECX  0x6c65746e
-#define INTEL_CPUID_EDX  0x49656e69
-
+#define INTEL_CPUID_EBX  UINT32_C(0x756e6547)
+#define INTEL_CPUID_ECX  UINT32_C(0x6c65746e)
+#define INTEL_CPUID_EDX  UINT32_C(0x49656e69)
 
 enum vendor {
Index: kernel/arch/amd64/src/debugger.c
===================================================================
--- kernel/arch/amd64/src/debugger.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/src/debugger.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -126,5 +126,5 @@
 	/* Disable breakpoint in DR7 */
 	unative_t dr7 = read_dr7();
-	dr7 &= ~(0x2 << (curidx * 2));
+	dr7 &= ~(0x02U << (curidx * 2));
 	
 	/* Setup DR register */
@@ -147,24 +147,24 @@
 		
 		/* Set type to requested breakpoint & length*/
-		dr7 &= ~(0x3 << (16 + 4 * curidx));
-		dr7 &= ~(0x3 << (18 + 4 * curidx));
+		dr7 &= ~(0x03U << (16 + 4 * curidx));
+		dr7 &= ~(0x03U << (18 + 4 * curidx));
 		
 		if (!(flags & BKPOINT_INSTR)) {
 #ifdef __32_BITS__
-			dr7 |= ((unative_t) 0x3) << (18 + 4 * curidx);
+			dr7 |= ((unative_t) 0x03U) << (18 + 4 * curidx);
 #endif
 			
 #ifdef __64_BITS__
-			dr7 |= ((unative_t) 0x2) << (18 + 4 * curidx);
+			dr7 |= ((unative_t) 0x02U) << (18 + 4 * curidx);
 #endif
 			
 			if ((flags & BKPOINT_WRITE))
-				dr7 |= ((unative_t) 0x1) << (16 + 4 * curidx);
+				dr7 |= ((unative_t) 0x01U) << (16 + 4 * curidx);
 			else if ((flags & BKPOINT_READ_WRITE))
-				dr7 |= ((unative_t) 0x3) << (16 + 4 * curidx);
+				dr7 |= ((unative_t) 0x03U) << (16 + 4 * curidx);
 		}
 		
 		/* Enable global breakpoint */
-		dr7 |= 0x2 << (curidx * 2);
+		dr7 |= 0x02U << (curidx * 2);
 		
 		write_dr7(dr7);
@@ -230,14 +230,14 @@
 				return;
 			
-			printf("*** Found ZERO on address %" PRIp " (slot %d) ***\n",
-			    breakpoints[slot].address, slot);
+			printf("*** Found ZERO on address %p (slot %d) ***\n",
+			    (void *) breakpoints[slot].address, slot);
 		} else {
-			printf("Data watchpoint - new data: %" PRIp "\n",
+			printf("Data watchpoint - new data: %#" PRIxn "\n",
 			    *((unative_t *) breakpoints[slot].address));
 		}
 	}
 	
-	printf("Reached breakpoint %d:%" PRIp " (%s)\n", slot, getip(istate),
-	    symtab_fmt_name_lookup(getip(istate)));
+	printf("Reached breakpoint %d:%p (%s)\n", slot,
+	    (void *) getip(istate), symtab_fmt_name_lookup(getip(istate)));
 	
 #ifdef CONFIG_KCONSOLE
@@ -363,12 +363,12 @@
 			
 #ifdef __32_BITS__
-			printf("%-4u %7" PRIs " %p %s\n", i,
-			    breakpoints[i].counter, breakpoints[i].address,
+			printf("%-4u %7zu %p %s\n", i,
+			    breakpoints[i].counter, (void *) breakpoints[i].address,
 			    symbol);
 #endif
 			
 #ifdef __64_BITS__
-			printf("%-4u %7" PRIs " %p %s\n", i,
-			    breakpoints[i].counter, breakpoints[i].address,
+			printf("%-4u %7zu %p %s\n", i,
+			    breakpoints[i].counter, (void *) breakpoints[i].address,
 			    symbol);
 #endif
@@ -405,7 +405,8 @@
 		flags = BKPOINT_WRITE;
 	
-	printf("Adding breakpoint on address: %p\n", argv->intval);
-	
-	int id = breakpoint_add((void *)argv->intval, flags, -1);
+	printf("Adding breakpoint on address: %p\n",
+	    (void *) argv->intval);
+	
+	int id = breakpoint_add((void *) argv->intval, flags, -1);
 	if (id < 0)
 		printf("Add breakpoint failed.\n");
Index: kernel/arch/amd64/src/interrupt.c
===================================================================
--- kernel/arch/amd64/src/interrupt.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/src/interrupt.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -65,18 +65,28 @@
 void istate_decode(istate_t *istate)
 {
-	printf("cs =%p\trip=%p\trfl=%p\terr=%p\n",
-	    istate->cs, istate->rip, istate->rflags, istate->error_word);
-
+	printf("cs =%#0" PRIx64 "\trip=%p\t"
+	    "rfl=%#0" PRIx64 "\terr=%#0" PRIx64 "\n",
+	    istate->cs, (void *) istate->rip,
+	    istate->rflags, istate->error_word);
+	
 	if (istate_from_uspace(istate))
-		printf("ss =%p\n", istate->ss);
-	
-	printf("rax=%p\trbx=%p\trcx=%p\trdx=%p\n",
+		printf("ss =%#0" PRIx64 "\n", istate->ss);
+	
+	printf("rax=%#0" PRIx64 "\trbx=%#0" PRIx64 "\t"
+	    "rcx=%#0" PRIx64 "\trdx=%#0" PRIx64 "\n",
 	    istate->rax, istate->rbx, istate->rcx, istate->rdx);
+	
 	printf("rsi=%p\trdi=%p\trbp=%p\trsp=%p\n",
-	    istate->rsi, istate->rdi, istate->rbp,
-	    istate_from_uspace(istate) ? istate->rsp : (uintptr_t)&istate->rsp);
-	printf("r8 =%p\tr9 =%p\tr10=%p\tr11=%p\n",
+	    (void *) istate->rsi, (void *) istate->rdi,
+	    (void *) istate->rbp,
+	    istate_from_uspace(istate) ? ((void *) istate->rsp) :
+	    &istate->rsp);
+	
+	printf("r8 =%#0" PRIx64 "\tr9 =%#0" PRIx64 "\t"
+	    "r10=%#0" PRIx64 "\tr11=%#0" PRIx64 "\n",
 	    istate->r8, istate->r9, istate->r10, istate->r11);
-	printf("r12=%p\tr13=%p\tr14=%p\tr15=%p\n",
+	
+	printf("r12=%#0" PRIx64 "\tr13=%#0" PRIx64 "\t"
+	    "r14=%#0" PRIx64 "\tr15=%#0" PRIx64 "\n",
 	    istate->r12, istate->r13, istate->r14, istate->r15);
 }
Index: kernel/arch/amd64/src/mm/page.c
===================================================================
--- kernel/arch/amd64/src/mm/page.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/src/mm/page.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -89,5 +89,5 @@
 	
 	if (as_page_fault(page, access, istate) == AS_PF_FAULT) {
-		fault_if_from_uspace(istate, "Page fault: %#x.", page);
+		fault_if_from_uspace(istate, "Page fault: %p.", (void *) page);
 		panic_memtrap(istate, access, page, NULL);
 	}
@@ -97,6 +97,6 @@
 {
 	if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
-		panic("Unable to map physical memory %p (%" PRIs " bytes).", physaddr,
-		    size);
+		panic("Unable to map physical memory %p (%zu bytes).",
+		    (void *) physaddr, size);
 	
 	uintptr_t virtaddr = PA2KA(last_frame);
Index: kernel/arch/amd64/src/pm.c
===================================================================
--- kernel/arch/amd64/src/pm.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/amd64/src/pm.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -28,5 +28,5 @@
  */
 
-/** @addtogroup amd64	
+/** @addtogroup amd64
  * @{
  */
@@ -52,57 +52,57 @@
 	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
 	/* KTEXT descriptor */
-	{ .limit_0_15  = 0xffff, 
-	  .base_0_15   = 0, 
-	  .base_16_23  = 0, 
-	  .access      = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE, 
-	  .limit_16_19 = 0xf, 
-	  .available   = 0, 
-	  .longmode    = 1, 
+	{ .limit_0_15  = 0xffffU,
+	  .base_0_15   = 0,
+	  .base_16_23  = 0,
+	  .access      = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE,
+	  .limit_16_19 = 0x0fU,
+	  .available   = 0,
+	  .longmode    = 1,
 	  .special     = 0,
-	  .granularity = 1, 
+	  .granularity = 1,
 	  .base_24_31  = 0 },
 	/* KDATA descriptor */
-	{ .limit_0_15  = 0xffff, 
-	  .base_0_15   = 0, 
-	  .base_16_23  = 0, 
-	  .access      = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 
-	  .limit_16_19 = 0xf, 
-	  .available   = 0, 
-	  .longmode    = 0, 
-	  .special     = 0, 
-	  .granularity = 1, 
+	{ .limit_0_15  = 0xffffU,
+	  .base_0_15   = 0,
+	  .base_16_23  = 0,
+	  .access      = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL,
+	  .limit_16_19 = 0x0fU,
+	  .available   = 0,
+	  .longmode    = 0,
+	  .special     = 0,
+	  .granularity = 1,
 	  .base_24_31  = 0 },
 	/* UDATA descriptor */
-	{ .limit_0_15  = 0xffff, 
-	  .base_0_15   = 0, 
-	  .base_16_23  = 0, 
-	  .access      = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 
-	  .limit_16_19 = 0xf, 
-	  .available   = 0, 
-	  .longmode    = 0, 
-	  .special     = 1, 
-	  .granularity = 1, 
+	{ .limit_0_15  = 0xffffU,
+	  .base_0_15   = 0,
+	  .base_16_23  = 0,
+	  .access      = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER,
+	  .limit_16_19 = 0x0fU,
+	  .available   = 0,
+	  .longmode    = 0,
+	  .special     = 1,
+	  .granularity = 1,
 	  .base_24_31  = 0 },
 	/* UTEXT descriptor */
-	{ .limit_0_15  = 0xffff, 
-	  .base_0_15   = 0, 
-	  .base_16_23  = 0, 
-	  .access      = AR_PRESENT | AR_CODE | DPL_USER, 
-	  .limit_16_19 = 0xf, 
-	  .available   = 0, 
-	  .longmode    = 1, 
-	  .special     = 0, 
-	  .granularity = 1, 
+	{ .limit_0_15  = 0xffffU,
+	  .base_0_15   = 0,
+	  .base_16_23  = 0,
+	  .access      = AR_PRESENT | AR_CODE | DPL_USER,
+	  .limit_16_19 = 0x0fU,
+	  .available   = 0,
+	  .longmode    = 1,
+	  .special     = 0,
+	  .granularity = 1,
 	  .base_24_31  = 0 },
 	/* KTEXT 32-bit protected, for protected mode before long mode */
-	{ .limit_0_15  = 0xffff, 
-	  .base_0_15   = 0, 
-	  .base_16_23  = 0, 
-	  .access      = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE, 
-	  .limit_16_19 = 0xf, 
-	  .available   = 0, 
-	  .longmode    = 0, 
+	{ .limit_0_15  = 0xffffU,
+	  .base_0_15   = 0,
+	  .base_16_23  = 0,
+	  .access      = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE,
+	  .limit_16_19 = 0x0fU,
+	  .available   = 0,
+	  .longmode    = 0,
 	  .special     = 1,
-	  .granularity = 1, 
+	  .granularity = 1,
 	  .base_24_31  = 0 },
 	/* TSS descriptor - set up will be completed later,
@@ -111,7 +111,8 @@
 	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
 	/* VESA Init descriptor */
-#ifdef CONFIG_FB	
-	{ 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | DPL_KERNEL,
-	  0xf, 0, 0, 0, 0, 0
+#ifdef CONFIG_FB
+	{
+		0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | DPL_KERNEL,
+		    0xf, 0, 0, 0, 0, 0
 	}
 #endif
@@ -129,8 +130,8 @@
 {
 	tss_descriptor_t *td = (tss_descriptor_t *) d;
-
-	td->base_0_15 = base & 0xffff;
-	td->base_16_23 = ((base) >> 16) & 0xff;
-	td->base_24_31 = ((base) >> 24) & 0xff;
+	
+	td->base_0_15 = base & 0xffffU;
+	td->base_16_23 = ((base) >> 16) & 0xffU;
+	td->base_24_31 = ((base) >> 24) & 0xffU;
 	td->base_32_63 = ((base) >> 32);
 }
@@ -140,6 +141,6 @@
 	tss_descriptor_t *td = (tss_descriptor_t *) d;
 	
-	td->limit_0_15 = limit & 0xffff;
-	td->limit_16_19 = (limit >> 16) & 0xf;
+	td->limit_0_15 = limit & 0xffffU;
+	td->limit_16_19 = (limit >> 16) & 0x0fU;
 }
 
@@ -149,6 +150,6 @@
 	 * Offset is a linear address.
 	 */
-	d->offset_0_15 = offset & 0xffff;
-	d->offset_16_31 = offset >> 16 & 0xffff;
+	d->offset_0_15 = offset & 0xffffU;
+	d->offset_16_31 = (offset >> 16) & 0xffffU;
 	d->offset_32_63 = offset >> 32;
 }
@@ -165,16 +166,16 @@
 {
 	idescriptor_t *d;
-	int i;
-
+	unsigned int i;
+	
 	for (i = 0; i < IDT_ITEMS; i++) {
 		d = &idt[i];
-
+		
 		d->unused = 0;
 		d->selector = GDT_SELECTOR(KTEXT_DES);
-
+		
 		d->present = 1;
-		d->type = AR_INTERRUPT;	/* masking interrupt */
+		d->type = AR_INTERRUPT;  /* masking interrupt */
 	}
-
+	
 	d = &idt[0];
 	idt_setoffset(d++, (uintptr_t) &int_0);
Index: kernel/arch/arm32/include/types.h
===================================================================
--- kernel/arch/arm32/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/arm32/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -57,24 +57,11 @@
 } fncptr_t;
 
-#define PRIp "x"  /**< Format for uintptr_t. */
-#define PRIs "u"  /**< Format for size_t. */
+#define INTN_C(c)   INT32_C(c)
+#define UINTN_C(c)  UINT32_C(c)
 
-#define PRId8 "d"     /**< Format for int8_t. */
-#define PRId16 "d"    /**< Format for int16_t. */
-#define PRId32 "d"    /**< Format for int32_t. */
-#define PRId64 "lld"  /**< Format for int64_t. */
-#define PRIdn "d"     /**< Format for native_t. */
-
-#define PRIu8 "u"     /**< Format for uint8_t. */
-#define PRIu16 "u"    /**< Format for uint16_t. */
-#define PRIu32 "u"    /**< Format for uint32_t. */
-#define PRIu64 "llu"  /**< Format for uint64_t. */
-#define PRIun "u"     /**< Format for unative_t. */
-
-#define PRIx8 "x"     /**< Format for hexadecimal (u)int8_t. */
-#define PRIx16 "x"    /**< Format for hexadecimal (u)int16_t. */
-#define PRIx32 "x"    /**< Format for hexadecimal (u)uint32_t. */
-#define PRIx64 "llx"  /**< Format for hexadecimal (u)int64_t. */
-#define PRIxn "x"     /**< Format for hexadecimal (u)native_t. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for unative_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/arm32/src/exception.c
===================================================================
--- kernel/arch/arm32/src/exception.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/arm32/src/exception.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -175,12 +175,17 @@
 void istate_decode(istate_t *istate)
 {
-	printf("r0 =%#0.8lx\tr1 =%#0.8lx\tr2 =%#0.8lx\tr3 =%#0.8lx\n",
+	printf("r0 =%#0" PRIx32 "\tr1 =%#0" PRIx32 "\t"
+	    "r2 =%#0" PRIx32 "\tr3 =%#0" PRIx32 "\n",
 	    istate->r0, istate->r1, istate->r2, istate->r3);
-	printf("r4 =%#0.8lx\tr5 =%#0.8lx\tr6 =%#0.8lx\tr7 =%#0.8lx\n",
+	printf("r4 =%#" PRIx32 "\tr5 =%#0" PRIx32 "\t"
+	    "r6 =%#0" PRIx32 "\tr7 =%#0" PRIx32 "\n",
 	    istate->r4, istate->r5, istate->r6, istate->r7);
-	printf("r8 =%#0.8lx\tr9 =%#0.8lx\tr10=%#0.8lx\tfp =%#0.8lx\n",
-	    istate->r8, istate->r9, istate->r10, istate->fp);
-	printf("r12=%#0.8lx\tsp =%#0.8lx\tlr =%#0.8lx\tspsr=%#0.8lx\n",
-	    istate->r12, istate->sp, istate->lr, istate->spsr);
+	printf("r8 =%#0" PRIx32 "\tr9 =%#0" PRIx32 "\t"
+	    "r10=%#0" PRIx32 "\tfp =%p\n",
+	    istate->r8, istate->r9, istate->r10,
+	    (void *) istate->fp);
+	printf("r12=%#0" PRIx32 "\tsp =%p\tlr =%p\tspsr=%p\n",
+	    istate->r12, (void *) istate->sp,
+	    (void *) istate->lr, (void *) istate->spsr);
 }
 
Index: kernel/arch/arm32/src/mm/page.c
===================================================================
--- kernel/arch/arm32/src/mm/page.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/arm32/src/mm/page.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -93,5 +93,5 @@
 	    KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) {
 		panic("Unable to map physical memory %p (%d bytes).",
-		    physaddr, size);
+		    (void *) physaddr, size);
 	}
 	
Index: kernel/arch/arm32/src/mm/page_fault.c
===================================================================
--- kernel/arch/arm32/src/mm/page_fault.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/arm32/src/mm/page_fault.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -141,5 +141,6 @@
 	if (instr.condition == 0xf) {
 		panic("page_fault - instruction does not access memory "
-		    "(instr_code: %x, badvaddr:%x).", instr, badvaddr);
+		    "(instr_code: %#0" PRIx32 ", badvaddr:%p).",
+		    instr_union.pc, (void *) badvaddr);
 		return PF_ACCESS_EXEC;
 	}
@@ -160,5 +161,6 @@
 
 	panic("page_fault - instruction doesn't access memory "
-	    "(instr_code: %x, badvaddr:%x).", instr, badvaddr);
+	    "(instr_code: %#0" PRIx32 ", badvaddr:%p).",
+	    instr_union.pc, (void *) badvaddr);
 
 	return PF_ACCESS_EXEC;
Index: kernel/arch/ia32/include/boot/boot.h
===================================================================
--- kernel/arch/ia32/include/boot/boot.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/boot/boot.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -38,5 +38,5 @@
 #define BOOT_OFFSET      0x108000
 #define AP_BOOT_OFFSET   0x8000
-#define BOOT_STACK_SIZE  0x400
+#define BOOT_STACK_SIZE  0x0400
 
 #define MULTIBOOT_HEADER_MAGIC  0x1BADB002
Index: kernel/arch/ia32/include/boot/memmap.h
===================================================================
--- kernel/arch/ia32/include/boot/memmap.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/boot/memmap.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -70,5 +70,5 @@
 
 extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
-extern uint8_t e820counter; 
+extern uint8_t e820counter;
 
 #endif
Index: kernel/arch/ia32/include/context.h
===================================================================
--- kernel/arch/ia32/include/context.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/context.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
@@ -40,5 +40,5 @@
 #include <typedefs.h>
 
-#define STACK_ITEM_SIZE	4
+#define STACK_ITEM_SIZE  4
 
 /*
@@ -48,5 +48,5 @@
  * One item is put onto stack to support get_stack_base().
  */
-#define SP_DELTA	(8 + STACK_ITEM_SIZE)
+#define SP_DELTA  (8 + STACK_ITEM_SIZE)
 
 #define context_set(c, _pc, stack, size) \
Index: kernel/arch/ia32/include/context_offset.h
===================================================================
--- kernel/arch/ia32/include/context_offset.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/context_offset.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
@@ -36,33 +36,32 @@
 #define KERN_ia32_CONTEXT_OFFSET_H_
 
-#define OFFSET_SP  0x0
-#define OFFSET_PC  0x4
-#define OFFSET_EBX 0x8
-#define OFFSET_ESI 0xC
-#define OFFSET_EDI 0x10
-#define OFFSET_EBP 0x14
+#define OFFSET_SP   0x00
+#define OFFSET_PC   0x04
+#define OFFSET_EBX  0x08
+#define OFFSET_ESI  0x0C
+#define OFFSET_EDI  0x10
+#define OFFSET_EBP  0x14
 
-#ifdef KERNEL 
-# define OFFSET_IPL 0x18
+#ifdef KERNEL
+	#define OFFSET_IPL  0x18
 #else
-# define OFFSET_TLS 0x18
+	#define OFFSET_TLS  0x18
 #endif
 
+#ifdef __ASM__
 
-#ifdef __ASM__ 
-
-# ctx: address of the structure with saved context 
+# ctx: address of the structure with saved context
 # pc: return address
 
 .macro CONTEXT_SAVE_ARCH_CORE ctx:req pc:req
-	movl %esp,OFFSET_SP(\ctx)	# %esp -> ctx->sp	
+	movl %esp,OFFSET_SP(\ctx)	# %esp -> ctx->sp
 	movl \pc,OFFSET_PC(\ctx)	# %eip -> ctx->pc
-	movl %ebx,OFFSET_EBX(\ctx)	# %ebx -> ctx->ebx	
-	movl %esi,OFFSET_ESI(\ctx)	# %esi -> ctx->esi	
-	movl %edi,OFFSET_EDI(\ctx)	# %edi -> ctx->edi	
-	movl %ebp,OFFSET_EBP(\ctx)	# %ebp -> ctx->ebp	
+	movl %ebx,OFFSET_EBX(\ctx)	# %ebx -> ctx->ebx
+	movl %esi,OFFSET_ESI(\ctx)	# %esi -> ctx->esi
+	movl %edi,OFFSET_EDI(\ctx)	# %edi -> ctx->edi
+	movl %ebp,OFFSET_EBP(\ctx)	# %ebp -> ctx->ebp
 .endm
 
-# ctx: address of the structure with saved context 
+# ctx: address of the structure with saved context
 
 .macro CONTEXT_RESTORE_ARCH_CORE ctx:req pc:req
@@ -75,5 +74,5 @@
 .endm
 
-#endif /* __ASM__ */ 
+#endif /* __ASM__ */
 
 #endif
@@ -81,3 +80,2 @@
 /** @}
  */
-
Index: kernel/arch/ia32/include/cpu.h
===================================================================
--- kernel/arch/ia32/include/cpu.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/cpu.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -44,7 +44,7 @@
 
 /* Support for SYSENTER and SYSEXIT */
-#define IA32_MSR_SYSENTER_CS	0x174
-#define IA32_MSR_SYSENTER_ESP	0x175
-#define IA32_MSR_SYSENTER_EIP	0x176
+#define IA32_MSR_SYSENTER_CS   0x174U
+#define IA32_MSR_SYSENTER_ESP  0x175U
+#define IA32_MSR_SYSENTER_EIP  0x176U
 
 #ifndef __ASM__
Index: kernel/arch/ia32/include/drivers/i8259.h
===================================================================
--- kernel/arch/ia32/include/drivers/i8259.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/drivers/i8259.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -39,8 +39,8 @@
 #include <arch/interrupt.h>
 
-#define PIC_PIC0PORT1  ((ioport8_t *) 0x20)
-#define PIC_PIC0PORT2  ((ioport8_t *) 0x21)
-#define PIC_PIC1PORT1  ((ioport8_t *) 0xa0)
-#define PIC_PIC1PORT2  ((ioport8_t *) 0xa1)
+#define PIC_PIC0PORT1  ((ioport8_t *) 0x20U)
+#define PIC_PIC0PORT2  ((ioport8_t *) 0x21U)
+#define PIC_PIC1PORT1  ((ioport8_t *) 0xa0U)
+#define PIC_PIC1PORT2  ((ioport8_t *) 0xa1U)
 
 #define PIC_NEEDICW4  (1 << 0)
Index: kernel/arch/ia32/include/istate.h
===================================================================
--- kernel/arch/ia32/include/istate.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/istate.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,10 +37,15 @@
 
 #ifdef KERNEL
+
 #include <typedefs.h>
 #include <trace.h>
-#else
+
+#else /* KERNEL */
+
 #include <sys/types.h>
+
 #define NO_TRACE
-#endif
+
+#endif /* KERNEL */
 
 typedef struct istate {
@@ -77,5 +82,5 @@
 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
 {
-	return !(istate->eip & 0x80000000);
+	return !(istate->eip & UINT32_C(0x80000000));
 }
 
Index: kernel/arch/ia32/include/mm/as.h
===================================================================
--- kernel/arch/ia32/include/mm/as.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/mm/as.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,12 +36,12 @@
 #define KERN_ia32_AS_H_
 
-#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH	0
+#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
 
-#define KERNEL_ADDRESS_SPACE_START_ARCH		((unsigned long) 0x80000000)
-#define KERNEL_ADDRESS_SPACE_END_ARCH		((unsigned long) 0xffffffff)
-#define USER_ADDRESS_SPACE_START_ARCH		((unsigned long) 0x00000000)
-#define USER_ADDRESS_SPACE_END_ARCH		((unsigned long) 0x7fffffff)
+#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
+#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT32_C(0xffffffff)
+#define USER_ADDRESS_SPACE_START_ARCH    UINT32_C(0x00000000)
+#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
 
-#define USTACK_ADDRESS_ARCH	(USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
+#define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
 
 typedef struct {
@@ -50,7 +50,7 @@
 #include <genarch/mm/as_pt.h>
 
-#define as_constructor_arch(as, flags)		(as != as)
-#define as_destructor_arch(as)			(as != as)
-#define as_create_arch(as, flags)		(as != as)
+#define as_constructor_arch(as, flags)  (as != as)
+#define as_destructor_arch(as)          (as != as)
+#define as_create_arch(as, flags)       (as != as)
 #define as_install_arch(as)
 #define as_deinstall_arch(as)
Index: kernel/arch/ia32/include/mm/page.h
===================================================================
--- kernel/arch/ia32/include/mm/page.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/mm/page.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -39,16 +39,20 @@
 #include <trace.h>
 
-#define PAGE_WIDTH	FRAME_WIDTH
-#define PAGE_SIZE	FRAME_SIZE
+#define PAGE_WIDTH  FRAME_WIDTH
+#define PAGE_SIZE   FRAME_SIZE
 
 #ifdef KERNEL
 
 #ifndef __ASM__
-#	define KA2PA(x)	(((uintptr_t) (x)) - 0x80000000)
-#	define PA2KA(x)	(((uintptr_t) (x)) + 0x80000000)
-#else
-#	define KA2PA(x)	((x) - 0x80000000)
-#	define PA2KA(x)	((x) + 0x80000000)
-#endif
+
+#define KA2PA(x)  (((uintptr_t) (x)) - UINT32_C(0x80000000))
+#define PA2KA(x)  (((uintptr_t) (x)) + UINT32_C(0x80000000))
+
+#else /* __ASM__ */
+
+#define KA2PA(x)  ((x) - 0x80000000)
+#define PA2KA(x)  ((x) + 0x80000000)
+
+#endif /* __ASM__ */
 
 /*
@@ -58,20 +62,20 @@
 
 /* Number of entries in each level. */
-#define PTL0_ENTRIES_ARCH	1024
-#define PTL1_ENTRIES_ARCH	0
-#define PTL2_ENTRIES_ARCH	0
-#define PTL3_ENTRIES_ARCH	1024
+#define PTL0_ENTRIES_ARCH  1024
+#define PTL1_ENTRIES_ARCH  0
+#define PTL2_ENTRIES_ARCH  0
+#define PTL3_ENTRIES_ARCH  1024
 
 /* Page table sizes for each level. */
-#define PTL0_SIZE_ARCH		ONE_FRAME
-#define PTL1_SIZE_ARCH		0
-#define PTL2_SIZE_ARCH		0
-#define PTL3_SIZE_ARCH		ONE_FRAME
+#define PTL0_SIZE_ARCH  ONE_FRAME
+#define PTL1_SIZE_ARCH  0
+#define PTL2_SIZE_ARCH  0
+#define PTL3_SIZE_ARCH  ONE_FRAME
 
 /* Macros calculating indices for each level. */
-#define PTL0_INDEX_ARCH(vaddr)	(((vaddr) >> 22) & 0x3ff)
-#define PTL1_INDEX_ARCH(vaddr)	0
-#define PTL2_INDEX_ARCH(vaddr)	0
-#define PTL3_INDEX_ARCH(vaddr)	(((vaddr) >> 12) & 0x3ff)
+#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 22) & 0x3ffU)
+#define PTL1_INDEX_ARCH(vaddr)  0
+#define PTL2_INDEX_ARCH(vaddr)  0
+#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x3ffU)
 
 /* Get PTE address accessors for each level. */
@@ -122,5 +126,5 @@
 #define PTE_WRITABLE_ARCH(p) \
 	((p)->writeable != 0)
-#define PTE_EXECUTABLE_ARCH(p)			1
+#define PTE_EXECUTABLE_ARCH(p)  1
 
 #ifndef __ASM__
@@ -144,5 +148,5 @@
 
 /** When bit on this position is 1, a reserved bit was set in page directory. */ 
-#define PFERR_CODE_RSVD		(1 << 3)	
+#define PFERR_CODE_RSVD		(1 << 3)
 
 /** Page Table Entry. */
Index: kernel/arch/ia32/include/smp/ap.h
===================================================================
--- kernel/arch/ia32/include/smp/ap.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/smp/ap.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
Index: kernel/arch/ia32/include/smp/apic.h
===================================================================
--- kernel/arch/ia32/include/smp/apic.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/smp/apic.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -49,63 +49,63 @@
 
 /** Delivery modes. */
-#define DELMOD_FIXED    0x0
-#define DELMOD_LOWPRI   0x1
-#define DELMOD_SMI      0x2
+#define DELMOD_FIXED    0x0U
+#define DELMOD_LOWPRI   0x1U
+#define DELMOD_SMI      0x2U
 /* 0x3 reserved */
-#define DELMOD_NMI      0x4
-#define DELMOD_INIT     0x5
-#define DELMOD_STARTUP  0x6
-#define DELMOD_EXTINT   0x7
+#define DELMOD_NMI      0x4U
+#define DELMOD_INIT     0x5U
+#define DELMOD_STARTUP  0x6U
+#define DELMOD_EXTINT   0x7U
 
 /** Destination modes. */
-#define DESTMOD_PHYS   0x0
-#define DESTMOD_LOGIC  0x1
+#define DESTMOD_PHYS   0x0U
+#define DESTMOD_LOGIC  0x1U
 
 /** Trigger Modes. */
-#define TRIGMOD_EDGE   0x0
-#define TRIGMOD_LEVEL  0x1
+#define TRIGMOD_EDGE   0x0U
+#define TRIGMOD_LEVEL  0x1U
 
 /** Levels. */
-#define LEVEL_DEASSERT  0x0
-#define LEVEL_ASSERT    0x1
+#define LEVEL_DEASSERT  0x0U
+#define LEVEL_ASSERT    0x1U
 
 /** Destination Shorthands. */
-#define SHORTHAND_NONE      0x0
-#define SHORTHAND_SELF      0x1
-#define SHORTHAND_ALL_INCL  0x2
-#define SHORTHAND_ALL_EXCL  0x3
+#define SHORTHAND_NONE      0x0U
+#define SHORTHAND_SELF      0x1U
+#define SHORTHAND_ALL_INCL  0x2U
+#define SHORTHAND_ALL_EXCL  0x3U
 
 /** Interrupt Input Pin Polarities. */
-#define POLARITY_HIGH  0x0
-#define POLARITY_LOW   0x1
+#define POLARITY_HIGH  0x0U
+#define POLARITY_LOW   0x1U
 
 /** Divide Values. (Bit 2 is always 0) */
-#define DIVIDE_2    0x0
-#define DIVIDE_4    0x1
-#define DIVIDE_8    0x2
-#define DIVIDE_16   0x3
-#define DIVIDE_32   0x8
-#define DIVIDE_64   0x9
-#define DIVIDE_128  0xa
-#define DIVIDE_1    0xb
+#define DIVIDE_2    0x0U
+#define DIVIDE_4    0x1U
+#define DIVIDE_8    0x2U
+#define DIVIDE_16   0x3U
+#define DIVIDE_32   0x8U
+#define DIVIDE_64   0x9U
+#define DIVIDE_128  0xaU
+#define DIVIDE_1    0xbU
 
 /** Timer Modes. */
-#define TIMER_ONESHOT   0x0
-#define TIMER_PERIODIC  0x1
+#define TIMER_ONESHOT   0x0U
+#define TIMER_PERIODIC  0x1U
 
 /** Delivery status. */
-#define DELIVS_IDLE     0x0
-#define DELIVS_PENDING  0x1
+#define DELIVS_IDLE     0x0U
+#define DELIVS_PENDING  0x1U
 
 /** Destination masks. */
-#define DEST_ALL  0xff
+#define DEST_ALL  0xffU
 
 /** Dest format models. */
-#define MODEL_FLAT     0xf
-#define MODEL_CLUSTER  0x0
+#define MODEL_FLAT     0xfU
+#define MODEL_CLUSTER  0x0U
 
 /** Interrupt Command Register. */
-#define ICRlo  (0x300 / sizeof(uint32_t))
-#define ICRhi  (0x310 / sizeof(uint32_t))
+#define ICRlo  (0x300U / sizeof(uint32_t))
+#define ICRhi  (0x310U / sizeof(uint32_t))
 
 typedef struct {
@@ -135,8 +135,8 @@
 
 /* End Of Interrupt. */
-#define EOI  (0x0b0 / sizeof(uint32_t))
+#define EOI  (0x0b0U / sizeof(uint32_t))
 
 /** Error Status Register. */
-#define ESR  (0x280 / sizeof(uint32_t))
+#define ESR  (0x280U / sizeof(uint32_t))
 
 typedef union {
@@ -157,5 +157,5 @@
 
 /* Task Priority Register */
-#define TPR  (0x080 / sizeof(uint32_t))
+#define TPR  (0x080U / sizeof(uint32_t))
 
 typedef union {
@@ -168,5 +168,5 @@
 
 /** Spurious-Interrupt Vector Register. */
-#define SVR  (0x0f0 / sizeof(uint32_t))
+#define SVR  (0x0f0U / sizeof(uint32_t))
 
 typedef union {
@@ -181,5 +181,5 @@
 
 /** Time Divide Configuration Register. */
-#define TDCR  (0x3e0 / sizeof(uint32_t))
+#define TDCR  (0x3e0U / sizeof(uint32_t))
 
 typedef union {
@@ -192,11 +192,11 @@
 
 /* Initial Count Register for Timer */
-#define ICRT  (0x380 / sizeof(uint32_t))
+#define ICRT  (0x380U / sizeof(uint32_t))
 
 /* Current Count Register for Timer */
-#define CCRT  (0x390 / sizeof(uint32_t))
+#define CCRT  (0x390U / sizeof(uint32_t))
 
 /** LVT Timer register. */
-#define LVT_Tm  (0x320 / sizeof(uint32_t))
+#define LVT_Tm  (0x320U / sizeof(uint32_t))
 
 typedef union {
@@ -214,6 +214,6 @@
 
 /** LVT LINT registers. */
-#define LVT_LINT0  (0x350 / sizeof(uint32_t))
-#define LVT_LINT1  (0x360 / sizeof(uint32_t))
+#define LVT_LINT0  (0x350U / sizeof(uint32_t))
+#define LVT_LINT1  (0x360U / sizeof(uint32_t))
 
 typedef union {
@@ -233,5 +233,5 @@
 
 /** LVT Error register. */
-#define LVT_Err  (0x370 / sizeof(uint32_t))
+#define LVT_Err  (0x370U / sizeof(uint32_t))
 
 typedef union {
@@ -248,5 +248,5 @@
 
 /** Local APIC ID Register. */
-#define L_APIC_ID  (0x020 / sizeof(uint32_t))
+#define L_APIC_ID  (0x020U / sizeof(uint32_t))
 
 typedef union {
@@ -259,13 +259,13 @@
 
 /** Local APIC Version Register */
-#define LAVR       (0x030 / sizeof(uint32_t))
-#define LAVR_Mask  0xff
-
-#define is_local_apic(x)    (((x) & LAVR_Mask & 0xf0) == 0x1)
-#define is_82489DX_apic(x)  ((((x) & LAVR_Mask & 0xf0) == 0x0))
-#define is_local_xapic(x)   (((x) & LAVR_Mask) == 0x14)
+#define LAVR       (0x030U / sizeof(uint32_t))
+#define LAVR_Mask  0xffU
+
+#define is_local_apic(x)    (((x) & LAVR_Mask & 0xf0U) == 0x1U)
+#define is_82489DX_apic(x)  ((((x) & LAVR_Mask & 0xf0U) == 0x0U))
+#define is_local_xapic(x)   (((x) & LAVR_Mask) == 0x14U)
 
 /** Logical Destination Register. */
-#define  LDR  (0x0d0 / sizeof(uint32_t))
+#define  LDR  (0x0d0U / sizeof(uint32_t))
 
 typedef union {
@@ -278,5 +278,5 @@
 
 /** Destination Format Register. */
-#define DFR  (0x0e0 / sizeof(uint32_t))
+#define DFR  (0x0e0U / sizeof(uint32_t))
 
 typedef union {
@@ -289,11 +289,11 @@
 
 /* IO APIC */
-#define IOREGSEL  (0x00 / sizeof(uint32_t))
-#define IOWIN     (0x10 / sizeof(uint32_t))
-
-#define IOAPICID   0x00
-#define IOAPICVER  0x01
-#define IOAPICARB  0x02
-#define IOREDTBL   0x10
+#define IOREGSEL  (0x00U / sizeof(uint32_t))
+#define IOWIN     (0x10U / sizeof(uint32_t))
+
+#define IOAPICID   0x00U
+#define IOAPICVER  0x01U
+#define IOAPICARB  0x02U
+#define IOREDTBL   0x10U
 
 /** I/O Register Select Register. */
Index: kernel/arch/ia32/include/types.h
===================================================================
--- kernel/arch/ia32/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -50,24 +50,11 @@
 } fncptr_t;
 
-#define PRIp "x"  /**< Format for uintptr_t. */
-#define PRIs "u"  /**< Format for size_t. */
+#define INTN_C(c)   INT32_C(c)
+#define UINTN_C(c)  UINT32_C(c)
 
-#define PRId8 "d"     /**< Format for int8_t. */
-#define PRId16 "d"    /**< Format for int16_t. */
-#define PRId32 "d"    /**< Format for int32_t. */
-#define PRId64 "lld"  /**< Format for int64_t. */
-#define PRIdn "d"     /**< Format for native_t. */
-
-#define PRIu8 "u"     /**< Format for uint8_t. */
-#define PRIu16 "u"    /**< Format for uint16_t. */
-#define PRIu32 "u"    /**< Format for uint32_t. */
-#define PRIu64 "llu"  /**< Format for uint64_t. */
-#define PRIun "u"     /**< Format for unative_t. */
-
-#define PRIx8 "x"     /**< Format for hexadecimal (u)int8_t. */
-#define PRIx16 "x"    /**< Format for hexadecimal (u)int16_t. */
-#define PRIx32 "x"    /**< Format for hexadecimal (u)uint32_t. */
-#define PRIx64 "llx"  /**< Format for hexadecimal (u)int64_t. */
-#define PRIxn "x"     /**< Format for hexadecimal (u)native_t. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for unative_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/ia32/src/bios/bios.c
===================================================================
--- kernel/arch/ia32/src/bios/bios.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/bios/bios.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,5 +36,5 @@
 #include <typedefs.h>
 
-#define BIOS_EBDA_PTR  0x40e
+#define BIOS_EBDA_PTR  0x40eU
 
 uintptr_t ebda = 0;
@@ -43,5 +43,5 @@
 {
 	/* Copy the EBDA address out from BIOS Data Area */
-	ebda = *((uint16_t *) BIOS_EBDA_PTR) * 0x10;
+	ebda = *((uint16_t *) BIOS_EBDA_PTR) * 0x10U;
 }
 
Index: kernel/arch/ia32/src/boot/memmap.c
===================================================================
--- kernel/arch/ia32/src/boot/memmap.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/boot/memmap.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -35,5 +35,5 @@
 #include <arch/boot/memmap.h>
 
-uint8_t e820counter = 0xff;
+uint8_t e820counter = 0xffU;
 e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
 
Index: kernel/arch/ia32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ia32/src/cpu/cpu.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/cpu/cpu.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -49,11 +49,11 @@
  * Contains only non-MP-Specification specific SMP code.
  */
-#define AMD_CPUID_EBX  0x68747541
-#define AMD_CPUID_ECX  0x444d4163
-#define AMD_CPUID_EDX  0x69746e65
+#define AMD_CPUID_EBX  UINT32_C(0x68747541)
+#define AMD_CPUID_ECX  UINT32_C(0x444d4163)
+#define AMD_CPUID_EDX  UINT32_C(0x69746e65)
 
-#define INTEL_CPUID_EBX  0x756e6547
-#define INTEL_CPUID_ECX  0x6c65746e
-#define INTEL_CPUID_EDX  0x49656e69
+#define INTEL_CPUID_EBX  UINT32_C(0x756e6547)
+#define INTEL_CPUID_ECX  UINT32_C(0x6c65746e)
+#define INTEL_CPUID_EDX  UINT32_C(0x49656e69)
 
 
@@ -140,19 +140,19 @@
 		if ((info.cpuid_ebx == AMD_CPUID_EBX)
 		    && (info.cpuid_ecx == AMD_CPUID_ECX)
-			&& (info.cpuid_edx == AMD_CPUID_EDX))
+		    && (info.cpuid_edx == AMD_CPUID_EDX))
 			CPU->arch.vendor = VendorAMD;
 		
 		/*
 		 * Check for Intel processor.
-		 */		
+		 */
 		if ((info.cpuid_ebx == INTEL_CPUID_EBX)
 		    && (info.cpuid_ecx == INTEL_CPUID_ECX)
-			&& (info.cpuid_edx == INTEL_CPUID_EDX))
+		    && (info.cpuid_edx == INTEL_CPUID_EDX))
 			CPU->arch.vendor = VendorIntel;
 		
 		cpuid(INTEL_CPUID_STANDARD, &info);
-		CPU->arch.family = (info.cpuid_eax >> 8) & 0x0f;
-		CPU->arch.model = (info.cpuid_eax >> 4) & 0x0f;
-		CPU->arch.stepping = (info.cpuid_eax >> 0) & 0x0f;						
+		CPU->arch.family = (info.cpuid_eax >> 8) & 0x0fU;
+		CPU->arch.model = (info.cpuid_eax >> 4) & 0x0fU;
+		CPU->arch.stepping = (info.cpuid_eax >> 0) & 0x0fU;
 	}
 }
Index: kernel/arch/ia32/src/debug/stacktrace.c
===================================================================
--- kernel/arch/ia32/src/debug/stacktrace.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/debug/stacktrace.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,6 +37,6 @@
 #include <typedefs.h>
 
-#define FRAME_OFFSET_FP_PREV	0
-#define FRAME_OFFSET_RA		1
+#define FRAME_OFFSET_FP_PREV  0
+#define FRAME_OFFSET_RA       1
 
 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
Index: kernel/arch/ia32/src/drivers/i8254.c
===================================================================
--- kernel/arch/ia32/src/drivers/i8254.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/drivers/i8254.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -54,6 +54,6 @@
 #include <ddi/device.h>
 
-#define CLK_PORT1  ((ioport8_t *) 0x40)
-#define CLK_PORT4  ((ioport8_t *) 0x43)
+#define CLK_PORT1  ((ioport8_t *) 0x40U)
+#define CLK_PORT4  ((ioport8_t *) 0x43U)
 
 #define CLK_CONST     1193180
Index: kernel/arch/ia32/src/drivers/i8259.c
===================================================================
--- kernel/arch/ia32/src/drivers/i8259.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/drivers/i8259.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -121,6 +121,6 @@
 void pic_eoi(void)
 {
-	pio_write_8((ioport8_t *)0x20, 0x20);
-	pio_write_8((ioport8_t *)0xa0, 0x20);
+	pio_write_8((ioport8_t *) 0x20, 0x20);
+	pio_write_8((ioport8_t *) 0xa0, 0x20);
 }
 
Index: kernel/arch/ia32/src/drivers/vesa.c
===================================================================
--- kernel/arch/ia32/src/drivers/vesa.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/drivers/vesa.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -70,5 +70,5 @@
 bool vesa_init(void)
 {
-	if ((vesa_width == 0xffff) || (vesa_height == 0xffff))
+	if ((vesa_width == 0xffffU) || (vesa_height == 0xffffU))
 		return false;
 	
Index: kernel/arch/ia32/src/interrupt.c
===================================================================
--- kernel/arch/ia32/src/interrupt.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/interrupt.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -65,17 +65,25 @@
 void istate_decode(istate_t *istate)
 {
-	printf("cs =%p\teip=%p\tefl=%p\terr=%p\n",
-	    istate->cs, istate->eip, istate->eflags, istate->error_word);
-
-	printf("ds =%p\tes =%p\tfs =%p\tgs =%p\n",
+	printf("cs =%#0" PRIx32 "\teip=%p\t"
+	    "efl=%#0" PRIx32 "\terr=%#0" PRIx32 "\n",
+	    istate->cs, (void *) istate->eip,
+	    istate->eflags, istate->error_word);
+	
+	printf("ds =%#0" PRIx32 "\tes =%#0" PRIx32 "\t"
+	    "fs =%#0" PRIx32 "\tgs =%#0" PRIx32 "\n",
 	    istate->ds, istate->es, istate->fs, istate->gs);
+	
 	if (istate_from_uspace(istate))
-		printf("ss =%p\n", istate->ss);
-
-	printf("eax=%p\tebx=%p\tecx=%p\tedx=%p\n",
+		printf("ss =%#0" PRIx32 "\n", istate->ss);
+	
+	printf("eax=%#0" PRIx32 "\tebx=%#0" PRIx32 "\t"
+	    "ecx=%#0" PRIx32 "\tedx=%#0" PRIx32 "\n",
 	    istate->eax, istate->ebx, istate->ecx, istate->edx);
+	
 	printf("esi=%p\tedi=%p\tebp=%p\tesp=%p\n",
-	    istate->esi, istate->edi, istate->ebp,
-	    istate_from_uspace(istate) ? istate->esp : (uintptr_t)&istate->esp);
+	    (void *) istate->esi, (void *) istate->edi,
+	    (void *) istate->ebp,
+	    istate_from_uspace(istate) ? ((void *) istate->esp) :
+	    &istate->esp);
 }
 
@@ -139,7 +147,7 @@
 	);
 	
-	fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR=%#0.8x.",
-	    (unative_t) mxcsr);
-	panic_badtrap(istate, n, "SIMD FP exception, MXCSR=%#0.8x");
+	fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR=%#0" PRIx32 ".",
+	    mxcsr);
+	panic_badtrap(istate, n, "SIMD FP exception");
 }
 
Index: kernel/arch/ia32/src/mm/frame.c
===================================================================
--- kernel/arch/ia32/src/mm/frame.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/mm/frame.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -44,9 +44,8 @@
 #include <align.h>
 #include <macros.h>
-
 #include <print.h>
 
-#define PHYSMEM_LIMIT32  0x07c000000ull
-#define PHYSMEM_LIMIT64  0x200000000ull
+#define PHYSMEM_LIMIT32  UINT64_C(0x07c000000)
+#define PHYSMEM_LIMIT64  UINT64_C(0x200000000)
 
 size_t hardcoded_unmapped_ktext_size = 0;
Index: kernel/arch/ia32/src/mm/page.c
===================================================================
--- kernel/arch/ia32/src/mm/page.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/mm/page.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -82,5 +82,6 @@
 {
 	if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
-		panic("Unable to map physical memory %p (%d bytes).", physaddr, size);
+		panic("Unable to map physical memory %p (%zu bytes).",
+		    (void *) physaddr, size);
 	
 	uintptr_t virtaddr = PA2KA(last_frame);
Index: kernel/arch/ia32/src/smp/apic.c
===================================================================
--- kernel/arch/ia32/src/smp/apic.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/smp/apic.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -72,6 +72,6 @@
  *
  */
-volatile uint32_t *l_apic = (uint32_t *) 0xfee00000;
-volatile uint32_t *io_apic = (uint32_t *) 0xfec00000;
+volatile uint32_t *l_apic = (uint32_t *) UINT32_C(0xfee00000);
+volatile uint32_t *io_apic = (uint32_t *) UINT32_C(0xfec00000);
 
 uint32_t apic_id_mask = 0;
@@ -184,5 +184,5 @@
 	 * Other interrupts will be forwarded to the lowest priority CPU.
 	 */
-	io_apic_disable_irqs(0xffff);
+	io_apic_disable_irqs(0xffffU);
 	
 	irq_initialize(&l_apic_timer_irq);
@@ -477,5 +477,5 @@
 {
 #ifdef LAPIC_VERBOSE
-	printf("LVT on cpu%" PRIs ", LAPIC ID: %" PRIu8 "\n",
+	printf("LVT on cpu%u, LAPIC ID: %" PRIu8 "\n",
 	    CPU->id, l_apic_id());
 	
Index: kernel/arch/ia32/src/smp/mps.c
===================================================================
--- kernel/arch/ia32/src/smp/mps.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia32/src/smp/mps.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -52,6 +52,6 @@
  */
 
-#define FS_SIGNATURE  0x5f504d5f
-#define CT_SIGNATURE  0x504d4350
+#define FS_SIGNATURE  UINT32_C(0x5f504d5f)
+#define CT_SIGNATURE  UINT32_C(0x504d4350)
 
 static struct mps_fs *fs;
Index: kernel/arch/ia64/include/types.h
===================================================================
--- kernel/arch/ia64/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia64/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -52,24 +52,11 @@
 } __attribute__((may_alias)) fncptr_t;
 
-#define PRIp "lx"  /**< Format for uintptr_t. */
-#define PRIs "lu"  /**< Format for size_t. */
+#define INTN_C(c)   INT64_C(c)
+#define UINTN_C(c)  UINT64_C(c)
 
-#define PRId8 "d"    /**< Format for int8_t. */
-#define PRId16 "d"   /**< Format for int16_t. */
-#define PRId32 "d"   /**< Format for int32_t. */
-#define PRId64 "ld"  /**< Format for int64_t. */
-#define PRIdn "d"    /**< Format for native_t. */
-
-#define PRIu8 "u"    /**< Format for uint8_t. */
-#define PRIu16 "u"   /**< Format for uint16_t. */
-#define PRIu32 "u"   /**< Format for uint32_t. */
-#define PRIu64 "lu"  /**< Format for uint64_t. */
-#define PRIun "u"    /**< Format for unative_t. */
-
-#define PRIx8 "x"    /**< Format for hexadecimal (u)int8_t. */
-#define PRIx16 "x"   /**< Format for hexadecimal (u)int16_t. */
-#define PRIx32 "x"   /**< Format for hexadecimal (u)uint32_t. */
-#define PRIx64 "lx"  /**< Format for hexadecimal (u)int64_t. */
-#define PRIxn "x"    /**< Format for hexadecimal (u)native_t. */
+#define PRIdn  PRId64  /**< Format for native_t. */
+#define PRIun  PRIu64  /**< Format for unative_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/ia64/src/interrupt.c
===================================================================
--- kernel/arch/ia64/src/interrupt.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia64/src/interrupt.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -135,18 +135,19 @@
 void istate_decode(istate_t *istate)
 {
-	printf("ar.bsp=%p\tar.bspstore=%p\n", istate->ar_bsp,
-	    istate->ar_bspstore);
-	printf("ar.rnat=%#018llx\tar.rsc=%#018llx\n", istate->ar_rnat,
-	    istate->ar_rsc);
-	printf("ar.ifs=%#018llx\tar.pfs=%#018llx\n", istate->ar_ifs,
-	    istate->ar_pfs);
-	printf("cr.isr=%#018llx\tcr.ipsr=%#018llx\t\n", istate->cr_isr.value,
-	    istate->cr_ipsr);
-	
-	printf("cr.iip=%#018llx, #%d\t(%s)\n", istate->cr_iip, istate->cr_isr.ei,
+	printf("ar.bsp=%p\tar.bspstore=%p\n",
+	    (void *) istate->ar_bsp, (void *) istate->ar_bspstore);
+	printf("ar.rnat=%#0" PRIx64 "\tar.rsc=%#0" PRIx64 "\n",
+	    istate->ar_rnat, istate->ar_rsc);
+	printf("ar.ifs=%#0" PRIx64 "\tar.pfs=%#0" PRIx64 "\n",
+	    istate->ar_ifs, istate->ar_pfs);
+	printf("cr.isr=%#0" PRIx64 "\tcr.ipsr=%#0" PRIx64 "\n",
+	    istate->cr_isr.value, istate->cr_ipsr.value);
+	
+	printf("cr.iip=%#0" PRIx64 ", #%u\t(%s)\n",
+	    istate->cr_iip, istate->cr_isr.ei,
 	    symtab_fmt_name_lookup(istate->cr_iip));
-	printf("cr.iipa=%#018llx\t(%s)\n", istate->cr_iipa,
+	printf("cr.iipa=%#0" PRIx64 "\t(%s)\n", istate->cr_iipa,
 	    symtab_fmt_name_lookup(istate->cr_iipa));
-	printf("cr.ifa=%#018llx\t(%s)\n", istate->cr_ifa,
+	printf("cr.ifa=%#0" PRIx64 "\t(%s)\n", istate->cr_ifa,
 	    symtab_fmt_name_lookup(istate->cr_ifa));
 }
Index: kernel/arch/ia64/src/mm/tlb.c
===================================================================
--- kernel/arch/ia64/src/mm/tlb.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ia64/src/mm/tlb.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -499,5 +499,6 @@
 		page_table_unlock(AS, true);
 		if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
-			fault_if_from_uspace(istate, "Page fault at %p.", va);
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
 			panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
 		}
@@ -556,5 +557,5 @@
 			} else {
 				fault_if_from_uspace(istate,
-				    "IO access fault at %p.", va);
+				    "IO access fault at %p.", (void *) va);
 			}
 		}
@@ -620,5 +621,6 @@
 		 */
 		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
-			fault_if_from_uspace(istate, "Page fault at %p.", va);
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
 			panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
 		}
@@ -668,5 +670,6 @@
 	} else {
 		if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
-			fault_if_from_uspace(istate, "Page fault at %p.", va);
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
 			panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
 		}
@@ -704,5 +707,6 @@
 	} else {
 		if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
-			fault_if_from_uspace(istate, "Page fault at %p.", va);
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
 			panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
 		}
@@ -740,5 +744,6 @@
 	} else {
 		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
-			fault_if_from_uspace(istate, "Page fault at %p.", va);
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
 			panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
 		}
@@ -772,5 +777,6 @@
 	ASSERT(!t->w);
 	if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
-		fault_if_from_uspace(istate, "Page fault at %p.", va);
+		fault_if_from_uspace(istate, "Page fault at %p.",
+		    (void *) va);
 		panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
 	}
@@ -812,5 +818,6 @@
 		page_table_unlock(AS, true);
 		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
-			fault_if_from_uspace(istate, "Page fault at %p.", va);
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
 			panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
 		}
Index: kernel/arch/mips32/include/types.h
===================================================================
--- kernel/arch/mips32/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/mips32/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -50,24 +50,11 @@
 } fncptr_t;
 
-#define PRIp "x"  /**< Format for uintptr_t. */
-#define PRIs "u"  /**< Format for size_t. */
+#define INTN_C(c)   INT32_C(c)
+#define UINTN_C(c)  UINT32_C(c)
 
-#define PRId8 "d"     /**< Format for int8_t. */
-#define PRId16 "d"    /**< Format for int16_t. */
-#define PRId32 "ld"   /**< Format for int32_t. */
-#define PRId64 "lld"  /**< Format for int64_t. */
-#define PRIdn "d"     /**< Format for native_t. */
-
-#define PRIu8 "u"     /**< Format for uint8_t. */
-#define PRIu16 "u"    /**< Format for uint16_t. */
-#define PRIu32 "u"    /**< Format for uint32_t. */
-#define PRIu64 "llu"  /**< Format for uint64_t. */
-#define PRIun "u"     /**< Format for unative_t. */
-
-#define PRIx8 "x"     /**< Format for hexadecimal (u)int8_t. */
-#define PRIx16 "x"    /**< Format for hexadecimal (u)int16_t. */
-#define PRIx32 "x"    /**< Format for hexadecimal (u)uint32_t. */
-#define PRIx64 "llx"  /**< Format for hexadecimal (u)int64_t. */
-#define PRIxn "x"     /**< Format for hexadecimal (u)native_t. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for unative_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/mips32/src/cache.c
===================================================================
--- kernel/arch/mips32/src/cache.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/mips32/src/cache.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -39,5 +39,5 @@
 void cache_error(istate_t *istate)
 {
-	panic("cache_error exception (epc=%p).", istate->epc);
+	panic("cache_error exception (epc=%p).", (void *) istate->epc);
 }
 
Index: kernel/arch/mips32/src/debugger.c
===================================================================
--- kernel/arch/mips32/src/debugger.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/mips32/src/debugger.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -191,5 +191,5 @@
 	}
 	
-	printf("Adding breakpoint on address %p\n", argv->intval);
+	printf("Adding breakpoint on address %p\n", (void *) argv->intval);
 	
 	cur->address = (uintptr_t) argv->intval;
@@ -267,6 +267,6 @@
 			    breakpoints[i].address);
 			
-			printf("%-4u %7" PRIs " %p %-8s %-9s %-10s %s\n", i,
-			    breakpoints[i].counter, breakpoints[i].address,
+			printf("%-4u %7zu %p %-8s %-9s %-10s %s\n", i,
+			    breakpoints[i].counter, (void *) breakpoints[i].address,
 			    ((breakpoints[i].flags & BKPOINT_INPROG) ? "true" :
 			    "false"), ((breakpoints[i].flags & BKPOINT_ONESHOT)
@@ -366,5 +366,6 @@
 		
 		if (!(cur->flags & BKPOINT_FUNCCALL)) {
-			printf("***Breakpoint %u: %p in %s.\n", i, fireaddr,
+			printf("***Breakpoint %u: %p in %s.\n", i,
+			    (void *) fireaddr,
 			    symtab_fmt_name_lookup(fireaddr));
 		}
@@ -381,5 +382,6 @@
 		cur->flags |= BKPOINT_INPROG;
 	} else {
-		printf("***Breakpoint %d: %p in %s.\n", i, fireaddr,
+		printf("***Breakpoint %d: %p in %s.\n", i,
+		    (void *) fireaddr,
 		    symtab_fmt_name_lookup(fireaddr));
 		
Index: kernel/arch/mips32/src/exception.c
===================================================================
--- kernel/arch/mips32/src/exception.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/mips32/src/exception.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -74,22 +74,40 @@
 void istate_decode(istate_t *istate)
 {
-	printf("epc=%p\tsta=%p\tlo =%p\thi =%p\n",
-	    istate->epc, istate->status, istate->lo, istate->hi);
-	printf("a0 =%p\ta1 =%p\ta2 =%p\ta3 =%p\n",
+	printf("epc=%p\tsta=%#0" PRIx32 "\t"
+	    "lo =%#0" PRIx32 "\thi =%#0" PRIx32 "\n",
+	    (void *) istate->epc, istate->status,
+	    istate->lo, istate->hi);
+	
+	printf("a0 =%#0" PRIx32 "\ta1 =%#0" PRIx32 "\t"
+	    "a2 =%#0" PRIx32 "\ta3 =%#0" PRIx32 "\n",
 	    istate->a0, istate->a1, istate->a2, istate->a3);
-	printf("t0 =%p\tt1 =%p\tt2 =%p\tt3 =%p\n",
+	
+	printf("t0 =%#0" PRIx32 "\tt1 =%#0" PRIx32 "\t"
+	    "t2 =%#0" PRIx32 "\tt3 =%#0" PRIx32 "\n",
 	    istate->t0, istate->t1, istate->t2, istate->t3);
-	printf("t4 =%p\tt5 =%p\tt6 =%p\tt7 =%p\n",
+	
+	printf("t4 =%#0" PRIx32 "\tt5 =%#0" PRIx32 "\t"
+	    "t6 =%#0" PRIx32 "\tt7 =%#0" PRIx32 "\n",
 	    istate->t4, istate->t5, istate->t6, istate->t7);
-	printf("t8 =%p\tt9 =%p\tv0 =%p\tv1 =%p\n",
+	
+	printf("t8 =%#0" PRIx32 "\tt9 =%#0" PRIx32 "\t"
+	    "v0 =%#0" PRIx32 "\tv1 =%#0" PRIx32 "\n",
 	    istate->t8, istate->t9, istate->v0, istate->v1);
-	printf("s0 =%p\ts1 =%p\ts2 =%p\ts3 =%p\n",
+	
+	printf("s0 =%#0" PRIx32 "\ts1 =%#0" PRIx32 "\t"
+	    "s2 =%#0" PRIx32 "\ts3 =%#0" PRIx32 "\n",
 	    istate->s0, istate->s1, istate->s2, istate->s3);
-	printf("s4 =%p\ts5 =%p\ts6 =%p\ts7 =%p\n",
+	
+	printf("s4 =%#0" PRIx32 "\ts5 =%#0" PRIx32 "\t"
+	    "s6 =%#0" PRIx32 "\ts7 =%#0" PRIx32 "\n",
 	    istate->s4, istate->s5, istate->s6, istate->s7);
-	printf("s8 =%p\tat =%p\tkt0=%p\tkt1=%p\n",
+	
+	printf("s8 =%#0" PRIx32 "\tat =%#0" PRIx32 "\t"
+	    "kt0=%#0" PRIx32 "\tkt1=%#0" PRIx32 "\n",
 	    istate->s8, istate->at, istate->kt0, istate->kt1);
+	
 	printf("sp =%p\tra =%p\tgp =%p\n",
-	    istate->sp, istate->ra, istate->gp);
+	    (void *) istate->sp, (void *) istate->ra,
+	    (void *) istate->gp);
 }
 
Index: kernel/arch/mips32/src/mm/tlb.c
===================================================================
--- kernel/arch/mips32/src/mm/tlb.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/mips32/src/mm/tlb.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -323,5 +323,6 @@
 	uintptr_t va = cp0_badvaddr_read();
 	
-	fault_if_from_uspace(istate, "TLB Refill Exception on %p.", va);
+	fault_if_from_uspace(istate, "TLB Refill Exception on %p.",
+	    (void *) va);
 	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Refill Exception.");
 }
@@ -332,5 +333,6 @@
 	uintptr_t va = cp0_badvaddr_read();
 	
-	fault_if_from_uspace(istate, "TLB Invalid Exception on %p.", va);
+	fault_if_from_uspace(istate, "TLB Invalid Exception on %p.",
+	    (void *) va);
 	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Invalid Exception.");
 }
@@ -340,5 +342,6 @@
 	uintptr_t va = cp0_badvaddr_read();
 	
-	fault_if_from_uspace(istate, "TLB Modified Exception on %p.", va);
+	fault_if_from_uspace(istate, "TLB Modified Exception on %p.",
+	    (void *) va);
 	panic_memtrap(istate, PF_ACCESS_WRITE, va, "TLB Modified Exception.");
 }
Index: kernel/arch/ppc32/include/types.h
===================================================================
--- kernel/arch/ppc32/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ppc32/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -50,26 +50,11 @@
 } fncptr_t;
 
-/** Formats for uintptr_t, size_t */
-#define PRIp  "x"
-#define PRIs  "u"
+#define INTN_C(c)   INT32_C(c)
+#define UINTN_C(c)  UINT32_C(c)
 
-/** Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */
-#define PRId8   "d"
-#define PRId16  "d"
-#define PRId32  "d"
-#define PRId64  "lld"
-#define PRIdn   "d"
-
-#define PRIu8   "u"
-#define PRIu16  "u"
-#define PRIu32  "u"
-#define PRIu64  "llu"
-#define PRIun   "u"
-
-#define PRIx8   "x"
-#define PRIx16  "x"
-#define PRIx32  "x"
-#define PRIx64  "llx"
-#define PRIxn   "x"
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for unative_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/ppc32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ppc32/src/cpu/cpu.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ppc32/src/cpu/cpu.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -68,5 +68,5 @@
 	}
 	
-	printf("cpu%" PRIs ": version=%" PRIu16" (%s), revision=%" PRIu16 "\n", cpu->id,
+	printf("cpu%u: version=%" PRIu16" (%s), revision=%" PRIu16 "\n", cpu->id,
 	    cpu->arch.version, name, cpu->arch.revision);
 }
Index: kernel/arch/ppc32/src/interrupt.c
===================================================================
--- kernel/arch/ppc32/src/interrupt.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ppc32/src/interrupt.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -54,26 +54,44 @@
 void istate_decode(istate_t *istate)
 {
-	printf("r0 =%p\tr1 =%p\tr2 =%p\n", istate->r0, istate->sp, istate->r2);
-	printf("r3 =%p\tr4 =%p\tr5 =%p\n", istate->r3, istate->r4, istate->r5);
-	printf("r6 =%p\tr7 =%p\tr8 =%p\n", istate->r6, istate->r7, istate->r8);
-	printf("r9 =%p\tr10=%p\tr11=%p\n",
+	printf("r0 =%#0" PRIx32 "\tr1 =%p\tr2 =%#0" PRIx32 "\n",
+	    istate->r0, (void *) istate->sp, istate->r2);
+	
+	printf("r3 =%#0" PRIx32 "\tr4 =%#0" PRIx32 "\tr5 =%#0" PRIx32 "\n",
+	    istate->r3, istate->r4, istate->r5);
+	
+	printf("r6 =%#0" PRIx32 "\tr7 =%#0" PRIx32 "\tr8 =%#0" PRIx32 "\n",
+	    istate->r6, istate->r7, istate->r8);
+	
+	printf("r9 =%#0" PRIx32 "\tr10=%#0" PRIx32 "\tr11=%#0" PRIx32 "\n",
 	    istate->r9, istate->r10, istate->r11);
-	printf("r12=%p\tr13=%p\tr14=%p\n",
+	
+	printf("r12=%#0" PRIx32 "\tr13=%#0" PRIx32 "\tr14=%#0" PRIx32 "\n",
 	    istate->r12, istate->r13, istate->r14);
-	printf("r15=%p\tr16=%p\tr17=%p\n",
+	
+	printf("r15=%#0" PRIx32 "\tr16=%#0" PRIx32 "\tr17=%#0" PRIx32 "\n",
 	    istate->r15, istate->r16, istate->r17);
-	printf("r18=%p\tr19=%p\tr20=%p\n",
+	
+	printf("r18=%#0" PRIx32 "\tr19=%#0" PRIx32 "\tr20=%#0" PRIx32 "\n",
 	    istate->r18, istate->r19, istate->r20);
-	printf("r21=%p\tr22=%p\tr23=%p\n",
+	
+	printf("r21=%#0" PRIx32 "\tr22=%#0" PRIx32 "\tr23=%#0" PRIx32 "\n",
 	    istate->r21, istate->r22, istate->r23);
-	printf("r24=%p\tr25=%p\tr26=%p\n",
+	
+	printf("r24=%#0" PRIx32 "\tr25=%#0" PRIx32 "\tr26=%#0" PRIx32 "\n",
 	    istate->r24, istate->r25, istate->r26);
-	printf("r27=%p\tr28=%p\tr29=%p\n",
+	
+	printf("r27=%#0" PRIx32 "\tr28=%#0" PRIx32 "\tr29=%#0" PRIx32 "\n",
 	    istate->r27, istate->r28, istate->r29);
-	printf("r30=%p\tr31=%p\n", istate->r30, istate->r31);
-	printf("cr =%p\tpc =%p\tlr =%p\n", istate->cr, istate->pc, istate->lr);
-	printf("ctr=%p\txer=%p\tdar=%p\n",
+	
+	printf("r30=%#0" PRIx32 "\tr31=%#0" PRIx32 "\n",
+	    istate->r30, istate->r31);
+	
+	printf("cr =%#0" PRIx32 "\tpc =%p\tlr =%p\n",
+	    istate->cr, (void *) istate->pc, (void *) istate->lr);
+	
+	printf("ctr=%#0" PRIx32 "\txer=%#0" PRIx32 "\tdar=%#0" PRIx32 "\n",
 	    istate->ctr, istate->xer, istate->dar);
-	printf("srr1=%p\n", istate->srr1);
+	
+	printf("srr1=%p\n", (void *) istate->srr1);
 }
 
@@ -111,5 +129,5 @@
 			 */
 #ifdef CONFIG_DEBUG
-			printf("cpu%" PRIs ": spurious interrupt (inum=%" PRIu8 ")\n",
+			printf("cpu%u: spurious interrupt (inum=%" PRIu8 ")\n",
 			    CPU->id, inum);
 #endif
Index: kernel/arch/ppc32/src/mm/frame.c
===================================================================
--- kernel/arch/ppc32/src/mm/frame.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ppc32/src/mm/frame.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -49,5 +49,5 @@
 	size_t i;
 	for (i = 0; i < memmap.cnt; i++) {
-		printf("%#10x %#10x\n", memmap.zones[i].start,
+		printf("%p %#0zx\n", memmap.zones[i].start,
 		    memmap.zones[i].size);
 	}
Index: kernel/arch/ppc32/src/mm/page.c
===================================================================
--- kernel/arch/ppc32/src/mm/page.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ppc32/src/mm/page.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -49,6 +49,6 @@
 	if (last_frame + ALIGN_UP(size, PAGE_SIZE) >
 	    KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
-		panic("Unable to map physical memory %p (%" PRIs " bytes).",
-		    physaddr, size);
+		panic("Unable to map physical memory %p (%zu bytes).",
+		    (void *) physaddr, size);
 	
 	uintptr_t virtaddr = PA2KA(last_frame);
Index: kernel/arch/ppc32/src/mm/tlb.c
===================================================================
--- kernel/arch/ppc32/src/mm/tlb.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/ppc32/src/mm/tlb.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -111,5 +111,6 @@
 static void pht_refill_fail(uintptr_t badvaddr, istate_t *istate)
 {
-	fault_if_from_uspace(istate, "PHT Refill Exception on %p.", badvaddr);
+	fault_if_from_uspace(istate, "PHT Refill Exception on %p.",
+	    (void *) badvaddr);
 	panic_memtrap(istate, PF_ACCESS_UNKNOWN, badvaddr,
 	    "PHT Refill Exception.");
@@ -459,11 +460,11 @@
 		length = 0; \
 	\
-	printf(name ": page=%.*p frame=%.*p length=%d KB (mask=%#x)%s%s\n", \
-	    sizeof(upper) * 2, upper & 0xffff0000, sizeof(lower) * 2, \
-	    lower & 0xffff0000, length, mask, \
+	printf(name ": page=%#0" PRIx32 " frame=%#0" PRIx32 \
+	    " length=%#0" PRIx32 " KB (mask=%#0" PRIx32 ")%s%s\n", \
+	    upper & UINT32_C(0xffff0000), lower & UINT32_C(0xffff0000), \
+	    length, mask, \
 	    ((upper >> 1) & 1) ? " supervisor" : "", \
 	    (upper & 1) ? " user" : "");
 
-
 void tlb_print(void)
 {
@@ -473,6 +474,7 @@
 		uint32_t vsid = sr_get(sr << 28);
 		
-		printf("sr[%02u]: vsid=%.*p (asid=%u)%s%s\n", sr,
-		    sizeof(vsid) * 2, vsid & 0xffffff, (vsid & 0xffffff) >> 4,
+		printf("sr[%02" PRIu32 "]: vsid=%#0" PRIx32 " (asid=%" PRIu32 ")"
+		    "%s%s\n", sr, vsid & UINT32_C(0x00ffffff),
+		    (vsid & UINT32_C(0x00ffffff)) >> 4,
 		    ((vsid >> 30) & 1) ? " supervisor" : "",
 		    ((vsid >> 29) & 1) ? " user" : "");
Index: kernel/arch/sparc64/include/types.h
===================================================================
--- kernel/arch/sparc64/include/types.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/include/types.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -52,26 +52,11 @@
 typedef uint8_t asi_t;
 
-/** Formats for uintptr_t, size_t */
-#define PRIp  "llx"
-#define PRIs  "llu"
+#define INTN_C(c)   INT64_C(c)
+#define UINTN_C(c)  UINT64_C(c)
 
-/** Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */
-#define PRId8   "d"
-#define PRId16  "d"
-#define PRId32  "d"
-#define PRId64  "lld"
-#define PRIdn   "lld"
-
-#define PRIu8   "u"
-#define PRIu16  "u"
-#define PRIu32  "u"
-#define PRIu64  "llu"
-#define PRIun   "llu"
-
-#define PRIx8   "x"
-#define PRIx16  "x"
-#define PRIx32  "x"
-#define PRIx64  "llx"
-#define PRIxn   "llx"
+#define PRIdn  PRId64  /**< Format for native_t. */
+#define PRIun  PRIu64  /**< Format for unative_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal unative_t. */
+#define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
 #endif
Index: kernel/arch/sparc64/src/console.c
===================================================================
--- kernel/arch/sparc64/src/console.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/src/console.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -70,5 +70,5 @@
 	ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value);
 	if (!screen)
-		panic("Cannot find %s.", prop_scr->value);
+		panic("Cannot find %s.", (char *) prop_scr->value);
 	
 	scr_init(screen);
@@ -83,5 +83,5 @@
 	ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value);
 	if (!keyboard)
-		panic("Cannot find %s.", prop_kbd->value);
+		panic("Cannot find %s.", (char *) prop_kbd->value);
 	
 	kbd_init(keyboard);
Index: kernel/arch/sparc64/src/drivers/pci.c
===================================================================
--- kernel/arch/sparc64/src/drivers/pci.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/src/drivers/pci.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -211,5 +211,6 @@
 		 * Unsupported model.
 		 */
-		printf("Unsupported PCI controller model (%s).\n", prop->value);
+		printf("Unsupported PCI controller model (%s).\n",
+		    (char *) prop->value);
 	}
 
Index: kernel/arch/sparc64/src/mm/sun4u/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -360,7 +360,7 @@
 static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
 {
-	printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
-	    "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
-	    "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn,
+	printf("%u: vpn=%#" PRIx64 ", context=%u, v=%u, size=%u, nfo=%u, "
+	    "ie=%u, soft2=%#x, pfn=%#x, soft=%#x, l=%u, "
+	    "cp=%u, cv=%u, e=%u, p=%u, w=%u, g=%u\n", i, (uint64_t) t.vpn,
 	    t.context, d.v, d.size, d.nfo, d.ie, d.soft2,
 	    d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
@@ -441,5 +441,5 @@
     uintptr_t va, const char *str)
 {
-	fault_if_from_uspace(istate, "%s, Address=%p.", str, va);
+	fault_if_from_uspace(istate, "%s, address=%p.", str, (void *) va);
 	panic_memtrap(istate, PF_ACCESS_EXEC, va, str);
 }
@@ -451,6 +451,6 @@
 
 	va = tag.vpn << MMU_PAGE_WIDTH;
-	fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va,
-	    tag.context);
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str,
+	    (void *) va, tag.context);
 	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, str);
 }
@@ -462,6 +462,6 @@
 
 	va = tag.vpn << MMU_PAGE_WIDTH;
-	fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va,
-	    tag.context);
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str,
+	    (void *) va, tag.context);
 	panic_memtrap(istate, PF_ACCESS_WRITE, va, str);
 }
@@ -484,6 +484,6 @@
 	    sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
 #endif
-	    
-	printf("DTLB SFAR: address=%p\n", sfar);
+	
+	printf("DTLB SFAR: address=%p\n", (void *) sfar);
 	
 	dtlb_sfsr_write(0);
@@ -508,5 +508,5 @@
 #endif
 	    
-	printf("DTLB SFAR: address=%p\n", sfar);
+	printf("DTLB SFAR: address=%p\n", (void *) sfar);
 	
 	dtlb_sfsr_write(0);
Index: kernel/arch/sparc64/src/mm/sun4v/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -358,5 +358,6 @@
     const char *str)
 {
-	fault_if_from_uspace(istate, "%s, Address=%p.", str, va);
+	fault_if_from_uspace(istate, "%s, address=%p.", str,
+	    (void *) va);
 	panic_memtrap(istate, PF_ACCESS_EXEC, va, str);
 }
@@ -365,6 +366,6 @@
     uint64_t page_and_ctx, const char *str)
 {
-	fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str,
-	    DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx));
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%" PRId64 ").", str,
+	    (void *) DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx));
 	panic_memtrap(istate, PF_ACCESS_UNKNOWN, DMISS_ADDRESS(page_and_ctx),
 	    str);
@@ -374,6 +375,6 @@
     uint64_t page_and_ctx, const char *str)
 {
-	fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str,
-	    DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx));
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%" PRId64 ").", str,
+	    (void *) DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx));
 	panic_memtrap(istate, PF_ACCESS_WRITE, DMISS_ADDRESS(page_and_ctx),
 	    str);
@@ -399,7 +400,6 @@
 	uint64_t errno =  __hypercall_fast3(MMU_DEMAP_ALL, 0, 0,
 		MMU_FLAG_DTLB | MMU_FLAG_ITLB);
-	if (errno != HV_EOK) {
-		panic("Error code = %d.\n", errno);
-	}
+	if (errno != HV_EOK)
+		panic("Error code = %" PRIu64 ".\n", errno);
 }
 
Index: kernel/arch/sparc64/src/sun4v/md.c
===================================================================
--- kernel/arch/sparc64/src/sun4v/md.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/src/sun4v/md.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -310,6 +310,6 @@
 	retval = retval;
 	if (retval != HV_EOK) {
-		printf("Could not retrieve machine description, error = %d.\n",
-		    retval);
+		printf("Could not retrieve machine description, "
+		    "error=%" PRIu64 ".\n", retval);
 	}
 }
Index: kernel/arch/sparc64/src/trap/sun4v/interrupt.c
===================================================================
--- kernel/arch/sparc64/src/trap/sun4v/interrupt.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/arch/sparc64/src/trap/sun4v/interrupt.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -87,5 +87,5 @@
 		KA2PA(cpu_mondo_queues[CPU->id]),
 		CPU_MONDO_NENTRIES) != HV_EOK)
-			panic("Initializing mondo queue failed on CPU %d.\n",
+			panic("Initializing mondo queue failed on CPU %" PRIu64 ".\n",
 			    CPU->arch.id);
 }
Index: kernel/generic/include/config.h
===================================================================
--- kernel/generic/include/config.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/config.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -66,5 +66,5 @@
 
 typedef struct {
-	size_t cpu_count;            /**< Number of processors detected. */
+	unsigned int cpu_count;      /**< Number of processors detected. */
 	volatile size_t cpu_active;  /**< Number of processors that are up and running. */
 	
Index: kernel/generic/include/cpu.h
===================================================================
--- kernel/generic/include/cpu.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/cpu.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -83,5 +83,5 @@
 	 * Processor ID assigned by kernel.
 	 */
-	size_t id;
+	unsigned int id;
 	
 	bool active;
Index: kernel/generic/include/interrupt.h
===================================================================
--- kernel/generic/include/interrupt.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/interrupt.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,4 +37,5 @@
 
 #include <arch/interrupt.h>
+#include <print.h>
 #include <typedefs.h>
 #include <proc/task.h>
@@ -57,5 +58,6 @@
 extern exc_table_t exc_table[];
 
-extern void fault_if_from_uspace(istate_t *, const char *, ...);
+extern void fault_if_from_uspace(istate_t *, const char *, ...)
+    PRINTF_ATTRIBUTE(2, 3);
 extern iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t);
 extern void exc_dispatch(unsigned int, istate_t *);
Index: kernel/generic/include/macros.h
===================================================================
--- kernel/generic/include/macros.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/macros.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -104,10 +104,10 @@
 #define STRING_ARG(arg)  #arg
 
-#define LOWER32(arg)  (((uint64_t) (arg)) & 0xffffffff)
-#define UPPER32(arg)  (((((uint64_t) arg)) >> 32) & 0xffffffff)
+#define LOWER32(arg)  (((uint64_t) (arg)) & UINT32_C(0xffffffff))
+#define UPPER32(arg)  (((((uint64_t) arg)) >> 32) & UINT32_C(0xffffffff))
 
 #define MERGE_LOUP32(lo, up) \
-	((((uint64_t) (lo)) & 0xffffffff) \
-	    | ((((uint64_t) (up)) & 0xffffffff) << 32))
+	((((uint64_t) (lo)) & UINT32_C(0xffffffff)) \
+	    | ((((uint64_t) (up)) & UINT32_C(0xffffffff)) << 32))
 
 /** Pseudorandom generator
Index: kernel/generic/include/mm/slab.h
===================================================================
--- kernel/generic/include/mm/slab.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/mm/slab.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -126,5 +126,6 @@
 extern void slab_cache_destroy(slab_cache_t *);
 
-extern void * slab_alloc(slab_cache_t *, unsigned int);
+extern void *slab_alloc(slab_cache_t *, unsigned int)
+    __attribute__((malloc));
 extern void slab_free(slab_cache_t *, void *);
 extern size_t slab_reclaim(unsigned int);
@@ -138,5 +139,6 @@
 
 /* malloc support */
-extern void *malloc(size_t, unsigned int);
+extern void *malloc(size_t, unsigned int)
+    __attribute__((malloc));
 extern void *realloc(void *, size_t, unsigned int);
 extern void free(void *);
Index: kernel/generic/include/panic.h
===================================================================
--- kernel/generic/include/panic.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/panic.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -37,4 +37,5 @@
 
 #include <typedefs.h>
+#include <print.h>
 
 #define panic(fmt, ...) \
@@ -62,5 +63,6 @@
 
 extern void panic_common(panic_category_t, struct istate *, int,
-    uintptr_t, const char *, ...) __attribute__ ((noreturn));
+    uintptr_t, const char *, ...) __attribute__ ((noreturn))
+    PRINTF_ATTRIBUTE(5, 6);
 
 #endif
Index: kernel/generic/include/print.h
===================================================================
--- kernel/generic/include/print.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/print.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -39,9 +39,22 @@
 #include <stdarg.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)
 
 extern int puts(const char *s);
-extern int printf(const char *fmt, ...);
-extern int snprintf(char *str, size_t size, const char *fmt, ...);
+extern int printf(const char *fmt, ...)
+    PRINTF_ATTRIBUTE(1, 2);
+extern int snprintf(char *str, size_t size, const char *fmt, ...)
+    PRINTF_ATTRIBUTE(3, 4);
 
 extern int vprintf(const char *fmt, va_list ap);
Index: kernel/generic/include/stdint.h
===================================================================
--- kernel/generic/include/stdint.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/stdint.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -36,27 +36,27 @@
 #define KERN_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)
 
 #endif
Index: kernel/generic/include/synch/spinlock.h
===================================================================
--- kernel/generic/include/synch/spinlock.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/synch/spinlock.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -146,5 +146,5 @@
 	if ((pname)++ > (value)) { \
 		(pname) = 0; \
-		printf("Deadlock probe %s: exceeded threshold %u\n", \
+		printf("Deadlock probe %s: exceeded threshold %u\n" \
 		    "cpu%u: function=%s, line=%u\n", \
 		    #pname, (value), CPU->id, __func__, __LINE__); \
Index: kernel/generic/include/sysinfo/abi.h
===================================================================
--- kernel/generic/include/sysinfo/abi.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/sysinfo/abi.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -66,5 +66,5 @@
  */
 typedef struct {
-	size_t id;               /**< CPU ID as stored by kernel */
+	unsigned int id;         /**< CPU ID as stored by kernel */
 	bool active;             /**< CPU is activate */
 	uint16_t frequency_mhz;  /**< Frequency in MHz */
Index: kernel/generic/include/typedefs.h
===================================================================
--- kernel/generic/include/typedefs.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/include/typedefs.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -40,5 +40,5 @@
 #include <arch/types.h>
 
-#define NULL	((void *) 0)
+#define NULL  ((void *) 0)
 
 #define false  0
@@ -69,6 +69,4 @@
 typedef int32_t devno_t;
 
-typedef int32_t wchar_t;
-
 typedef volatile uint8_t ioport8_t;
 typedef volatile uint16_t ioport16_t;
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/console/cmd.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -554,4 +554,10 @@
 	}
 	
+	unsigned int _len = (unsigned int) len;
+	if ((_len != len) || (((int) _len) < 0)) {
+		printf("Command length overflow\n");
+		return 1;
+	}
+	
 	for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
 		cmd_info_t *hlp;
@@ -559,5 +565,5 @@
 		
 		spinlock_lock(&hlp->lock);
-		printf("%-*s %s\n", len, hlp->name, hlp->description);
+		printf("%-*s %s\n", _len, hlp->name, hlp->description);
 		spinlock_unlock(&hlp->lock);
 	}
@@ -668,5 +674,5 @@
 		fnc = (unative_t (*)(void)) arch_construct_function(&fptr,
 		    (void *) symaddr, (void *) cmd_call0);
-		printf("Calling %s() (%p)\n", symbol, symaddr);
+		printf("Calling %s() (%p)\n", symbol, (void *) symaddr);
 		printf("Result: %#" PRIxn "\n", fnc());
 		interrupts_restore(ipl);
@@ -685,5 +691,5 @@
 	 */
 	
-	size_t i;
+	unsigned int i;
 	for (i = 0; i < config.cpu_count; i++) {
 		if (!cpus[i].active)
@@ -697,5 +703,5 @@
 			irq_spinlock_unlock(&thread->lock, true);
 			
-			printf("cpu%" PRIs ": ", i);
+			printf("cpu%u: ", i);
 			
 			thread_ready(thread);
@@ -703,5 +709,5 @@
 			thread_detach(thread);
 		} else
-			printf("Unable to create thread for cpu%" PRIs "\n", i);
+			printf("Unable to create thread for cpu%u\n", i);
 	}
 	
@@ -731,6 +737,9 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1);
-		printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
+		fnc = (unative_t (*)(unative_t, ...))
+		    arch_construct_function(&fptr, (void *) symaddr,
+		    (void *) cmd_call1);
+		printf("Calling f(%#" PRIxn "): %p: %s\n", arg1,
+		    (void *) symaddr, symbol);
 		printf("Result: %#" PRIxn "\n", fnc(arg1));
 		interrupts_restore(ipl);
@@ -765,7 +774,9 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2);
+		fnc = (unative_t (*)(unative_t, unative_t, ...))
+		    arch_construct_function(&fptr, (void *) symaddr,
+		    (void *) cmd_call2);
 		printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", 
-		       arg1, arg2, symaddr, symbol);
+		       arg1, arg2, (void *) symaddr, symbol);
 		printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
 		interrupts_restore(ipl);
@@ -800,7 +811,9 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3);
-		printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", 
-		       arg1, arg2, arg3, symaddr, symbol);
+		fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...))
+		    arch_construct_function(&fptr, (void *) symaddr,
+		    (void *) cmd_call3);
+		printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
+		       arg1, arg2, arg3, (void *) symaddr, symbol);
 		printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
 		interrupts_restore(ipl);
@@ -875,5 +888,5 @@
 	
 	if (rc == ENOENT)
-		printf("Symbol %s not found.\n", argv->buffer);
+		printf("Symbol %s not found.\n", (char *) argv->buffer);
 	else if (rc == EINVAL)
 		printf("Invalid address.\n");
@@ -884,5 +897,5 @@
 		if (pointer)
 			addr = *(uintptr_t *) addr;
-		printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
+		printf("Writing %#" PRIx32" -> %p\n", arg1, (void *) addr);
 		*(uint32_t *) addr = arg1;
 	} else
@@ -1172,8 +1185,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 Run all safe tests\n", len, "*");
+		printf("%-*s %s%s\n", _len, test->name, test->desc,
+		    (test->safe ? "" : " (unsafe)"));
+	
+	printf("%-*s Run all safe tests\n", _len, "*");
 }
 
Index: kernel/generic/src/cpu/cpu.c
===================================================================
--- kernel/generic/src/cpu/cpu.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/cpu/cpu.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -107,5 +107,5 @@
 void cpu_list(void)
 {
-	size_t i;
+	unsigned int i;
 	
 	for (i = 0; i < config.cpu_count; i++) {
Index: kernel/generic/src/debug/debug.c
===================================================================
--- kernel/generic/src/debug/debug.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/debug/debug.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -52,8 +52,8 @@
 	if (symtab_name_lookup((uintptr_t) call_site, &call_site_sym,
 	    &call_site_off) == EOK)
-		printf("%s+%" PRIp "->%s\n", call_site_sym, call_site_off,
-		    fn_sym);
+		printf("%s()+%p->%s()\n", call_site_sym,
+		    (void *) call_site_off, fn_sym);
 	else
-		printf("->%s\n", fn_sym);
+		printf("->%s()\n", fn_sym);
 }
 
@@ -67,8 +67,8 @@
 	if (symtab_name_lookup((uintptr_t) call_site, &call_site_sym,
 	    &call_site_off) == EOK)
-		printf("%s+%" PRIp "<-%s\n", call_site_sym, call_site_off,
-		    fn_sym);
+		printf("%s()+%p<-%s()\n", call_site_sym,
+		    (void *) call_site_off, fn_sym);
 	else
-		printf("<-%s\n", fn_sym);
+		printf("<-%s()\n", fn_sym);
 }
 
Index: kernel/generic/src/debug/panic.c
===================================================================
--- kernel/generic/src/debug/panic.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/debug/panic.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -42,23 +42,27 @@
 #include <interrupt.h>
 
+#define BANNER_LEFT   "######>"
+#define BANNER_RIGHT  "<######"
+
 void panic_common(panic_category_t cat, istate_t *istate, int access,
     uintptr_t address, const char *fmt, ...)
 {
 	va_list args;
-
+	
 	silent = false;
-
-	printf("\nKERNEL PANIC ");
+	
+	printf("\n%s Kernel panic ", BANNER_LEFT);
 	if (CPU)
-		printf("ON cpu%d ", CPU->id);
-	printf("DUE TO ");
-
+		printf("on cpu%u ", CPU->id);
+	printf("due to ");
+	
 	va_start(args, fmt);
 	if (cat == PANIC_ASSERT) {
-		printf("A FAILED ASSERTION:\n");
+		printf("a failed assertion: %s\n", BANNER_RIGHT);
 		vprintf(fmt, args);
 		printf("\n");
 	} else if (cat == PANIC_BADTRAP) {
-		printf("BAD TRAP %ld.\n", address);
+		printf("bad trap %" PRIun ". %s\n", address,
+		    BANNER_RIGHT);
 		if (fmt) {
 			vprintf(fmt, args);
@@ -66,14 +70,15 @@
 		}
 	} else if (cat == PANIC_MEMTRAP) {
-		printf("A BAD MEMORY ACCESS WHILE ");
+		printf("a bad memory access while ");
 		if (access == PF_ACCESS_READ)
-			printf("LOADING FROM");
+			printf("loading from");
 		else if (access == PF_ACCESS_WRITE)
-			printf("STORING TO");
+			printf("storing to");
 		else if (access == PF_ACCESS_EXEC)
-			printf("BRANCHING TO");
+			printf("branching to");
 		else
-			printf("REFERENCING");
-		printf(" ADDRESS %p.\n", address); 
+			printf("referencing");
+		printf(" address %p. %s\n", (void *) address,
+		    BANNER_RIGHT);
 		if (fmt) {
 			vprintf(fmt, args);
@@ -81,17 +86,18 @@
 		}
 	} else {
-		printf("THE FOLLOWING REASON:\n");
+		printf("the following reason: %s\n",
+		    BANNER_RIGHT);
 		vprintf(fmt, args);
 		printf("\n");
 	}
 	va_end(args);
-
+	
 	printf("\n");
-
+	
 	if (istate) {
 		istate_decode(istate);
 		printf("\n");
 	}
-
+	
 	stack_trace();
 	halt();
Index: kernel/generic/src/debug/stacktrace.c
===================================================================
--- kernel/generic/src/debug/stacktrace.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/debug/stacktrace.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -41,6 +41,5 @@
 #define STACK_FRAMES_MAX	20
 
-void
-stack_trace_ctx(stack_trace_ops_t *ops, stack_trace_context_t *ctx)
+void stack_trace_ctx(stack_trace_ops_t *ops, stack_trace_context_t *ctx)
 {
 	int cnt = 0;
@@ -54,17 +53,18 @@
 		if (ops->symbol_resolve &&
 		    ops->symbol_resolve(ctx->pc, &symbol, &offset)) {
-		    	if (offset)
-				printf("%p: %s+%" PRIp "()\n",
-				    ctx->fp, symbol, offset);
+			if (offset)
+				printf("%p: %s()+%p\n", (void *) ctx->fp,
+				    symbol, (void *) offset);
 			else
-				printf("%p: %s()\n",
-				    ctx->fp, symbol);
-		} else {
-			printf("%p: %p()\n", ctx->fp, ctx->pc);
-		}
+				printf("%p: %s()\n", (void *) ctx->fp, symbol);
+		} else
+			printf("%p: %p()\n", (void *) ctx->fp, (void *) ctx->pc);
+		
 		if (!ops->return_address_get(ctx, &pc))
 			break;
+		
 		if (!ops->frame_pointer_prev(ctx, &fp))
 			break;
+		
 		ctx->fp = fp;
 		ctx->pc = pc;
Index: kernel/generic/src/debug/symtab.c
===================================================================
--- kernel/generic/src/debug/symtab.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/debug/symtab.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -192,5 +192,5 @@
 		uintptr_t addr = uint64_t_le2host(symbol_table[pos].address_le);
 		char *realname = symbol_table[pos].symbol_name;
-		printf("%p: %s\n", addr, realname);
+		printf("%p: %s\n", (void *) addr, realname);
 		pos++;
 	}
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/interrupt/interrupt.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -176,5 +176,5 @@
 	printf("Task %s (%" PRIu64 ") killed due to an exception at "
 	    "program counter %p.\n", TASK->name, TASK->taskid,
-	    istate_get_pc(istate));
+	    (void *) istate_get_pc(istate));
 	
 	stack_trace_istate(istate);
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/ipc/ipc.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -702,10 +702,10 @@
 	for (i = 0; i < IPC_MAX_PHONES; i++) {
 		if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
-			printf("%d: mutex busy\n", i);
+			printf("%zu: mutex busy\n", i);
 			continue;
 		}
 		
 		if (task->phones[i].state != IPC_PHONE_FREE) {
-			printf("%" PRIs ": ", i);
+			printf("%zu: ", i);
 			
 			switch (task->phones[i].state) {
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/main/kinit.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -129,5 +129,5 @@
 		 * For each CPU, create its load balancing thread.
 		 */
-		size_t i;
+		unsigned int i;
 		
 		for (i = 0; i < config.cpu_count; i++) {
@@ -139,5 +139,5 @@
 				thread_ready(thread);
 			} else
-				printf("Unable to create kcpulb thread for cpu" PRIs "\n", i);
+				printf("Unable to create kcpulb thread for cpu%u\n", i);
 		}
 	}
@@ -179,5 +179,5 @@
 	for (i = 0; i < init.cnt; i++) {
 		if (init.tasks[i].addr % FRAME_SIZE) {
-			printf("init[%" PRIs "].addr is not frame aligned\n", i);
+			printf("init[%zu].addr is not frame aligned\n", i);
 			programs[i].task = NULL;
 			continue;
@@ -219,5 +219,5 @@
 			
 			if (rd != RE_OK)
-				printf("Init binary %" PRIs " not used (error %d)\n", i, rd);
+				printf("Init binary %zu not used (error %d)\n", i, rd);
 		}
 	}
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/main/main.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -183,6 +183,6 @@
 	version_print();
 	
-	LOG("\nconfig.base=%p config.kernel_size=%" PRIs
-	    "\nconfig.stack_base=%p config.stack_size=%" PRIs,
+	LOG("\nconfig.base=%p config.kernel_size=%zu"
+	    "\nconfig.stack_base=%p config.stack_size=%zu",
 	    config.base, config.kernel_size, config.stack_base,
 	    config.stack_size);
@@ -225,5 +225,5 @@
 	slab_enable_cpucache();
 	
-	printf("Detected %" PRIs " CPU(s), %" PRIu64" MiB free memory\n",
+	printf("Detected %u CPU(s), %" PRIu64 " MiB free memory\n",
 	    config.cpu_count, SIZE2MB(zones_total_size()));
 	
@@ -241,7 +241,6 @@
 		size_t i;
 		for (i = 0; i < init.cnt; i++)
-			LOG("init[%" PRIs "].addr=%p, init[%" PRIs
-			    "].size=%" PRIs, i, init.tasks[i].addr, i,
-			    init.tasks[i].size);
+			LOG("init[%zu].addr=%p, init[%zu].size=%zu",
+			    i, init.tasks[i].addr, i, init.tasks[i].size);
 	} else
 		printf("No init binaries found.\n");
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/mm/as.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -1811,6 +1811,6 @@
 	}
 	
-	panic("Inconsistency detected while adding %" PRIs " pages of used "
-	    "space at %p.", count, page);
+	panic("Inconsistency detected while adding %zu pages of used "
+	    "space at %p.", count, (void *) page);
 }
 
@@ -1991,6 +1991,6 @@
 	
 error:
-	panic("Inconsistency detected while removing %" PRIs " pages of used "
-	    "space from %p.", count, page);
+	panic("Inconsistency detected while removing %zu pages of used "
+	    "space from %p.", count, (void *) page);
 }
 
@@ -2105,7 +2105,8 @@
 			
 			mutex_lock(&area->lock);
-			printf("as_area: %p, base=%p, pages=%" PRIs
-			    " (%p - %p)\n", area, area->base, area->pages,
-			    area->base, area->base + FRAMES2SIZE(area->pages));
+			printf("as_area: %p, base=%p, pages=%zu"
+			    " (%p - %p)\n", area, (void *) area->base,
+			    area->pages, (void *) area->base,
+			    (void *) (area->base + FRAMES2SIZE(area->pages)));
 			mutex_unlock(&area->lock);
 		}
Index: kernel/generic/src/mm/frame.c
===================================================================
--- kernel/generic/src/mm/frame.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/mm/frame.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -145,8 +145,9 @@
 			    (!iswithin(zones.info[i].base, zones.info[i].count,
 			    base, count))) {
-				printf("Zone (%p, %p) overlaps with previous zone (%p, %p)!\n",
-				    PFN2ADDR(base), PFN2ADDR(count),
-				    PFN2ADDR(zones.info[i].base),
-				    PFN2ADDR(zones.info[i].count));
+				printf("Zone (%p, %p) overlaps "
+				    "with previous zone (%p %p)!\n",
+				    (void *) PFN2ADDR(base), (void *) PFN2ADDR(count),
+				    (void *) PFN2ADDR(zones.info[i].base),
+				    (void *) PFN2ADDR(zones.info[i].count));
 			}
 			
@@ -1049,6 +1050,6 @@
 		
 #ifdef CONFIG_DEBUG
-		printf("Thread %" PRIu64 " waiting for %" PRIs " frames, "
-		    "%" PRIs " available.\n", THREAD->tid, size, avail);
+		printf("Thread %" PRIu64 " waiting for %zu frames, "
+		    "%zu available.\n", THREAD->tid, size, avail);
 #endif
 		
@@ -1297,15 +1298,15 @@
 		bool available = zone_flags_available(flags);
 		
-		printf("%-4" PRIs, i);
+		printf("%-4zu", i);
 		
 #ifdef __32_BITS__
-		printf("  %10p", base);
+		printf("  %p", (void *) base);
 #endif
 		
 #ifdef __64_BITS__
-		printf(" %18p", base);
+		printf(" %p", (void *) base);
 #endif
 		
-		printf(" %12" PRIs " %c%c%c      ", count,
+		printf(" %12zu %c%c%c      ", count,
 		    available ? 'A' : ' ',
 		    (flags & ZONE_RESERVED) ? 'R' : ' ',
@@ -1313,5 +1314,5 @@
 		
 		if (available)
-			printf("%14" PRIs " %14" PRIs,
+			printf("%14zu %14zu",
 			    free_count, busy_count);
 		
@@ -1354,7 +1355,7 @@
 	bool available = zone_flags_available(flags);
 	
-	printf("Zone number:       %" PRIs "\n", znum);
-	printf("Zone base address: %p\n", base);
-	printf("Zone size:         %" PRIs " frames (%" PRIs " KiB)\n", count,
+	printf("Zone number:       %zu\n", znum);
+	printf("Zone base address: %p\n", (void *) base);
+	printf("Zone size:         %zu frames (%zu KiB)\n", count,
 	    SIZE2KB(FRAMES2SIZE(count)));
 	printf("Zone flags:        %c%c%c\n",
@@ -1364,7 +1365,7 @@
 	
 	if (available) {
-		printf("Allocated space:   %" PRIs " frames (%" PRIs " KiB)\n",
+		printf("Allocated space:   %zu frames (%zu KiB)\n",
 		    busy_count, SIZE2KB(FRAMES2SIZE(busy_count)));
-		printf("Available space:   %" PRIs " frames (%" PRIs " KiB)\n",
+		printf("Available space:   %zu frames (%zu KiB)\n",
 		    free_count, SIZE2KB(FRAMES2SIZE(free_count)));
 	}
Index: kernel/generic/src/mm/slab.c
===================================================================
--- kernel/generic/src/mm/slab.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/mm/slab.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -890,5 +890,5 @@
 		irq_spinlock_unlock(&slab_cache_lock, true);
 		
-		printf("%-18s %8" PRIs " %8u %8" PRIs " %8ld %8ld %8ld %-5s\n",
+		printf("%-18s %8zu %8u %8zu %8ld %8ld %8ld %-5s\n",
 		    name, size, (1 << order), objects, allocated_slabs,
 		    cached_objs, allocated_objs,
Index: kernel/generic/src/printf/printf_core.c
===================================================================
--- kernel/generic/src/printf/printf_core.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/printf/printf_core.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -83,5 +83,6 @@
 	PrintfQualifierLong,
 	PrintfQualifierLongLong,
-	PrintfQualifierPointer
+	PrintfQualifierPointer,
+	PrintfQualifierSize
 } qualifier_t;
 
@@ -553,7 +554,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
@@ -737,4 +739,9 @@
 				}
 				break;
+			case 'z':
+				qualifier = PrintfQualifierSize;
+				i = nxt;
+				uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
+				break;
 			default:
 				/* Default type */
@@ -764,5 +771,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);
@@ -850,4 +857,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: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/proc/program.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -145,6 +145,6 @@
 		
 		program_loader = image_addr;
-		LOG("Registered program loader at 0x%" PRIp,
-		    image_addr);
+		LOG("Registered program loader at %p",
+		    (void *) image_addr);
 		
 		return EOK;
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/proc/scheduler.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -727,5 +727,5 @@
 		irq_spinlock_lock(&cpus[cpu].lock, true);
 		
-		printf("cpu%u: address=%p, nrdy=%ld, needs_relink=%" PRIs "\n",
+		printf("cpu%u: address=%p, nrdy=%" PRIua ", needs_relink=%zu\n",
 		    cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy),
 		    cpus[cpu].needs_relink);
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/proc/task.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -478,5 +478,5 @@
 #ifdef __32_BITS__
 	if (*additional)
-		printf("%-8" PRIu64 " %9lu %7lu", task->taskid,
+		printf("%-8" PRIu64 " %9" PRIua " %7" PRIua, task->taskid,
 		    atomic_get(&task->refcount), atomic_get(&task->active_calls));
 	else
@@ -489,5 +489,6 @@
 #ifdef __64_BITS__
 	if (*additional)
-		printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c %9lu %7lu",
+		printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c "
+		    "%9" PRIua " %7" PRIua,
 		    task->taskid, ucycles, usuffix, kcycles, ksuffix,
 		    atomic_get(&task->refcount), atomic_get(&task->active_calls));
@@ -501,5 +502,5 @@
 		for (i = 0; i < IPC_MAX_PHONES; i++) {
 			if (task->phones[i].callee)
-				printf(" %" PRIs ":%p", i, task->phones[i].callee);
+				printf(" %zu:%p", i, task->phones[i].callee);
 		}
 		printf("\n");
Index: kernel/generic/src/synch/spinlock.c
===================================================================
--- kernel/generic/src/synch/spinlock.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/synch/spinlock.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -102,7 +102,7 @@
 		
 		if (i++ > DEADLOCK_THRESHOLD) {
-			printf("cpu%u: looping on spinlock %" PRIp ":%s, "
-			    "caller=%" PRIp "(%s)\n", CPU->id, lock, lock->name,
-			    CALLER, symtab_fmt_name_lookup(CALLER));
+			printf("cpu%u: looping on spinlock %p:%s, "
+			    "caller=%p (%s)\n", CPU->id, lock, lock->name,
+			    (void *) CALLER, symtab_fmt_name_lookup(CALLER));
 			
 			i = 0;
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -494,5 +494,5 @@
 			break;
 		case SYSINFO_VAL_DATA:
-			printf("+ %s (%" PRIs" bytes)\n", cur->name,
+			printf("+ %s (%zu bytes)\n", cur->name,
 			    cur->val.data.size);
 			break;
@@ -505,5 +505,5 @@
 			/* N.B.: No data was actually returned (only a dry run) */
 			(void) cur->val.fn_data(cur, &size, true);
-			printf("+ %s (%" PRIs" bytes) [generated]\n", cur->name,
+			printf("+ %s (%zu bytes) [generated]\n", cur->name,
 			    size);
 			break;
Index: kernel/test/avltree/avltree1.c
===================================================================
--- kernel/test/avltree/avltree1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/avltree/avltree1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -202,5 +202,5 @@
 	avltree_create(tree);
 	
-	TPRINTF("Inserting %" PRIs " nodes...", node_count);
+	TPRINTF("Inserting %zu nodes...", node_count);
 	
 	for (i = 0; i < node_count; i++) {
Index: kernel/test/fpu/fpu1_ia64.c
===================================================================
--- kernel/test/fpu/fpu1_ia64.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/fpu/fpu1_ia64.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -161,5 +161,6 @@
 	
 	while (atomic_get(&threads_ok) != total) {
-		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
+		TPRINTF("Threads left: %" PRIua "\n",
+		    total - atomic_get(&threads_ok));
 		thread_sleep(1);
 	}
Index: kernel/test/fpu/fpu1_x86.c
===================================================================
--- kernel/test/fpu/fpu1_x86.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/fpu/fpu1_x86.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -82,5 +82,6 @@
 		
 		if ((int) (100000000 * e) != E_10e8) {
-			TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
+			TPRINTF("tid%" PRIu64 ": e*10e8=%" PRIun " should be %" PRIun "\n",
+			    THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
 			atomic_inc(&threads_fault);
 			break;
@@ -115,5 +116,6 @@
 		
 		if ((int) (100000000 * pi) != PI_10e8) {
-			TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
+			TPRINTF("tid%" PRIu64 ": pi*10e8=%" PRIun " should be %" PRIun "\n",
+			    THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
 			atomic_inc(&threads_fault);
 			break;
@@ -158,5 +160,5 @@
 	
 	while (atomic_get(&threads_ok) != total) {
-		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
+		TPRINTF("Threads left: %" PRIua "\n", total - atomic_get(&threads_ok));
 		thread_sleep(1);
 	}
Index: kernel/test/fpu/sse1.c
===================================================================
--- kernel/test/fpu/sse1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/fpu/sse1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -142,5 +142,5 @@
 	
 	while (atomic_get(&threads_ok) != total) {
-		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
+		TPRINTF("Threads left: %" PRIua "\n", total - atomic_get(&threads_ok));
 		thread_sleep(1);
 	}
Index: kernel/test/mm/falloc1.c
===================================================================
--- kernel/test/mm/falloc1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/mm/falloc1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -64,5 +64,6 @@
 				
 				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
-					TPRINTF("Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
+					TPRINTF("Block at address %p (size %dK) is not aligned\n",
+					    (void *) frames[allocated], (FRAME_SIZE << order) >> 10);
 					return "Test failed";
 				}
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/mm/falloc2.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -85,5 +85,6 @@
 				for (k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); k++) {
 					if (((uint8_t *) frames[i])[k] != val) {
-						TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %#" PRIs "\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
+						TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %zu\n",
+						    THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
 						atomic_inc(&thread_fail);
 						goto cleanup;
@@ -121,5 +122,5 @@
 	
 	while (atomic_get(&thread_count) > 0) {
-		TPRINTF("Threads left: %ld\n", atomic_get(&thread_count));
+		TPRINTF("Threads left: %" PRIua "\n", atomic_get(&thread_count));
 		thread_sleep(1);
 	}
Index: kernel/test/mm/mapping1.c
===================================================================
--- kernel/test/mm/mapping1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/mm/mapping1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -39,6 +39,6 @@
 #define PAGE1  (PAGE0 + PAGE_SIZE)
 
-#define VALUE0  0x01234567
-#define VALUE1  0x89abcdef
+#define VALUE0  UINT32_C(0x01234567)
+#define VALUE1  UINT32_C(0x89abcdef)
 
 const char *test_mapping1(void)
@@ -50,20 +50,26 @@
 	frame1 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
 	
-	TPRINTF("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
+	TPRINTF("Writing %#" PRIx32 " to physical address %p.\n",
+	    (uint32_t) VALUE0, (void *) KA2PA(frame0));
 	*((uint32_t *) frame0) = VALUE0;
 	
-	TPRINTF("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1));
+	TPRINTF("Writing %#" PRIx32 " to physical address %p.\n",
+	    (uint32_t) VALUE1, (void *) KA2PA(frame1));
 	*((uint32_t *) frame1) = VALUE1;
 	
-	TPRINTF("Mapping virtual address %p to physical address %p.\n", PAGE0, KA2PA(frame0));
+	TPRINTF("Mapping virtual address %p to physical address %p.\n",
+	    (void *) PAGE0, (void *) KA2PA(frame0));
 	page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE);
 	
-	TPRINTF("Mapping virtual address %p to physical address %p.\n", PAGE1, KA2PA(frame1));
+	TPRINTF("Mapping virtual address %p to physical address %p.\n",
+	    (void *) PAGE1, (void *) KA2PA(frame1));
 	page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE);
 	
 	v0 = *((uint32_t *) PAGE0);
 	v1 = *((uint32_t *) PAGE1);
-	TPRINTF("Value at virtual address %p is %#x.\n", PAGE0, v0);
-	TPRINTF("Value at virtual address %p is %#x.\n", PAGE1, v1);
+	TPRINTF("Value at virtual address %p is %#" PRIx32 ".\n",
+	    (void *) PAGE0, v0);
+	TPRINTF("Value at virtual address %p is %#" PRIx32 ".\n",
+	    (void *) PAGE1, v1);
 	
 	if (v0 != VALUE0)
@@ -72,8 +78,10 @@
 		return "Value at v1 not equal to VALUE1";
 	
-	TPRINTF("Writing %#x to virtual address %p.\n", 0, PAGE0);
+	TPRINTF("Writing %#" PRIx32 " to virtual address %p.\n",
+	    (uint32_t) 0, (void *) PAGE0);
 	*((uint32_t *) PAGE0) = 0;
 	
-	TPRINTF("Writing %#x to virtual address %p.\n", 0, PAGE1);
+	TPRINTF("Writing %#" PRIx32 " to virtual address %p.\n",
+	    (uint32_t) 0, (void *) PAGE1);
 	*((uint32_t *) PAGE1) = 0;
 	
@@ -81,6 +89,8 @@
 	v1 = *((uint32_t *) PAGE1);
 	
-	TPRINTF("Value at virtual address %p is %#x.\n", PAGE0, *((uint32_t *) PAGE0));	
-	TPRINTF("Value at virtual address %p is %#x.\n", PAGE1, *((uint32_t *) PAGE1));
+	TPRINTF("Value at virtual address %p is %#" PRIx32 ".\n",
+	    (void *) PAGE0, *((uint32_t *) PAGE0));
+	TPRINTF("Value at virtual address %p is %#" PRIx32 ".\n",
+	    (void *) PAGE1, *((uint32_t *) PAGE1));
 	
 	if (v0 != 0)
Index: kernel/test/print/print1.c
===================================================================
--- kernel/test/print/print1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/print/print1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -48,8 +48,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: kernel/test/print/print2.c
===================================================================
--- kernel/test/print/print2.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/print/print2.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -32,7 +32,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");
@@ -48,9 +48,9 @@
 	TPRINTF("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
 	
-	unative_t nat = 0x12345678u;
+	unative_t nat = UINTN_C(0x12345678);
 	
-	TPRINTF("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", 0x1234567887654321ll, 0x12345678, 0x1234, 0x12, nat, 0x1234567887654321ull, \"Lovely string\"):\n");
+	TPRINTF("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), \"Lovely string\"):\n");
 	TPRINTF("Expected output: [0x1234567887654321] [0x12345678] [0x1234] [0x12] [0x12345678] [0x1234567887654321] \"Lovely string\"\n");
-	TPRINTF("Real output:     [%#" PRIx64 "] [%#" PRIx32 "] [%#" PRIx16 "] [%#" PRIx8 "] [%#" PRIxn "] [%#" PRIx64 "] \"%s\"\n\n", 0x1234567887654321ll, 0x12345678, 0x1234, 0x12, nat, 0x1234567887654321ull, "Lovely string");
+	TPRINTF("Real output:     [%#" PRIx64 "] [%#" PRIx32 "] [%#" PRIx16 "] [%#" PRIx8 "] [%#" PRIxn "] [%#" PRIx64 "] \"%s\"\n\n", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), "Lovely string");
 	
 	return NULL;
Index: kernel/test/print/print4.c
===================================================================
--- kernel/test/print/print4.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/print/print4.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -44,5 +44,5 @@
 		TPRINTF("  ");
 		for (index = 0; index < 32; index++)
-			TPRINTF("%lc", (wchar_t) ((group << 5) + index));
+			TPRINTF("%lc", (wint_t) ((group << 5) + index));
 		
 		TPRINTF("\n");
@@ -56,5 +56,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: kernel/test/print/print5.c
===================================================================
--- kernel/test/print/print5.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
+++ kernel/test/print/print5.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -0,0 +1,55 @@
+/*
+ * 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 <print.h>
+#include <test.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: kernel/test/print/print5.def
===================================================================
--- kernel/test/print/print5.def	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
+++ kernel/test/print/print5.def	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -0,0 +1,6 @@
+{
+	"print5",
+	"Extended printf test",
+	&test_print5,
+	true
+},
Index: kernel/test/synch/semaphore1.c
===================================================================
--- kernel/test/synch/semaphore1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/synch/semaphore1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -88,5 +88,6 @@
 		producers = (4 - i) * PRODUCERS;
 		
-		TPRINTF("Creating %d consumers and %d producers...", consumers, producers);
+		TPRINTF("Creating %" PRIua " consumers and %" PRIua " producers...",
+		    consumers, producers);
 		
 		for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
@@ -113,5 +114,6 @@
 		
 		while ((items_consumed.count != consumers) || (items_produced.count != producers)) {
-			TPRINTF("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count);
+			TPRINTF("%" PRIua " consumers remaining, %" PRIua " producers remaining\n",
+			    consumers - items_consumed.count, producers - items_produced.count);
 			thread_sleep(1);
 		}
Index: kernel/test/test.c
===================================================================
--- kernel/test/test.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/test.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -57,4 +57,5 @@
 #include <print/print3.def>
 #include <print/print4.def>
+#include <print/print5.def>
 #include <thread/thread1.def>
 	{
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/test.h	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -76,4 +76,5 @@
 extern const char *test_print3(void);
 extern const char *test_print4(void);
+extern const char *test_print5(void);
 extern const char *test_thread1(void);
 
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ kernel/test/thread/thread1.c	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -76,5 +76,5 @@
 	atomic_set(&finish, 0);
 	while (atomic_get(&threads_finished) < total) {
-		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_finished));
+		TPRINTF("Threads left: %" PRIua "\n", total - atomic_get(&threads_finished));
 		thread_sleep(1);
 	}
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision 2e15ac408aa6d5ce089d57231c2eda5fe5db57d0)
+++ tools/autotool.py	(revision bbc28becd7d06ac1598f9fe6c3a639eb10017af9)
@@ -49,22 +49,38 @@
 
 PACKAGE_BINUTILS = "usually part of binutils"
-PACKAGE_GCC = "preferably version 4.4.3 or newer"
+PACKAGE_GCC = "preferably version 4.5.1 or newer"
 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
 
 COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."
-
-PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, value) \\
+COMPILER_WARNING = "The compilation of HelenOS might fail."
+
+PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
 	asm volatile ( \\
-		"AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t%[val]\\n" \\
+		"AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
 		: \\
 		: [val] "n" (value) \\
 	)
 
-#define DECLARE_INTSIZE(tag, type) \\
-	AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, sizeof(unsigned type)); \\
-	AUTOTOOL_DECLARE("intsize", "signed", tag, #type, sizeof(signed type))
+#define STRING(arg)      STRING_ARG(arg)
+#define STRING_ARG(arg)  #arg
+
+#define DECLARE_BUILTIN_TYPE(tag, type) \\
+	AUTOTOOL_DECLARE("builtin", "", tag, STRING(type), "", "", sizeof(type));
+
+#define DECLARE_INTSIZE(tag, type, strc, conc) \\
+	AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\
+	AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type));
 
 int main(int argc, char *argv[])
 {
+#ifdef __SIZE_TYPE__
+	DECLARE_BUILTIN_TYPE("size", __SIZE_TYPE__);
+#endif
+#ifdef __WCHAR_TYPE__
+	DECLARE_BUILTIN_TYPE("wchar", __WCHAR_TYPE__);
+#endif
+#ifdef __WINT_TYPE__
+	DECLARE_BUILTIN_TYPE("wint", __WINT_TYPE__);
+#endif
 """
 
@@ -96,4 +112,17 @@
 	
 	sys.exit(1)
+
+def print_warning(msg):
+	"Print a bold error message"
+	
+	sys.stderr.write("\n")
+	sys.stderr.write("######################################################################\n")
+	sys.stderr.write("HelenOS build sanity check warning:\n")
+	sys.stderr.write("\n")
+	sys.stderr.write("%s\n" % "\n".join(msg))
+	sys.stderr.write("######################################################################\n")
+	sys.stderr.write("\n")
+	
+	time.sleep(5)
 
 def sandbox_enter():
@@ -186,4 +215,18 @@
 	check_app([common['STRIP'], "--version"], "GNU strip", details)
 
+def decode_value(value):
+	"Decode integer value"
+	
+	base = 10
+	
+	if ((value.startswith('$')) or (value.startswith('#'))):
+		value = value[1:]
+	
+	if (value.startswith('0x')):
+		value = value[2:]
+		base = 16
+	
+	return int(value, base)
+
 def probe_compiler(common, sizes):
 	"Generate, compile and parse probing source"
@@ -195,5 +238,5 @@
 	
 	for typedef in sizes:
-		outf.write("\tDECLARE_INTSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
+		outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc']))
 	
 	outf.write(PROBE_TAIL)
@@ -231,4 +274,12 @@
 	signed_tags = {}
 	
+	unsigned_strcs = {}
+	signed_strcs = {}
+	
+	unsigned_concs = {}
+	signed_concs = {}
+	
+	builtins = {}
+	
 	for j in range(len(lines)):
 		tokens = lines[j].strip().split("\t")
@@ -236,5 +287,5 @@
 		if (len(tokens) > 0):
 			if (tokens[0] == "AUTOTOOL_DECLARE"):
-				if (len(tokens) < 5):
+				if (len(tokens) < 7):
 					print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
 				
@@ -243,33 +294,38 @@
 				tag = tokens[3]
 				name = tokens[4]
-				value = tokens[5]
+				strc = tokens[5]
+				conc = tokens[6]
+				value = tokens[7]
 				
 				if (category == "intsize"):
-					base = 10
-					
-					if ((value.startswith('$')) or (value.startswith('#'))):
-						value = value[1:]
-					
-					if (value.startswith('0x')):
-						value = value[2:]
-						base = 16
-					
 					try:
-						value_int = int(value, base)
+						value_int = decode_value(value)
 					except:
 						print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
 					
 					if (subcategory == "unsigned"):
-						unsigned_sizes[name] = value_int
+						unsigned_sizes[value_int] = name
 						unsigned_tags[tag] = value_int
+						unsigned_strcs[value_int] = strc
+						unsigned_concs[value_int] = conc
 					elif (subcategory == "signed"):
-						signed_sizes[name] = value_int
+						signed_sizes[value_int] = name
 						signed_tags[tag] = value_int
+						signed_strcs[value_int] = strc
+						signed_concs[value_int] = conc
 					else:
 						print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
-	
-	return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags}
-
-def detect_uints(probe, bytes):
+				
+				if (category == "builtin"):
+					try:
+						value_int = decode_value(value)
+					except:
+						print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
+					
+					builtins[tag] = {'name': name, 'value': value_int}
+	
+	return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'builtins': builtins}
+
+def detect_uints(probe, bytes, tags):
 	"Detect correct types for fixed-size integer types"
 	
@@ -278,63 +334,111 @@
 	
 	for b in bytes:
+		if (not b in probe['unsigned_sizes']):
+			print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b,
+			             COMPILER_FAIL])
+		
+		if (not b in probe['signed_sizes']):
+			print_error(['Unable to find appropriate signed integer type for %u bytes' % b,
+			             COMPILER_FAIL])
+		
+		if (not b in probe['unsigned_strcs']):
+			print_error(['Unable to find appropriate unsigned printf formatter for %u bytes' % b,
+			             COMPILER_FAIL])
+		
+		if (not b in probe['signed_strcs']):
+			print_error(['Unable to find appropriate signed printf formatter for %u bytes' % b,
+			             COMPILER_FAIL])
+		
+		if (not b in probe['unsigned_concs']):
+			print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b,
+			             COMPILER_FAIL])
+		
+		if (not b in probe['signed_concs']):
+			print_error(['Unable to find appropriate signed literal macro for %u bytes' % b,
+			             COMPILER_FAIL])
+		
+		typedefs.append({'oldtype': "unsigned %s" % probe['unsigned_sizes'][b], 'newtype': "uint%u_t" % (b * 8)})
+		typedefs.append({'oldtype': "signed %s" % probe['signed_sizes'][b], 'newtype': "int%u_t" % (b * 8)})
+		
+		macros.append({'oldmacro': "\"%so\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIo%u" % (b * 8)})
+		macros.append({'oldmacro': "\"%su\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIu%u" % (b * 8)})
+		macros.append({'oldmacro': "\"%sx\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIx%u" % (b * 8)})
+		macros.append({'oldmacro': "\"%sX\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIX%u" % (b * 8)})
+		macros.append({'oldmacro': "\"%sd\"" % probe['signed_strcs'][b], 'newmacro': "PRId%u" % (b * 8)})
+		
+		name = probe['unsigned_concs'][b]
+		if ((name.startswith('@')) or (name == "")):
+			macros.append({'oldmacro': "c ## U", 'newmacro': "UINT%u_C(c)" % (b * 8)})
+		else:
+			macros.append({'oldmacro': "c ## U%s" % name, 'newmacro': "UINT%u_C(c)" % (b * 8)})
+		
+		name = probe['unsigned_concs'][b]
+		if ((name.startswith('@')) or (name == "")):
+			macros.append({'oldmacro': "c", 'newmacro': "INT%u_C(c)" % (b * 8)})
+		else:
+			macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)})
+	
+	for tag in tags:
+		newmacro = "U%s" % tag
+		if (not tag in probe['unsigned_tags']):
+			print_error(['Unable to find appropriate size macro for %s' % newmacro,
+			             COMPILER_FAIL])
+		
+		oldmacro = "UINT%s" % (probe['unsigned_tags'][tag] * 8)
+		macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
+		macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
+		
+		newmacro = tag
+		if (not tag in probe['unsigned_tags']):
+			print_error(['Unable to find appropriate size macro for %s' % newmacro,
+			             COMPILER_FAIL])
+		
+		oldmacro = "INT%s" % (probe['signed_tags'][tag] * 8)
+		macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
+		macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
+	
+	fnd = True
+	
+	if (not 'wchar' in probe['builtins']):
+		print_warning(['The compiler does not provide the macro __WCHAR_TYPE__',
+		               'for defining the compiler-native type wchar_t. We are',
+		               'forced to define wchar_t as a hardwired type int32_t.',
+		               COMPILER_WARNING])
 		fnd = False
-		newtype = "uint%s_t" % (b * 8)
-		
-		for name, value in probe['unsigned_sizes'].items():
-			if (value == b):
-				oldtype = "unsigned %s" % name
-				typedefs.append({'oldtype' : oldtype, 'newtype' : newtype})
-				fnd = True
-				break
-		
-		if (not fnd):
-			print_error(['Unable to find appropriate integer type for %s' % newtype,
-			             COMPILER_FAIL])
-		
-		
+	
+	if (probe['builtins']['wchar']['value'] != 4):
+		print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining',
+		               'the compiler-native type wchar_t is not compliant with',
+		               'HelenOS. We are forced to define wchar_t as a hardwired',
+		               'type int32_t.',
+		               COMPILER_WARNING])
 		fnd = False
-		newtype = "int%s_t" % (b * 8)
-		
-		for name, value in probe['signed_sizes'].items():
-			if (value == b):
-				oldtype = "signed %s" % name
-				typedefs.append({'oldtype' : oldtype, 'newtype' : newtype})
-				fnd = True
-				break
-		
-		if (not fnd):
-			print_error(['Unable to find appropriate integer type for %s' % newtype,
-			             COMPILER_FAIL])
-	
-	for tag in ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG']:
-		fnd = False;
-		newmacro = "U%s" % tag
-		
-		for name, value in probe['unsigned_tags'].items():
-			if (name == tag):
-				oldmacro = "UINT%s" % (value * 8)
-				macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
-				macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
-				fnd = True
-				break
-		
-		if (not fnd):
-			print_error(['Unable to find appropriate size macro for %s' % newmacro,
-			             COMPILER_FAIL])
-		
-		fnd = False;
-		newmacro = tag
-		
-		for name, value in probe['signed_tags'].items():
-			if (name == tag):
-				oldmacro = "INT%s" % (value * 8)
-				macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
-				macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
-				fnd = True
-				break
-		
-		if (not fnd):
-			print_error(['Unable to find appropriate size macro for %s' % newmacro,
-			             COMPILER_FAIL])
+	
+	if (not fnd):
+		macros.append({'oldmacro': "int32_t", 'newmacro': "wchar_t"})
+	else:
+		macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"})
+	
+	fnd = True
+	
+	if (not 'wint' in probe['builtins']):
+		print_warning(['The compiler does not provide the macro __WINT_TYPE__',
+		               'for defining the compiler-native type wint_t. We are',
+		               'forced to define wint_t as a hardwired type int32_t.',
+		               COMPILER_WARNING])
+		fnd = False
+	
+	if (probe['builtins']['wint']['value'] != 4):
+		print_warning(['The compiler provided macro __WINT_TYPE__ for defining',
+		               'the compiler-native type wint_t is not compliant with',
+		               'HelenOS. We are forced to define wint_t as a hardwired',
+		               'type int32_t.',
+		               COMPILER_WARNING])
+		fnd = False
+	
+	if (not fnd):
+		macros.append({'oldmacro': "int32_t", 'newmacro': "wint_t"})
+	else:
+		macros.append({'oldmacro': "__WINT_TYPE__", 'newmacro': "wint_t"})
 	
 	return {'macros': macros, 'typedefs': typedefs}
@@ -508,13 +612,13 @@
 		probe = probe_compiler(common,
 			[
-				{'type': 'char', 'tag': 'CHAR'},
-				{'type': 'short int', 'tag': 'SHORT'},
-				{'type': 'int', 'tag': 'INT'},
-				{'type': 'long int', 'tag': 'LONG'},
-				{'type': 'long long int', 'tag': 'LLONG'}
+				{'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'},
+				{'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'},
+				{'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'},
+				{'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'},
+				{'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'}
 			]
 		)
 		
-		maps = detect_uints(probe, [1, 2, 4, 8])
+		maps = detect_uints(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'])
 		
 	finally:
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: pace/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: pace/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;
 
