Skip to content

Commit

Permalink
usrloc: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent af6b7b7 commit 6e89f3e
Show file tree
Hide file tree
Showing 19 changed files with 1,979 additions and 1,964 deletions.
383 changes: 187 additions & 196 deletions src/modules/usrloc/dlist.c

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions src/modules/usrloc/dlist.h
Expand Up @@ -36,10 +36,11 @@
/*!
* List of all domains registered with usrloc
*/
typedef struct dlist {
str name; /*!< Name of the domain (null terminated) */
udomain_t* d; /*!< Payload */
struct dlist* next; /*!< Next element in the list */
typedef struct dlist
{
str name; /*!< Name of the domain (null terminated) */
udomain_t *d; /*!< Payload */
struct dlist *next; /*!< Next element in the list */
} dlist_t;

/*! \brief Global list of all registered domains */
Expand All @@ -56,7 +57,7 @@ extern dlist_t *_ksr_ul_root;
* \param _d new created domain
* \return 0 on success, -1 on failure
*/
int register_udomain(const char* _n, udomain_t** _d);
int register_udomain(const char *_n, udomain_t **_d);


/*!
Expand All @@ -69,7 +70,7 @@ void free_all_udomains(void);
* \brief Print all domains, just for debugging
* \param _f output file
*/
void print_all_udomains(FILE* _f);
void print_all_udomains(FILE *_f);


/*!
Expand Down Expand Up @@ -123,7 +124,7 @@ int get_all_ucontacts(void *buf, int len, unsigned int flags,
* \param _d usrloc domain (location table)
* \return 0 on success, -1 on failure
*/
int get_udomain(const char* _n, udomain_t** _d);
int get_udomain(const char *_n, udomain_t **_d);

/*!
* \brief Loops through all domains summing up the number of users
Expand All @@ -138,7 +139,7 @@ unsigned long get_number_of_users(void);
* \param _p pointer to domain if found
* \return 1 if domain was found, 0 otherwise
*/
int find_domain(str* _d, udomain_t** _p);
int find_domain(str *_d, udomain_t **_p);


/*!
Expand Down
21 changes: 10 additions & 11 deletions src/modules/usrloc/hslot.c
Expand Up @@ -26,7 +26,6 @@
*/



#include "hslot.h"

/*!
Expand All @@ -35,13 +34,13 @@
* \param _s hash slot
* \param n used to get the slot number (modulo number or locks)
*/
int init_slot(struct udomain* _d, hslot_t* _s, int n)
int init_slot(struct udomain *_d, hslot_t *_s, int n)
{
_s->n = 0;
_s->first = 0;
_s->last = 0;
_s->d = _d;
if(rec_lock_init(&_s->rlock)==NULL) {
if(rec_lock_init(&_s->rlock) == NULL) {
LM_ERR("failed to initialize the slock (%d)\n", n);
return -1;
}
Expand All @@ -53,9 +52,9 @@ int init_slot(struct udomain* _d, hslot_t* _s, int n)
* \brief Deinitialize given slot structure
* \param _s hash slot
*/
void deinit_slot(hslot_t* _s)
void deinit_slot(hslot_t *_s)
{
struct urecord* ptr;
struct urecord *ptr;

/* Remove all elements */
while(_s->first) {
Expand All @@ -67,7 +66,7 @@ void deinit_slot(hslot_t* _s)

_s->n = 0;
_s->last = 0;
_s->d = 0;
_s->d = 0;
}


Expand All @@ -76,9 +75,9 @@ void deinit_slot(hslot_t* _s)
* \param _s hash slot
* \param _r added record
*/
void slot_add(hslot_t* _s, struct urecord* _r)
void slot_add(hslot_t *_s, struct urecord *_r)
{
if (_s->n == 0) {
if(_s->n == 0) {
_s->first = _s->last = _r;
} else {
_r->prev = _s->last;
Expand All @@ -95,15 +94,15 @@ void slot_add(hslot_t* _s, struct urecord* _r)
* \param _s hash slot
* \param _r removed record
*/
void slot_rem(hslot_t* _s, struct urecord* _r)
void slot_rem(hslot_t *_s, struct urecord *_r)
{
if (_r->prev) {
if(_r->prev) {
_r->prev->next = _r->next;
} else {
_s->first = _r->next;
}

if (_r->next) {
if(_r->next) {
_r->next->prev = _r->prev;
} else {
_s->last = _r->prev;
Expand Down
22 changes: 11 additions & 11 deletions src/modules/usrloc/hslot.h
Expand Up @@ -24,7 +24,6 @@
*/



#ifndef HSLOT_H
#define HSLOT_H

Expand All @@ -38,35 +37,36 @@ struct udomain;
struct urecord;


typedef struct hslot {
int n; /*!< Number of elements in the collision slot */
struct urecord* first; /*!< First element in the list */
struct urecord* last; /*!< Last element in the list */
struct udomain* d; /*!< Domain we belong to */
rec_lock_t rlock; /*!< Recursive lock for hash entry */
typedef struct hslot
{
int n; /*!< Number of elements in the collision slot */
struct urecord *first; /*!< First element in the list */
struct urecord *last; /*!< Last element in the list */
struct udomain *d; /*!< Domain we belong to */
rec_lock_t rlock; /*!< Recursive lock for hash entry */
} hslot_t;

/*! \brief
* Initialize slot structure
*/
int init_slot(struct udomain* _d, hslot_t* _s, int n);
int init_slot(struct udomain *_d, hslot_t *_s, int n);


/*! \brief
* Deinitialize given slot structure
*/
void deinit_slot(hslot_t* _s);
void deinit_slot(hslot_t *_s);


/*! \brief
* Add an element to slot linked list
*/
void slot_add(hslot_t* _s, struct urecord* _r);
void slot_add(hslot_t *_s, struct urecord *_r);


/*! \brief
* Remove an element from slot linked list
*/
void slot_rem(hslot_t* _s, struct urecord* _r);
void slot_rem(hslot_t *_s, struct urecord *_r);

#endif /* HSLOT_H */

0 comments on commit 6e89f3e

Please sign in to comment.