Index: uspace/app/df/df.c
===================================================================
--- uspace/app/df/df.c	(revision 73fbcbb1ce9960d7e8df87fde62a828ed28f2c7a)
+++ uspace/app/df/df.c	(revision 737227c73b00a156857650f236ff37db94a72e24)
@@ -50,5 +50,5 @@
 #define HEADER_TABLE_HR "Filesystem           Size           Used      Available Used%% Mounted on"
 
-#define PERCENTAGE(x, tot) ((unsigned long long) (100L * (x) / (tot)))
+#define PERCENTAGE(x, tot) (tot ? (100ULL * (x) / (tot)) : 0)
 #define FSBK_TO_BK(x, fsbk, bk) \
 	(((fsbk) != 0 && (fsbk) < (bk)) ? \
@@ -59,5 +59,5 @@
 static unsigned int human_readable;
 
-static int size_to_human_readable(char buf[], uint64_t bytes);
+static void size_to_human_readable(char *buf, uint64_t bytes);
 static void print_header(void);
 static void print_statfs(struct statfs *, char *, char *);
@@ -90,5 +90,6 @@
  
 		case ':':
-			fprintf(stderr, "Option -%c requires an operand\n", optopt);
+			fprintf(stderr, "Option -%c requires an operand\n",
+			    optopt);
 			errflg++;
 			break;
@@ -100,5 +101,6 @@
 
 		default:
-			fprintf(stderr, "Unknown error while parsing command line options.");
+			fprintf(stderr,
+			    "Unknown error while parsing command line options");
 			errflg++;
 			break;
@@ -107,5 +109,5 @@
 
 	if (optind > argc) {
-		fprintf(stderr, "Too many input parameter\n");
+		fprintf(stderr, "Too many input parameters\n");
 		errflg++;
 	}
@@ -118,4 +120,5 @@
 	LIST_INITIALIZE(mtab_list);
 	get_mtab_list(&mtab_list);
+
 	print_header();
 	list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) {
@@ -123,24 +126,20 @@
 		print_statfs(&st, mtab_ent->fs_name, mtab_ent->mp);
 	}
+
 	putchar('\n');
 	return 0;
 }
 
-static int size_to_human_readable(char buf[], uint64_t bytes)
+static void size_to_human_readable(char *buf, uint64_t bytes)
 {
 	const char *units = "BkMGTPEZY";
 	int i = 0;
-	int limit;
-
-	limit = str_length(units);
+
 	while (bytes >= 1024) {
-		if (i >= limit) 
-			return -1;
 		bytes /= 1024;
 		i++;
 	}
-	snprintf(buf, 6, "%4llu%c", (unsigned long long)bytes, units[i]);
-
-	return 0;
+
+	snprintf(buf, 6, "%4llu%c", (unsigned long long) bytes, units[i]);
 }
 
@@ -151,4 +150,5 @@
 	else
 		printf(HEADER_TABLE, unit_size);
+
 	putchar('\n');
 }
@@ -156,27 +156,39 @@
 static void print_statfs(struct statfs *st, char *name, char *mountpoint)
 {
+	uint64_t const used_blocks = st->f_blocks - st->f_bfree;
+	unsigned const perc_used = PERCENTAGE(used_blocks, st->f_blocks);
+
 	printf("%10s", name);
 
 	if (human_readable) {
 		char tmp[1024];
+
+		/* Print size */
 		size_to_human_readable(tmp, st->f_blocks *  st->f_bsize);
-		printf(" %14s", tmp);                                                                  /* Size       */
-		size_to_human_readable(tmp, (st->f_blocks - st->f_bfree)  *  st->f_bsize);
-		printf(" %14s", tmp);                                                                  /* Used       */
+		printf(" %14s", tmp);
+
+		/* Number of used blocks */
+		size_to_human_readable(tmp, used_blocks  *  st->f_bsize);
+		printf(" %14s", tmp);
+
+		/* Number of available blocks */
 		size_to_human_readable(tmp, st->f_bfree *  st->f_bsize);
-		printf(" %14s", tmp);                                                                  /* Available  */
-		printf(" %4llu%% %s\n", 
-			(st->f_blocks)?PERCENTAGE(st->f_blocks - st->f_bfree, st->f_blocks):0L,        /* Used%      */
-			mountpoint                                                                     /* Mounted on */
-		);
-	}
-	else
-		printf(" %15llu %14llu %14llu %4llu%% %s\n", 
-			FSBK_TO_BK(st->f_blocks, st->f_bsize, unit_size),                              /* Blocks     */
-			FSBK_TO_BK(st->f_blocks - st->f_bfree, st->f_bsize, unit_size),                /* Used       */
-			FSBK_TO_BK(st->f_bfree, st->f_bsize, unit_size),                               /* Available  */
-			(st->f_blocks)?PERCENTAGE(st->f_blocks - st->f_bfree, st->f_blocks):0L,        /* Used%      */
-			mountpoint                                                                     /* Mounted on */
-		);
+		printf(" %14s", tmp);
+
+		/* Percentage of used blocks */
+		printf(" %4llu%%", 
+		    PERCENTAGE(st->f_blocks - st->f_bfree, st->f_blocks));
+
+		/* Mount point */
+		printf(" %s\n", mountpoint);
+	} else {
+		/* Blocks / Used blocks / Available blocks / Used% / Mounted on */
+		printf(" %15llu %14llu %14llu %4u%% %s\n", 
+		    FSBK_TO_BK(st->f_blocks, st->f_bsize, unit_size),
+		    FSBK_TO_BK(used_blocks, st->f_bsize, unit_size),
+		    FSBK_TO_BK(st->f_bfree, st->f_bsize, unit_size),
+		    perc_used,
+		    mountpoint);
+	}
 
 }
