Index: uspace/lib/ext4/libext4_directory_index.c
===================================================================
--- uspace/lib/ext4/libext4_directory_index.c	(revision 343ccfd8e68d1b8af5ab00c04b07d36ffa854c56)
+++ uspace/lib/ext4/libext4_directory_index.c	(revision d9bbe45b59b45f91fb35394b54013cbf7aab5774)
@@ -130,9 +130,6 @@
 		ext4_superblock_t *sb, size_t name_len, const char *name)
 {
-	uint32_t block_size, entry_space;
-	uint16_t limit;
-	ext4_directory_dx_root_t *root;
-
-	root = (ext4_directory_dx_root_t *)root_block->data;
+
+	ext4_directory_dx_root_t *root = (ext4_directory_dx_root_t *)root_block->data;
 
 	if (root->info.hash_version != EXT4_HASH_VERSION_TEA &&
@@ -154,12 +151,12 @@
 	}
 
-	block_size = ext4_superblock_get_block_size(sb);
-
-	entry_space = block_size;
+	uint32_t block_size = ext4_superblock_get_block_size(sb);
+
+	uint32_t entry_space = block_size;
 	entry_space -= 2 * sizeof(ext4_directory_dx_dot_entry_t);
 	entry_space -= sizeof(ext4_directory_dx_root_info_t);
     entry_space = entry_space / sizeof(ext4_directory_dx_entry_t);
 
-    limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)&root->entries);
+    uint16_t limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)&root->entries);
     if (limit != entry_space) {
     	return EXT4_ERR_BAD_DX_DIR;
@@ -187,22 +184,18 @@
 {
 	int rc;
-	uint16_t count, limit, entry_space;
-	uint8_t indirect_level;
-	ext4_directory_dx_root_t *root;
+
+	ext4_directory_dx_block_t *tmp_dx_block = dx_blocks;
+
+	ext4_directory_dx_root_t *root = (ext4_directory_dx_root_t *)root_block->data;
+	ext4_directory_dx_entry_t *entries = (ext4_directory_dx_entry_t *)&root->entries;
+
+	uint16_t limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);
+	uint8_t indirect_level = ext4_directory_dx_root_info_get_indirect_levels(&root->info);
+
+	block_t *tmp_block = root_block;
 	ext4_directory_dx_entry_t *p, *q, *m, *at;
-	ext4_directory_dx_entry_t *entries;
-	block_t *tmp_block = root_block;
-	uint32_t fblock, next_block;
-	ext4_directory_dx_block_t *tmp_dx_block = dx_blocks;
-
-	root = (ext4_directory_dx_root_t *)root_block->data;
-	entries = (ext4_directory_dx_entry_t *)&root->entries;
-
-	limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);
-	indirect_level = ext4_directory_dx_root_info_get_indirect_levels(&root->info);
-
 	while (true) {
 
-		count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)entries);
+		uint16_t count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)entries);
 		if ((count == 0) || (count > limit)) {
 			return EXT4_ERR_BAD_DX_DIR;
@@ -232,8 +225,9 @@
         }
 
-		next_block = ext4_directory_dx_entry_get_block(at);
+		uint32_t next_block = ext4_directory_dx_entry_get_block(at);
 
         indirect_level--;
 
+        uint32_t fblock;
         rc = ext4_filesystem_get_inode_data_block_index(fs, inode, next_block, &fblock);
         if (rc != EOK) {
@@ -249,5 +243,6 @@
 		limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);
 
-        entry_space = ext4_superblock_get_block_size(fs->superblock) - sizeof(ext4_directory_dx_dot_entry_t);
+        uint16_t entry_space = ext4_superblock_get_block_size(fs->superblock)
+        		- sizeof(ext4_directory_dx_dot_entry_t);
         entry_space = entry_space / sizeof(ext4_directory_dx_entry_t);
 
