Expand "uint" to "unsigned int".
"uint" is not a standard type and is not portable.
Previously we had hacked around this by defining uint in block_device.h.
However, block_device.h was not always included. Instead of continuing
to workaround, eliminate the use of uint.
Bug: 110161494
Change-Id: I36f339c6af4cc7fbcf0e358e3e39562086b6e8bb
diff --git a/block_allocator.c b/block_allocator.c
index 80351d8..96b5868 100644
--- a/block_allocator.c
+++ b/block_allocator.c
@@ -55,8 +55,8 @@
*/
struct block_allocator_queue {
struct block_allocator_queue_entry entry[BLOCK_ALLOCATOR_QUEUE_LEN];
- uint head;
- uint tail;
+ unsigned int head;
+ unsigned int tail;
bool updating;
};
@@ -79,7 +79,8 @@
*
* Return: number of etnries in @q.
*/
-static uint block_allocator_queue_count(struct block_allocator_queue* q) {
+static unsigned int block_allocator_queue_count(
+ struct block_allocator_queue* q) {
return (q->tail + countof(q->entry) - q->head) % countof(q->entry);
}
@@ -93,7 +94,7 @@
*/
static int block_allocator_queue_find(struct block_allocator_queue* q,
data_block_t block) {
- uint i;
+ unsigned int i;
assert(q->head < countof(q->entry));
assert(q->tail < countof(q->entry));
@@ -117,7 +118,7 @@
*/
static void block_allocator_queue_add_dummy(struct block_allocator_queue* q) {
assert(block_allocator_queue_empty(q));
- uint new_tail = (q->tail + 1) % countof(q->entry);
+ unsigned int new_tail = (q->tail + 1) % countof(q->entry);
q->entry[q->tail].removed = true;
q->tail = new_tail;
pr_write("index %d\n", q->tail);
@@ -135,8 +136,8 @@
bool is_tmp,
bool is_free) {
int ret;
- uint index;
- uint new_tail;
+ unsigned int index;
+ unsigned int new_tail;
ret = block_allocator_queue_find(q, block);
if (ret >= 0) {
diff --git a/block_cache.c b/block_cache.c
index 10766ff..75298e4 100644
--- a/block_cache.c
+++ b/block_cache.c
@@ -119,7 +119,7 @@
*/
static struct block_cache_entry* block_cache_pop_io_op(struct block_device* dev,
data_block_t block,
- uint io_op) {
+ unsigned int io_op) {
struct block_cache_entry* entry;
list_for_every_entry(&dev->io_ops, entry, struct block_cache_entry,
@@ -350,8 +350,8 @@
* Return: A score value indicating in what order entries that are close in the
* lru should be replaced.
*/
-static uint block_cache_entry_score(struct block_cache_entry* entry,
- uint index) {
+static unsigned int block_cache_entry_score(struct block_cache_entry* entry,
+ unsigned int index) {
if (!entry->dev) {
return ~0;
}
@@ -377,10 +377,10 @@
bool allocate) {
struct block_cache_entry* entry;
struct block_cache_entry* unused_entry = NULL;
- uint unused_entry_score = 0;
- uint score;
- uint available = 0;
- uint in_use = 0;
+ unsigned int unused_entry_score = 0;
+ unsigned int score;
+ unsigned int available = 0;
+ unsigned int in_use = 0;
assert(dev);
assert(fs || !allocate);
@@ -1267,8 +1267,8 @@
*
* Return: number of blocks in cache that have references.
*/
-uint block_cache_debug_get_ref_block_count(void) {
- uint count = 0;
+unsigned int block_cache_debug_get_ref_block_count(void) {
+ unsigned int count = 0;
struct block_cache_entry* entry;
list_for_every_entry(&block_cache_lru, entry, struct block_cache_entry,
diff --git a/block_cache.h b/block_cache.h
index 07b09cb..e3041aa 100644
--- a/block_cache.h
+++ b/block_cache.h
@@ -111,4 +111,4 @@
data_block_t data_to_block_num(const void* data); /* test api, remove ? */
-uint block_cache_debug_get_ref_block_count(void);
+unsigned int block_cache_debug_get_ref_block_count(void);
diff --git a/block_device.h b/block_device.h
index 3813c70..aeab9ff 100644
--- a/block_device.h
+++ b/block_device.h
@@ -19,7 +19,6 @@
#include <lk/list.h>
#include <stdint.h>
-typedef unsigned int uint;
typedef unsigned long long data_block_t;
/**
diff --git a/block_tree.c b/block_tree.c
index 32bb2b6..ae14b86 100644
--- a/block_tree.c
+++ b/block_tree.c
@@ -151,8 +151,9 @@
* Return: Maximum number of keys that fit in a leaf node or in and internal
* node.
*/
-static uint block_tree_max_key_count(const struct block_tree* tree, bool leaf) {
- uint key_count = tree->key_count[leaf];
+static unsigned int block_tree_max_key_count(const struct block_tree* tree,
+ bool leaf) {
+ unsigned int key_count = tree->key_count[leaf];
assert(key_count);
assert(key_count * tree->key_size < tree->block_size);
@@ -166,7 +167,7 @@
*
* Return: Maximum number of keys that fit @node_ro.
*/
-static uint block_tree_node_max_key_count(
+static unsigned int block_tree_node_max_key_count(
const struct block_tree* tree,
const struct block_tree_node* node_ro) {
return block_tree_max_key_count(tree, block_tree_node_is_leaf(node_ro));
@@ -207,15 +208,15 @@
*/
static void block_tree_node_shift(const struct block_tree* tree,
struct block_tree_node* node_rw,
- uint dest_index,
- uint src_index,
+ unsigned int dest_index,
+ unsigned int src_index,
enum block_tree_shift_mode shift_mode,
const void* new_key,
const void* new_data,
void* overflow_key,
void* overflow_data) {
bool is_leaf = block_tree_node_is_leaf(node_rw);
- uint max_count = tree->key_count[is_leaf];
+ unsigned int max_count = tree->key_count[is_leaf];
int i;
void* base;
@@ -224,7 +225,7 @@
const void* src;
void* dest;
size_t size;
- uint clear_index;
+ unsigned int clear_index;
assert(max_count);
assert(dest_index <= max_count + !is_leaf + 1);
@@ -335,11 +336,11 @@
const struct block_tree* tree,
struct block_tree_node* node_rw,
const struct block_tree_node* src_node_ro,
- uint dest_index,
- uint count,
+ unsigned int dest_index,
+ unsigned int count,
const void* merge_key) {
bool is_leaf = block_tree_node_is_leaf(node_rw);
- uint max_count = tree->key_count[is_leaf];
+ unsigned int max_count = tree->key_count[is_leaf];
void* dest_key;
enum block_tree_shift_mode shift_mode = SHIFT_LEAF_OR_LEFT_CHILD;
if (!is_leaf) {
@@ -367,8 +368,8 @@
*/
static void block_tree_node_shift_down(const struct block_tree* tree,
struct block_tree_node* node_rw,
- uint dest_index,
- uint src_index,
+ unsigned int dest_index,
+ unsigned int src_index,
enum block_tree_shift_mode shift_mode) {
assert(dest_index < src_index);
block_tree_node_shift(tree, node_rw, dest_index, src_index, shift_mode,
@@ -386,7 +387,7 @@
*/
static void block_tree_node_clear_end(const struct block_tree* tree,
struct block_tree_node* node_rw,
- uint start_index) {
+ unsigned int start_index) {
block_tree_node_shift_down(tree, node_rw, start_index, ~0,
block_tree_node_is_leaf(node_rw)
? SHIFT_LEAF_OR_LEFT_CHILD
@@ -408,7 +409,7 @@
*/
static void block_tree_node_insert(const struct block_tree* tree,
struct block_tree_node* node_rw,
- uint index,
+ unsigned int index,
enum block_tree_shift_mode shift_mode,
const void* new_key,
const void* new_data,
@@ -432,7 +433,7 @@
const struct block_tree* tree,
data_block_t node_block,
const struct block_tree_node* node_ro,
- uint index) {
+ unsigned int index) {
data_block_t key = 0;
const void* keyp;
const size_t key_count = block_tree_node_max_key_count(tree, node_ro);
@@ -464,7 +465,7 @@
*/
static void block_tree_node_set_key(const struct block_tree* tree,
struct block_tree_node* node_rw,
- uint index,
+ unsigned int index,
data_block_t new_key) {
const size_t key_size = tree->key_size;
const size_t key_count = block_tree_node_max_key_count(tree, node_rw);
@@ -487,7 +488,7 @@
static const void* block_tree_node_get_child_data(
const struct block_tree* tree,
const struct block_tree_node* node_ro,
- uint index) {
+ unsigned int index) {
bool is_leaf = block_tree_node_is_leaf(node_ro);
const size_t max_key_count = tree->key_count[is_leaf];
const size_t child_data_size = tree->child_data_size[is_leaf];
@@ -533,7 +534,7 @@
const struct block_tree* tree,
data_block_t node_block,
const struct block_tree_node* node_ro,
- uint index) {
+ unsigned int index) {
const struct block_mac* child = NULL;
const size_t key_count = block_tree_node_max_key_count(tree, node_ro);
@@ -572,7 +573,7 @@
const struct block_tree* tree,
data_block_t node_block,
const struct block_tree_node* node_ro,
- uint index) {
+ unsigned int index) {
struct block_mac block_mac_ret = BLOCK_MAC_INITIAL_VALUE(block_mac_ret);
const struct block_mac* datap = NULL;
const size_t max_key_count = block_tree_node_max_key_count(tree, node_ro);
@@ -615,7 +616,7 @@
const struct block_tree* tree,
data_block_t node_block,
const struct block_tree_node* node_ro) {
- uint i;
+ unsigned int i;
const struct block_mac* child;
const size_t key_count = block_tree_node_max_key_count(tree, node_ro);
@@ -651,7 +652,7 @@
const struct block_tree* tree,
data_block_t node_block,
const struct block_tree_node* node_ro) {
- uint i;
+ unsigned int i;
data_block_t key;
struct block_mac data;
const size_t key_count = block_tree_node_max_key_count(tree, node_ro);
@@ -755,7 +756,7 @@
data_block_t node_block,
data_block_t min_key,
data_block_t max_key) {
- uint i;
+ unsigned int i;
data_block_t key;
data_block_t prev_key = 0;
int empty_count;
@@ -834,7 +835,7 @@
data_block_t max_key,
bool updating) {
const struct block_tree_node* node_ro;
- uint i;
+ unsigned int i;
int last_child = 0;
int empty_count;
int depth;
@@ -1074,7 +1075,8 @@
*
* Return: minimum number of keys required for non-root leaf or internal nodes.
*/
-static uint block_tree_min_key_count(const struct block_tree* tree, bool leaf) {
+static unsigned int block_tree_min_key_count(const struct block_tree* tree,
+ bool leaf) {
return block_tree_max_key_count(tree, leaf) / 2;
}
@@ -1351,8 +1353,8 @@
OBJ_REF_INITIAL_VALUE(ref[1]),
};
bool ref_index = 0;
- uint index;
- uint depth;
+ unsigned int index;
+ unsigned int depth;
const struct block_mac* block_mac;
data_block_t prev_key;
data_block_t next_key;
@@ -1635,7 +1637,7 @@
int path_index,
void* data,
obj_ref_t* data_ref) {
- uint index;
+ unsigned int index;
struct block_mac* block_mac;
struct block_tree_node* parent_node_rw;
bool parent_is_leaf;
@@ -1740,7 +1742,7 @@
int path_index,
data_block_t new_key) {
const struct block_mac* block_mac;
- uint index;
+ unsigned int index;
struct block_tree_node* node_rw;
obj_ref_t node_ref = OBJ_REF_INITIAL_VALUE(node_ref);
@@ -1803,8 +1805,8 @@
static int block_tree_node_get_key_count(
const struct block_tree* tree,
const struct block_tree_node* node_ro) {
- uint i;
- uint max_key_count = block_tree_node_max_key_count(tree, node_ro);
+ unsigned int i;
+ unsigned int max_key_count = block_tree_node_max_key_count(tree, node_ro);
for (i = 0; i < max_key_count; i++) {
if (!block_tree_node_get_key(tree, ~0, node_ro, i)) {
@@ -1828,8 +1830,8 @@
const struct block_tree* tree,
const struct block_mac* node_block_mac,
struct block_tree_node* node_rw,
- uint index) {
- uint max_key_count = block_tree_node_max_key_count(tree, node_rw);
+ unsigned int index) {
+ unsigned int max_key_count = block_tree_node_max_key_count(tree, node_rw);
if (print_internal_changes) {
printf("%s: index %d:", __func__, index);
@@ -1876,7 +1878,7 @@
struct block_mac right;
const struct block_mac* block_mac;
const struct block_mac* parent_block_mac;
- uint parent_index;
+ unsigned int parent_index;
int split_index;
data_block_t parent_key;
data_block_t overflow_key = 0;
@@ -2341,8 +2343,8 @@
obj_ref_t* merge_node_ref = &node_ref2;
const struct block_mac* block_mac;
struct block_mac merge_block;
- uint src_index;
- uint dest_index;
+ unsigned int src_index;
+ unsigned int dest_index;
data_block_t key;
data_block_t parent_key;
int index;
@@ -2818,7 +2820,7 @@
const struct block_mac* block_mac;
data_block_t prev_key;
data_block_t next_key;
- uint index;
+ unsigned int index;
size_t max_key_count;
assert(!tr->failed);
diff --git a/block_tree.h b/block_tree.h
index 4f47e85..9562317 100644
--- a/block_tree.h
+++ b/block_tree.h
@@ -102,7 +102,7 @@
*/
struct block_tree_path_entry {
struct block_mac block_mac;
- uint index;
+ unsigned int index;
data_block_t prev_key;
data_block_t next_key;
};
@@ -118,7 +118,7 @@
*/
struct block_tree_path {
struct block_tree_path_entry entry[BLOCK_TREE_MAX_DEPTH];
- uint count;
+ unsigned int count;
struct block_mac data;
struct transaction* tr;
struct block_tree* tree;
diff --git a/fs.h b/fs.h
index c30c114..d6388c5 100644
--- a/fs.h
+++ b/fs.h
@@ -67,8 +67,8 @@
struct block_device* super_dev;
const struct key* key;
data_block_t super_block[2];
- uint super_block_version;
- uint written_super_block_version;
+ unsigned int super_block_version;
+ unsigned int written_super_block_version;
data_block_t min_block_num;
size_t block_num_size;
size_t mac_size;
diff --git a/ipc.h b/ipc.h
index 5e15da0..45a5bb3 100644
--- a/ipc.h
+++ b/ipc.h
@@ -106,9 +106,9 @@
*/
int sync_ipc_send_msg(handle_t session,
iovec_t* tx_iovecs,
- uint tx_iovec_count,
+ unsigned int tx_iovec_count,
iovec_t* rx_iovecs,
- uint rx_iovec_count);
+ unsigned int rx_iovec_count);
int ipc_port_create(struct ipc_port_context* contextp,
const char* port_name,
diff --git a/super.c b/super.c
index ff44434..0431771 100644
--- a/super.c
+++ b/super.c
@@ -103,8 +103,8 @@
const struct block_mac* files) {
struct super_block* super_rw;
obj_ref_t super_ref = OBJ_REF_INITIAL_VALUE(super_ref);
- uint ver;
- uint index;
+ unsigned int ver;
+ unsigned int index;
uint32_t block_size = tr->fs->super_dev->block_size;
assert(block_size >= sizeof(struct super_block));
@@ -209,9 +209,9 @@
*/
static bool use_new_super(const struct block_device* dev,
const struct super_block* new_super,
- uint new_super_index,
+ unsigned int new_super_index,
const struct super_block* old_super) {
- uint dv;
+ unsigned int dv;
if (!super_block_valid(dev, new_super)) {
return false;
}
@@ -320,7 +320,7 @@
* version (regardless of its other content), -1 if not.
*/
static int load_super_block(struct fs* fs, bool clear) {
- uint i;
+ unsigned int i;
int ret;
const struct super_block* new_super;
obj_ref_t new_super_ref = OBJ_REF_INITIAL_VALUE(new_super_ref);
diff --git a/test/block_test.c b/test/block_test.c
index 6f43445..c6da0a8 100644
--- a/test/block_test.c
+++ b/test/block_test.c
@@ -150,7 +150,7 @@
const char* used_by_str,
data_block_t used_by_block) {
struct block_tree_path path;
- uint i;
+ unsigned int i;
block_tree_walk(tr, block_tree, 0, true, &path);
if (path.count) {
@@ -270,28 +270,42 @@
}
}
-typedef uint16_t (*keyfunc_t)(uint index, uint rindex, uint maxindex);
-static uint16_t inc_inc_key(uint index, uint rindex, uint maxindex) {
+typedef uint16_t (*keyfunc_t)(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex);
+static uint16_t inc_inc_key(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex) {
return rindex ?: index;
}
-static uint16_t inc_dec_key(uint index, uint rindex, uint maxindex) {
+static uint16_t inc_dec_key(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex) {
return index;
}
-static uint16_t dec_inc_key(uint index, uint rindex, uint maxindex) {
+static uint16_t dec_inc_key(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex) {
return maxindex + 1 - index;
}
-static uint16_t dec_dec_key(uint index, uint rindex, uint maxindex) {
+static uint16_t dec_dec_key(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex) {
return maxindex + 1 - (rindex ?: index);
}
-static uint16_t same_key(uint index, uint rindex, uint maxindex) {
+static uint16_t same_key(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex) {
return 1;
}
-static uint16_t rand_key(uint index, uint rindex, uint maxindex) {
+static uint16_t rand_key(unsigned int index,
+ unsigned int rindex,
+ unsigned int maxindex) {
uint16_t key;
RAND_bytes((uint8_t*)&key, sizeof(key));
@@ -304,15 +318,15 @@
};
static void block_tree_test_etc(struct transaction* tr,
- uint order,
- uint count,
- uint commit_interval,
+ unsigned int order,
+ unsigned int count,
+ unsigned int commit_interval,
keyfunc_t keyfunc) {
- uint i;
- uint ri;
+ unsigned int i;
+ unsigned int ri;
uint16_t key;
uint16_t tmpkey;
- uint commit_count = 0;
+ unsigned int commit_count = 0;
struct block_tree tree = BLOCK_TREE_INITIAL_VALUE(tree);
struct block_tree_path path;
const size_t key_size = sizeof(key);
@@ -399,10 +413,10 @@
}
static void block_tree_keyfuncs_test(struct transaction* tr,
- uint order,
- uint count) {
- uint commit_interval;
- uint i;
+ unsigned int order,
+ unsigned int count) {
+ unsigned int commit_interval;
+ unsigned int i;
for (commit_interval = 0; commit_interval < 2; commit_interval++) {
for (i = 0; i < countof(keyfuncs); i++) {
@@ -412,7 +426,7 @@
}
static void block_tree_test(struct transaction* tr) {
- uint order;
+ unsigned int order;
block_tree_keyfuncs_test(tr, 6, 5); /* test leaf node only */
block_tree_keyfuncs_test(tr, 6, 10);
@@ -428,7 +442,7 @@
static void block_set_test(struct transaction* tr) {
struct block_set sets[3];
- uint si, i;
+ unsigned int si, i;
for (si = 0; si < countof(sets); si++) {
block_set_init(tr->fs, &sets[si]);
@@ -454,7 +468,7 @@
}
static void block_tree_allocate_all_test(struct transaction* tr) {
- uint i;
+ unsigned int i;
for (i = 0; i < countof(keyfuncs); i++) {
assert(!tr->failed);
@@ -465,7 +479,7 @@
}
}
static void block_map_test(struct transaction* tr) {
- uint i;
+ unsigned int i;
struct block_mac block_mac = BLOCK_MAC_INITIAL_VALUE(block_mac);
struct block_map block_map = BLOCK_MAP_INITIAL_VALUE(block_map);
@@ -500,7 +514,7 @@
size_t blocks1_count,
data_block_t blocks2[],
size_t blocks2_count) {
- uint i;
+ unsigned int i;
struct transaction tr1;
struct transaction tr2;
size_t blocks_max_count = MAX(blocks1_count, blocks2_count);
@@ -561,7 +575,7 @@
size_t blocks1_count,
data_block_t blocks2[],
size_t blocks2_count) {
- uint i;
+ unsigned int i;
struct transaction tr1;
struct transaction tr2;
size_t blocks_max_count = MAX(blocks1_count, blocks2_count);
@@ -679,7 +693,7 @@
}
static void allocate_free_same_test(struct transaction* tr) {
- uint i;
+ unsigned int i;
printf("%s: start allocate then free same test\n", __func__);
for (i = 0; i < countof(allocated); i++) {
allocated[i] = block_allocate(tr);
@@ -712,7 +726,7 @@
}
static void allocate_free_other_test(struct transaction* tr) {
- uint i;
+ unsigned int i;
printf("%s: start allocate then free some other test\n", __func__);
for (i = 0; i < countof(allocated); i++) {
@@ -781,7 +795,7 @@
}
static void free_test(struct transaction* tr) {
- uint i;
+ unsigned int i;
free_test_etc(tr, allocated, countof(allocated), NULL, 0);
@@ -855,15 +869,15 @@
}
static void file_allocate_all_test(struct transaction* master_tr,
- uint tr_count,
+ unsigned int tr_count,
int success_count,
int step_size,
const char* path,
enum file_create_mode create) {
- uint i;
- uint j;
- uint done;
- uint count;
+ unsigned int i;
+ unsigned int j;
+ unsigned int done;
+ unsigned int count;
struct file_handle file[tr_count];
data_block_t file_size[tr_count];
struct transaction tr[tr_count];
@@ -1839,7 +1853,7 @@
},
};
struct transaction tr = {};
- uint i;
+ unsigned int i;
bool test_remount = true;
if (argc > 1) {
diff --git a/transaction.c b/transaction.c
index d78f3f7..9ea937f 100644
--- a/transaction.c
+++ b/transaction.c
@@ -203,7 +203,7 @@
* set.
*/
static void check_free_tree(struct transaction* tr, struct block_set* free) {
- uint i;
+ unsigned int i;
struct block_tree_path path;
block_tree_walk(tr, &free->block_tree, 0, true, &path);