summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-04-04 09:33:21 -0400
committerTavian Barnes <tavianator@tavianator.com>2022-04-16 12:09:16 -0400
commit8f5a73a6585bd425807430fd80ce1e3a737f4c5f (patch)
treefde0928db3d0f30b2d156ded10383eee2a9b3b91
parent7241d6cc35134fcb5ec6dfa81bbd01e430b2415f (diff)
downloadbfs-8f5a73a6585bd425807430fd80ce1e3a737f4c5f.tar.xz
style: Use &array[i] rather than array + i
-rw-r--r--mtab.c2
-rw-r--r--pwcache.c8
-rw-r--r--trie.c6
3 files changed, 8 insertions, 8 deletions
diff --git a/mtab.c b/mtab.c
index 8eb90bb..adc3f58 100644
--- a/mtab.c
+++ b/mtab.c
@@ -196,7 +196,7 @@ fail:
static void bfs_mtab_fill_types(struct bfs_mtab *mtab) {
for (size_t i = 0; i < darray_length(mtab->entries); ++i) {
- struct bfs_mtab_entry *entry = mtab->entries + i;
+ struct bfs_mtab_entry *entry = &mtab->entries[i];
struct bfs_stat sb;
if (bfs_stat(AT_FDCWD, entry->path, BFS_STAT_NOFOLLOW | BFS_STAT_NOSYNC, &sb) != 0) {
diff --git a/pwcache.c b/pwcache.c
index 7812b50..91435bd 100644
--- a/pwcache.c
+++ b/pwcache.c
@@ -77,7 +77,7 @@ struct bfs_users *bfs_users_parse(void) {
endpwent();
for (size_t i = 0; i < darray_length(users->entries); ++i) {
- struct passwd *entry = users->entries + i;
+ struct passwd *entry = &users->entries[i];
struct trie_leaf *leaf = trie_insert_str(&users->by_name, entry->pw_name);
if (leaf) {
if (!leaf->value) {
@@ -133,7 +133,7 @@ void bfs_users_free(struct bfs_users *users) {
trie_destroy(&users->by_name);
for (size_t i = 0; i < darray_length(users->entries); ++i) {
- struct passwd *entry = users->entries + i;
+ struct passwd *entry = &users->entries[i];
free(entry->pw_shell);
free(entry->pw_dir);
free(entry->pw_name);
@@ -223,7 +223,7 @@ struct bfs_groups *bfs_groups_parse(void) {
endgrent();
for (size_t i = 0; i < darray_length(groups->entries); ++i) {
- struct group *entry = groups->entries + i;
+ struct group *entry = &groups->entries[i];
struct trie_leaf *leaf = trie_insert_str(&groups->by_name, entry->gr_name);
if (leaf) {
if (!leaf->value) {
@@ -279,7 +279,7 @@ void bfs_groups_free(struct bfs_groups *groups) {
trie_destroy(&groups->by_name);
for (size_t i = 0; i < darray_length(groups->entries); ++i) {
- struct group *entry = groups->entries + i;
+ struct group *entry = &groups->entries[i];
for (size_t j = 0; j < darray_length(entry->gr_mem); ++j) {
free(entry->gr_mem[j]);
}
diff --git a/trie.c b/trie.c
index 6489b0c..bae9acb 100644
--- a/trie.c
+++ b/trie.c
@@ -413,7 +413,7 @@ static struct trie_leaf *trie_node_insert(uintptr_t *ptr, const void *key, size_
node->bitmap |= bit;
unsigned int index = trie_popcount(node->bitmap & (bit - 1));
- uintptr_t *child = node->children + index;
+ uintptr_t *child = &node->children[index];
if (index < size) {
memmove(child + 1, child, (size - index)*sizeof(*child));
}
@@ -550,7 +550,7 @@ struct trie_leaf *trie_insert_mem(struct trie *trie, const void *key, size_t len
if (node->bitmap & bit) {
assert(offset < mismatch);
unsigned int index = trie_popcount(node->bitmap & (bit - 1));
- ptr = node->children + index;
+ ptr = &node->children[index];
} else {
assert(offset == mismatch);
return trie_node_insert(ptr, key, length, offset);
@@ -638,7 +638,7 @@ void trie_remove(struct trie *trie, struct trie_leaf *leaf) {
child_index = index;
}
- child = node->children + index;
+ child = &node->children[index];
}
assert(trie_decode_leaf(*child) == leaf);