@@ -266,15 +261,12 @@
 
 
-static int ext4_dirextory_dx_find_dir_entry(block_t *block,
+static int ext4_directory_dx_find_dir_entry(block_t *block,
 		ext4_superblock_t *sb, size_t name_len, const char *name,
 		ext4_directory_entry_ll_t **res_entry, aoff64_t *block_offset)
 {
-	ext4_directory_entry_ll_t *dentry;
-	uint16_t dentry_len;
-	uint8_t *addr_limit;
+
 	aoff64_t offset = 0;
-
-	dentry = (ext4_directory_entry_ll_t *)block->data;
-	addr_limit = block->data + ext4_superblock_get_block_size(sb);
+	ext4_directory_entry_ll_t *dentry = (ext4_directory_entry_ll_t *)block->data;
+	uint8_t *addr_limit = block->data + ext4_superblock_get_block_size(sb);
 
 	while ((uint8_t *)dentry < addr_limit) {
@@ -297,5 +289,5 @@
 
 		// Goto next entry
-		dentry_len = ext4_directory_entry_ll_get_entry_length(dentry);
+		uint16_t dentry_len = ext4_directory_entry_ll_get_entry_length(dentry);
 
         if (dentry_len == 0) {
@@ -314,19 +306,14 @@
 		ext4_directory_dx_block_t *handle, ext4_directory_dx_block_t *handles)
 {
-	ext4_directory_dx_block_t *p;
-	uint16_t count;
-	uint32_t num_handles;
-	uint32_t current_hash;
-	block_t *block;
-	uint32_t block_addr, block_idx;
-    int rc;
-
-    num_handles = 0;
-    p = handle;
+	int rc;
+
+
+    uint32_t num_handles = 0;
+    ext4_directory_dx_block_t *p = handle;
 
     while (1) {
 
     	p->position++;
-    	count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)p->entries);
+    	uint16_t count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)p->entries);
 
     	if (p->position < p->entries + count) {
@@ -342,5 +329,5 @@
     }
 
-    current_hash = ext4_directory_dx_entry_get_hash(p->position);
+    uint32_t current_hash = ext4_directory_dx_entry_get_hash(p->position);
 
     if ((hash & 1) == 0) {
@@ -350,7 +337,9 @@
     }
 
+
     while (num_handles--) {
 
-    	block_idx = ext4_directory_dx_entry_get_block(p->position);
+    	uint32_t block_idx = ext4_directory_dx_entry_get_block(p->position);
+    	uint32_t block_addr;
     	rc = ext4_filesystem_get_inode_data_block_index(fs, inode, block_idx, &block_addr);
     	if (rc != EOK) {
@@ -358,4 +347,5 @@
     	}
 
+    	block_t *block;
     	rc = block_get(&block, fs->device, block_addr, BLOCK_FLAGS_NONE);
     	if (rc != EOK) {
@@ -379,12 +369,7 @@
 {
 	int rc;
-	uint32_t root_block_addr, leaf_block_addr, leaf_block_idx;
-	aoff64_t block_offset;
-	block_t *root_block, *leaf_block;
-	ext4_hash_info_t hinfo;
-	ext4_directory_entry_ll_t *res_dentry;
-	ext4_directory_dx_block_t dx_blocks[2], *dx_block;
 
 	// get direct block 0 (index root)
+	uint32_t root_block_addr;
 	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, &root_block_addr);
 	if (rc != EOK) {
@@ -392,4 +377,5 @@
 	}
 
+	block_t *root_block;
 	rc = block_get(&root_block, fs->device, root_block_addr, BLOCK_FLAGS_NONE);
 	if (rc != EOK) {
@@ -398,4 +384,5 @@
 	}
 
+	ext4_hash_info_t hinfo;
 	rc = ext4_directory_hinfo_init(&hinfo, root_block, fs->superblock, len, name);
 	if (rc != EOK) {
@@ -404,4 +391,6 @@
 	}
 
+	ext4_directory_dx_block_t dx_blocks[2];
+	ext4_directory_dx_block_t *dx_block;
 	rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref->inode, root_block, &dx_block, dx_blocks);
 	if (rc != EOK) {
@@ -410,8 +399,9 @@
 	}
 
+
 	do {
 
-		leaf_block_idx = ext4_directory_dx_entry_get_block(dx_block->position);
-
+		uint32_t leaf_block_idx = ext4_directory_dx_entry_get_block(dx_block->position);
+		uint32_t leaf_block_addr;
     	rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, leaf_block_idx, &leaf_block_addr);
     	if (rc != EOK) {
@@ -419,4 +409,5 @@
     	}
 
+    	block_t *leaf_block;
 		rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE);
 		if (rc != EOK) {
@@ -424,5 +415,7 @@
 		}
 
-		rc = ext4_dirextory_dx_find_dir_entry(leaf_block, fs->superblock, len, name,
+		aoff64_t block_offset;
+		ext4_directory_entry_ll_t *res_dentry;
+		rc = ext4_directory_dx_find_dir_entry(leaf_block, fs->superblock, len, name,
 				&res_dentry, &block_offset);
 
