summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-02-24 07:25:55 +0100
committerRichard Braun <rbraun@sceen.net>2018-02-24 07:25:55 +0100
commitc31ddfaf11320dea4828c753f48a29041643f552 (patch)
tree88b5c776170c406f90e686c347c7b9fef09d9c38
parent6a69c45189d3c576cc18dfac6e426cd606831657 (diff)
kern/{cbuf,fmt,hash,hlist,list,plist,rdxtree,shell,slist}: update from upstream
Note that this commit changes the order of some list operations without triggering warnings.
-rw-r--r--kern/cbuf.h6
-rw-r--r--kern/fmt.c4
-rw-r--r--kern/hash.h2
-rw-r--r--kern/hlist.h8
-rw-r--r--kern/list.h10
-rw-r--r--kern/plist.c4
-rw-r--r--kern/rdxtree.c12
-rw-r--r--kern/rdxtree.h6
-rw-r--r--kern/rdxtree_i.h5
-rw-r--r--kern/shell.c2
-rw-r--r--kern/shell.h3
-rw-r--r--kern/slist.h12
-rw-r--r--kern/thread.c6
-rw-r--r--vm/vm_map.c2
14 files changed, 47 insertions, 35 deletions
diff --git a/kern/cbuf.h b/kern/cbuf.h
index 4e9f57a..8995fbc 100644
--- a/kern/cbuf.h
+++ b/kern/cbuf.h
@@ -62,6 +62,12 @@ cbuf_size(const struct cbuf *cbuf)
return cbuf->end - cbuf->start;
}
+static inline size_t
+cbuf_avail_size(const struct cbuf *cbuf)
+{
+ return cbuf_capacity(cbuf) - cbuf_size(cbuf);
+}
+
static inline void
cbuf_clear(struct cbuf *cbuf)
{
diff --git a/kern/fmt.c b/kern/fmt.c
index f43a608..e90ed7d 100644
--- a/kern/fmt.c
+++ b/kern/fmt.c
@@ -401,7 +401,7 @@ fmt_sprintf_state_consume(struct fmt_sprintf_state *state)
c = fmt_consume(&state->format);
if (c == '\0') {
- return EIO;
+ return ENOENT;
}
if (c != '%') {
@@ -1083,7 +1083,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state)
c = fmt_consume(&state->format);
if (c == '\0') {
- return EIO;
+ return ENOENT;
}
if (c != '%') {
diff --git a/kern/hash.h b/kern/hash.h
index 182d92b..c854661 100644
--- a/kern/hash.h
+++ b/kern/hash.h
@@ -110,7 +110,7 @@ hash_str(const char *str, unsigned int bits)
hash = ((hash << 5) - hash) + c;
}
- return hash & ((1 << bits) - 1);
+ return hash & ((1UL << bits) - 1);
}
#endif /* KERN_HASH_H */
diff --git a/kern/hlist.h b/kern/hlist.h
index 8445888..62b451a 100644
--- a/kern/hlist.h
+++ b/kern/hlist.h
@@ -149,7 +149,7 @@ hlist_insert_head(struct hlist *list, struct hlist_node *node)
* Insert a node before another node.
*/
static inline void
-hlist_insert_before(struct hlist_node *next, struct hlist_node *node)
+hlist_insert_before(struct hlist_node *node, struct hlist_node *next)
{
node->next = next;
node->pprev = next->pprev;
@@ -161,7 +161,7 @@ hlist_insert_before(struct hlist_node *next, struct hlist_node *node)
* Insert a node after another node.
*/
static inline void
-hlist_insert_after(struct hlist_node *prev, struct hlist_node *node)
+hlist_insert_after(struct hlist_node *node, struct hlist_node *prev)
{
node->next = prev->next;
node->pprev = &prev->next;
@@ -303,7 +303,7 @@ hlist_rcu_insert_head(struct hlist *list, struct hlist_node *node)
* Insert a node before another node.
*/
static inline void
-hlist_rcu_insert_before(struct hlist_node *next, struct hlist_node *node)
+hlist_rcu_insert_before(struct hlist_node *node, struct hlist_node *next)
{
node->next = next;
node->pprev = next->pprev;
@@ -315,7 +315,7 @@ hlist_rcu_insert_before(struct hlist_node *next, struct hlist_node *node)
* Insert a node after another node.
*/
static inline void
-hlist_rcu_insert_after(struct hlist_node *prev, struct hlist_node *node)
+hlist_rcu_insert_after(struct hlist_node *node, struct hlist_node *prev)
{
node->next = prev->next;
node->pprev = &prev->next;
diff --git a/kern/list.h b/kern/list.h
index 7b7e0f6..6c1f7a4 100644
--- a/kern/list.h
+++ b/kern/list.h
@@ -136,7 +136,7 @@ list_empty(const struct list *list)
static inline bool
list_singular(const struct list *list)
{
- return (list != list->next) && (list->next == list->prev);
+ return !list_empty(list) && (list->next == list->prev);
}
/*
@@ -248,7 +248,7 @@ list_insert_tail(struct list *list, struct list *node)
* Insert a node before another node.
*/
static inline void
-list_insert_before(struct list *next, struct list *node)
+list_insert_before(struct list *node, struct list *next)
{
list_add(next->prev, next, node);
}
@@ -257,7 +257,7 @@ list_insert_before(struct list *next, struct list *node)
* Insert a node after another node.
*/
static inline void
-list_insert_after(struct list *prev, struct list *node)
+list_insert_after(struct list *node, struct list *prev)
{
list_add(prev, prev->next, node);
}
@@ -435,7 +435,7 @@ list_rcu_insert_tail(struct list *list, struct list *node)
* Insert a node before another node.
*/
static inline void
-list_rcu_insert_before(struct list *next, struct list *node)
+list_rcu_insert_before(struct list *node, struct list *next)
{
list_rcu_add(next->prev, next, node);
}
@@ -444,7 +444,7 @@ list_rcu_insert_before(struct list *next, struct list *node)
* Insert a node after another node.
*/
static inline void
-list_rcu_insert_after(struct list *prev, struct list *node)
+list_rcu_insert_after(struct list *node, struct list *prev)
{
list_rcu_add(prev, prev->next, node);
}
diff --git a/kern/plist.c b/kern/plist.c
index 851de62..6a5417f 100644
--- a/kern/plist.c
+++ b/kern/plist.c
@@ -37,12 +37,12 @@ plist_add(struct plist *plist, struct plist_node *pnode)
if (list_end(&plist->prio_list, &next->prio_node)
|| (pnode->priority != next->priority)) {
- list_insert_before(&next->prio_node, &pnode->prio_node);
+ list_insert_before(&pnode->prio_node, &next->prio_node);
} else {
list_init(&pnode->prio_node);
}
- list_insert_before(&next->node, &pnode->node);
+ list_insert_before(&pnode->node, &next->node);
}
void
diff --git a/kern/rdxtree.c b/kern/rdxtree.c
index ac73a10..41765f5 100644
--- a/kern/rdxtree.c
+++ b/kern/rdxtree.c
@@ -119,7 +119,7 @@ rdxtree_entry_addr(void *entry)
return (void *)((uintptr_t)entry & RDXTREE_ENTRY_ADDR_MASK);
}
-static inline int
+static inline bool
rdxtree_entry_is_node(const void *entry)
{
return ((uintptr_t)entry & 1) != 0;
@@ -208,13 +208,13 @@ rdxtree_node_unlink(struct rdxtree_node *node)
node->parent = NULL;
}
-static inline int
+static inline bool
rdxtree_node_full(struct rdxtree_node *node)
{
return (node->nr_entries == ARRAY_SIZE(node->entries));
}
-static inline int
+static inline bool
rdxtree_node_empty(struct rdxtree_node *node)
{
return (node->nr_entries == 0);
@@ -282,13 +282,13 @@ rdxtree_node_bm_clear(struct rdxtree_node *node, unsigned short index)
node->alloc_bm &= ~((rdxtree_bm_t)1 << index);
}
-static inline int
+static inline bool
rdxtree_node_bm_is_set(struct rdxtree_node *node, unsigned short index)
{
return (node->alloc_bm & ((rdxtree_bm_t)1 << index));
}
-static inline int
+static inline bool
rdxtree_node_bm_empty(struct rdxtree_node *node)
{
return (node->alloc_bm == RDXTREE_BM_EMPTY);
@@ -684,7 +684,7 @@ rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key)
void *
rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key,
- int get_slot)
+ bool get_slot)
{
struct rdxtree_node *node, *prev;
unsigned short height, shift, index;
diff --git a/kern/rdxtree.h b/kern/rdxtree.h
index 95b9ef9..553c51a 100644
--- a/kern/rdxtree.h
+++ b/kern/rdxtree.h
@@ -25,6 +25,8 @@
#ifndef KERN_RDXTREE_H
#define KERN_RDXTREE_H
+#include <assert.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@@ -136,7 +138,7 @@ void * rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key);
static inline void *
rdxtree_lookup(const struct rdxtree *tree, rdxtree_key_t key)
{
- return rdxtree_lookup_common(tree, key, 0);
+ return rdxtree_lookup_common(tree, key, false);
}
/*
@@ -153,7 +155,7 @@ rdxtree_lookup(const struct rdxtree *tree, rdxtree_key_t key)
static inline void **
rdxtree_lookup_slot(const struct rdxtree *tree, rdxtree_key_t key)
{
- return rdxtree_lookup_common(tree, key, 1);
+ return rdxtree_lookup_common(tree, key, true);
}
static inline void *
diff --git a/kern/rdxtree_i.h b/kern/rdxtree_i.h
index e3583a4..9714f5d 100644
--- a/kern/rdxtree_i.h
+++ b/kern/rdxtree_i.h
@@ -18,6 +18,9 @@
#ifndef KERN_RDXTREE_I_H
#define KERN_RDXTREE_I_H
+#include <stdbool.h>
+#include <stddef.h>
+
/*
* Radix tree.
*/
@@ -56,7 +59,7 @@ int rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr,
rdxtree_key_t *keyp, void ***slotp);
void * rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key,
- int get_slot);
+ bool get_slot);
void * rdxtree_walk(struct rdxtree *tree, struct rdxtree_iter *iter);
diff --git a/kern/shell.c b/kern/shell.c
index ebfa764..f8120e7 100644
--- a/kern/shell.c
+++ b/kern/shell.c
@@ -691,7 +691,7 @@ shell_cmd_history(int argc, char *argv[])
static struct shell_cmd shell_default_cmds[] = {
SHELL_CMD_INITIALIZER("help", shell_cmd_help,
"help [command]",
- "display help about shell commands"),
+ "obtain help about shell commands"),
SHELL_CMD_INITIALIZER("history", shell_cmd_history,
"history",
"display history list"),
diff --git a/kern/shell.h b/kern/shell.h
index bcc1302..69363e7 100644
--- a/kern/shell.h
+++ b/kern/shell.h
@@ -21,8 +21,9 @@
#ifndef KERN_SHELL_H
#define KERN_SHELL_H
-#include <errno.h>
+#include <stddef.h>
+#include <kern/error.h>
#include <kern/init.h>
#include <kern/macros.h>
diff --git a/kern/slist.h b/kern/slist.h
index 53b699d..33cf4e3 100644
--- a/kern/slist.h
+++ b/kern/slist.h
@@ -172,8 +172,8 @@ slist_insert_tail(struct slist *list, struct slist_node *node)
* The prev node must be valid.
*/
static inline void
-slist_insert_after(struct slist *list, struct slist_node *prev,
- struct slist_node *node)
+slist_insert_after(struct slist *list, struct slist_node *node,
+ struct slist_node *prev)
{
node->next = prev->next;
prev->next = node;
@@ -187,8 +187,8 @@ slist_insert_after(struct slist *list, struct slist_node *prev,
* Remove a node from a list.
*
* The prev argument must point to the node immediately preceding the target
- * node. It may safely denote the end of the given list, in which case the
- * first node is removed.
+ * node. It may safely denote the end of the given list (NULL), in which case
+ * the first node is removed.
*/
static inline void
slist_remove(struct slist *list, struct slist_node *prev)
@@ -354,8 +354,8 @@ slist_rcu_insert_tail(struct slist *list, struct slist_node *node)
* The prev node must be valid.
*/
static inline void
-slist_rcu_insert_after(struct slist *list, struct slist_node *prev,
- struct slist_node *node)
+slist_rcu_insert_after(struct slist *list, struct slist_node *node,
+ struct slist_node *prev)
{
node->next = prev->next;
rcu_store_ptr(prev->next, node);
diff --git a/kern/thread.c b/kern/thread.c
index 3ca0677..85e557d 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -938,10 +938,10 @@ thread_sched_fs_enqueue(struct thread_fs_runq *fs_runq, unsigned long round,
}
if (group->weight == 0) {
- list_insert_after(node, &group->node);
+ list_insert_after(&group->node, node);
} else if (node != init_node) {
list_remove(&group->node);
- list_insert_after(node, &group->node);
+ list_insert_after(&group->node, node);
}
/*
@@ -1060,7 +1060,7 @@ thread_sched_fs_dequeue(struct thread *thread)
if (node != init_node) {
list_remove(&group->node);
- list_insert_before(node, &group->node);
+ list_insert_before(&group->node, node);
}
}
}
diff --git a/vm/vm_map.c b/vm/vm_map.c
index 91eedf8..67a24c2 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -337,7 +337,7 @@ vm_map_link(struct vm_map *map, struct vm_map_entry *entry,
if (next == NULL) {
list_insert_tail(&map->entry_list, &entry->list_node);
} else {
- list_insert_before(&next->list_node, &entry->list_node);
+ list_insert_before(&entry->list_node, &next->list_node);
}
rbtree_insert(&map->entry_tree, &entry->tree_node, vm_map_entry_cmp_insert);