Skip to content
Browse files

reorder, cleanup and consolidate variable declarations

  • Loading branch information...
1 parent 736472a commit 3e486d22c1dc64e1999be1842697923f3e918db5 @zonque zonque committed Jan 24, 2014
Showing with 32 additions and 40 deletions.
  1. +2 −2 bus.c
  2. +9 −12 connection.c
  3. +1 −2 endpoint.c
  4. +1 −1 match.c
  5. +2 −3 memfd.c
  6. +3 −3 message.c
  7. +5 −6 names.c
  8. +1 −2 notify.c
  9. +4 −4 policy.c
  10. +4 −5 pool.c
View
4 bus.c
@@ -185,8 +185,8 @@ int kdbus_bus_new(struct kdbus_ns *ns,
size_t bloom_size, umode_t mode, kuid_t uid,
kgid_t gid, struct kdbus_bus **bus)
{
- char prefix[16];
struct kdbus_bus *b;
+ char prefix[16];
int ret;
BUG_ON(*bus);
@@ -279,8 +279,8 @@ int kdbus_bus_new(struct kdbus_ns *ns,
int kdbus_bus_make_user(struct kdbus_cmd_make *make,
char **name, size_t *bloom_size)
{
- const char *n = NULL;
const struct kdbus_item *item;
+ const char *n = NULL;
u64 bsize = 0;
int ret;
View
21 connection.c
@@ -360,8 +360,7 @@ static int kdbus_conn_payload_add(struct kdbus_conn *conn,
static void kdbus_conn_queue_add(struct kdbus_conn *conn,
struct kdbus_conn_queue *queue)
{
- struct rb_node **n;
- struct rb_node *pn = NULL;
+ struct rb_node **n, *pn = NULL;
bool highest = true;
/* sort into priority queue tree */
@@ -784,10 +783,9 @@ static int kdbus_conn_get_conn_dst(struct kdbus_bus *bus,
static int kdbus_conn_fds_install(struct kdbus_conn *conn,
struct kdbus_conn_queue *queue)
{
- size_t size;
unsigned int i;
- int *fds;
- int ret;
+ int ret, *fds;
+ size_t size;
/* get array of file descriptors */
size = queue->fds_count * sizeof(int);
@@ -832,10 +830,9 @@ static int kdbus_conn_memfds_install(struct kdbus_conn *conn,
struct kdbus_conn_queue *queue,
int **memfds)
{
- size_t size;
- int *fds;
+ int *fds, ret = 0;
unsigned int i;
- int ret = 0;
+ size_t size;
size = queue->memfds_count * sizeof(int);
fds = kmalloc(size, GFP_KERNEL);
@@ -1566,14 +1563,14 @@ int kdbus_cmd_conn_info(struct kdbus_conn *conn,
struct kdbus_cmd_conn_info *cmd_info,
size_t size)
{
- struct kdbus_conn_info info = {};
struct kdbus_conn *owner_conn = NULL;
- size_t off, pos;
- char *name = NULL;
+ struct kdbus_conn_info info = {};
struct kdbus_meta *meta = NULL;
+ char *name = NULL;
+ size_t off, pos;
+ int ret = 0;
u64 flags;
u32 hash;
- int ret = 0;
if (cmd_info->id == 0) {
if (size == sizeof(struct kdbus_cmd_conn_info)) {
View
3 endpoint.c
@@ -118,8 +118,7 @@ struct kdbus_ep *kdbus_ep_unref(struct kdbus_ep *ep)
static struct kdbus_ep *kdbus_ep_find(struct kdbus_bus *bus, const char *name)
{
- struct kdbus_ep *ep = NULL;
- struct kdbus_ep *e;
+ struct kdbus_ep *e, *ep = NULL;
mutex_lock(&bus->lock);
list_for_each_entry(e, &bus->ep_list, bus_entry) {
View
2 match.c
@@ -476,8 +476,8 @@ int kdbus_match_db_remove(struct kdbus_conn *conn,
struct kdbus_cmd_match *cmd)
{
struct kdbus_conn *target_conn = NULL;
- struct kdbus_match_db *db;
struct kdbus_match_entry *entry, *tmp;
+ struct kdbus_match_db *db;
/* privileged users can act on behalf of someone else */
if (cmd->owner_id == 0)
View
5 memfd.c
@@ -102,13 +102,12 @@ u64 kdbus_memfd_size(const struct file *fp)
*/
int kdbus_memfd_new(const char *name, size_t size, int *fd)
{
- struct kdbus_memfile *mf;
const char *shmem_name = NULL;
const char *anon_name = NULL;
+ struct kdbus_memfile *mf;
struct file *shmemfp;
struct file *fp;
- int f;
- int ret;
+ int f, ret;
mf = kzalloc(sizeof(*mf), GFP_KERNEL);
if (!mf)
View
6 message.c
@@ -82,11 +82,11 @@ static int kdbus_msg_scan_items(struct kdbus_conn *conn,
{
const struct kdbus_msg *msg = &kmsg->msg;
const struct kdbus_item *item;
- size_t vecs_size = 0;
unsigned int items_count = 0;
- bool has_fds = false;
- bool has_name = false;
+ size_t vecs_size = 0;
bool has_bloom = false;
+ bool has_name = false;
+ bool has_fds = false;
KDBUS_ITEM_FOREACH(item, msg, items) {
size_t payload_size;
View
11 names.c
@@ -239,10 +239,10 @@ static int kdbus_name_release(struct kdbus_name_entry *e,
void kdbus_name_remove_by_conn(struct kdbus_name_registry *reg,
struct kdbus_conn *conn)
{
- struct kdbus_name_entry *e_tmp, *e;
struct kdbus_name_queue_item *q_tmp, *q;
- LIST_HEAD(notify_list);
+ struct kdbus_name_entry *e_tmp, *e;
LIST_HEAD(names_queue_list);
+ LIST_HEAD(notify_list);
LIST_HEAD(names_list);
mutex_lock(&conn->lock);
@@ -339,8 +339,8 @@ static int kdbus_name_replace_owner(struct kdbus_name_registry *reg,
*/
bool kdbus_name_is_valid(const char *p)
{
- const char *q;
bool dot, found_dot;
+ const char *q;
for (dot = true, q = p; *q; q++) {
if (*q == '.') {
@@ -646,8 +646,8 @@ static int kdbus_name_list_write(struct kdbus_conn *conn,
struct kdbus_name_entry *e,
bool write)
{
- size_t p = *pos;
const size_t len = sizeof(struct kdbus_cmd_name);
+ size_t p = *pos;
size_t nlen = 0;
if (e)
@@ -768,8 +768,7 @@ int kdbus_cmd_name_list(struct kdbus_name_registry *reg,
struct kdbus_cmd_name_list *cmd)
{
struct kdbus_name_list list = {};
- size_t size;
- size_t off, pos;
+ size_t size, off, pos;
int ret;
mutex_lock(&reg->entries_lock);
View
3 notify.c
@@ -112,8 +112,7 @@ int kdbus_notify_name_change(u64 type,
struct list_head *queue_list)
{
struct kdbus_kmsg *kmsg = NULL;
- size_t name_len;
- size_t extra_size;
+ size_t name_len, extra_size;
int ret;
if (!queue_list)
View
8 policy.c
@@ -89,8 +89,8 @@ struct kdbus_policy_db_entry {
*/
void kdbus_policy_db_free(struct kdbus_policy_db *db)
{
- struct kdbus_policy_db_entry *e;
struct kdbus_policy_db_cache_entry *ce;
+ struct kdbus_policy_db_entry *e;
struct hlist_node *tmp;
unsigned int i;
@@ -258,9 +258,9 @@ int kdbus_policy_db_check_send_access(struct kdbus_policy_db *db,
struct kdbus_conn *conn_src,
struct kdbus_conn *conn_dst)
{
- int ret = 0;
- unsigned int hash = 0;
struct kdbus_policy_db_cache_entry *ce;
+ unsigned int hash = 0;
+ int ret = 0;
/*
* If there was a positive match for these two connections before,
@@ -374,8 +374,8 @@ bool kdbus_policy_db_check_own_access(struct kdbus_policy_db *db,
int kdbus_cmd_policy_set(struct kdbus_policy_db *db,
const struct kdbus_cmd_policy *cmd)
{
- const struct kdbus_item *item;
struct kdbus_policy_db_entry *current_entry = NULL;
+ const struct kdbus_item *item;
KDBUS_ITEM_FOREACH(item, cmd, policies) {
if (!KDBUS_ITEM_VALID(item, cmd))
View
9 pool.c
@@ -175,9 +175,8 @@ static int kdbus_pool_alloc_slice(struct kdbus_pool *pool,
size_t size, struct kdbus_slice **slice)
{
size_t slice_size = KDBUS_ALIGN8(size);
- struct rb_node *n;
+ struct rb_node *n, *found = NULL;
struct kdbus_slice *s;
- struct rb_node *found = NULL;
/* search a free slice with the closest matching size */
n = pool->slices_free.rb_node;
@@ -278,9 +277,9 @@ static void kdbus_pool_free_slice(struct kdbus_pool *pool,
*/
int kdbus_pool_new(const char *name, size_t size, struct kdbus_pool **pool)
{
+ struct kdbus_slice *s;
struct kdbus_pool *p;
struct file *f;
- struct kdbus_slice *s;
int ret;
BUG_ON(*pool);
@@ -440,9 +439,9 @@ int kdbus_pool_free_range(struct kdbus_pool *pool, size_t off)
static int kdbus_pool_copy_file(struct page *p, size_t start,
struct file *f, size_t off, size_t count)
{
+ loff_t o = off;
char *kaddr;
ssize_t n;
- loff_t o = off;
kaddr = kmap(p);
n = f->f_op->read(f, (char __force __user *)kaddr + start, count, &o);
@@ -459,8 +458,8 @@ static int kdbus_pool_copy_file(struct page *p, size_t start,
static int kdbus_pool_copy_data(struct page *p, size_t start,
void __user *from, size_t count)
{
- char *kaddr;
unsigned long remain;
+ char *kaddr;
if (fault_in_pages_readable(from, count) < 0)
return -EFAULT;

0 comments on commit 3e486d2

Please sign in to comment.
Something went wrong with that request. Please try again.