K&R style braces.
This is essentially commit f02d3ed3e1
from the
1.1 branch, making it easier to merge between master and 1.1.
This commit is contained in:
parent
ab7c61b06f
commit
5dde6461a3
32 changed files with 271 additions and 538 deletions
|
@ -36,8 +36,7 @@
|
|||
Unless the argument noclose is non-zero, daemon() will redirect
|
||||
standard input, standard output and standard error to /dev/null.
|
||||
*/
|
||||
int daemon(int nochdir, int noclose)
|
||||
{
|
||||
int daemon(int nochdir, int noclose) {
|
||||
#ifdef HAVE_FORK
|
||||
pid_t pid;
|
||||
int fd;
|
||||
|
@ -95,8 +94,7 @@ int daemon(int nochdir, int noclose)
|
|||
current directory name. If the environment variable PWD is set, and
|
||||
its value is correct, then that value will be returned.
|
||||
*/
|
||||
char *get_current_dir_name(void)
|
||||
{
|
||||
char *get_current_dir_name(void) {
|
||||
size_t size;
|
||||
char *buf;
|
||||
char *r;
|
||||
|
|
45
lib/list.c
45
lib/list.c
|
@ -25,8 +25,7 @@
|
|||
|
||||
/* (De)constructors */
|
||||
|
||||
list_t *list_alloc(list_action_t delete)
|
||||
{
|
||||
list_t *list_alloc(list_action_t delete) {
|
||||
list_t *list;
|
||||
|
||||
list = xmalloc_and_zero(sizeof(list_t));
|
||||
|
@ -35,18 +34,15 @@ list_t *list_alloc(list_action_t delete)
|
|||
return list;
|
||||
}
|
||||
|
||||
void list_free(list_t *list)
|
||||
{
|
||||
void list_free(list_t *list) {
|
||||
free(list);
|
||||
}
|
||||
|
||||
list_node_t *list_alloc_node(void)
|
||||
{
|
||||
list_node_t *list_alloc_node(void) {
|
||||
return xmalloc_and_zero(sizeof(list_node_t));
|
||||
}
|
||||
|
||||
void list_free_node(list_t *list, list_node_t *node)
|
||||
{
|
||||
void list_free_node(list_t *list, list_node_t *node) {
|
||||
if(node->data && list->delete)
|
||||
list->delete(node->data);
|
||||
|
||||
|
@ -55,8 +51,7 @@ void list_free_node(list_t *list, list_node_t *node)
|
|||
|
||||
/* Insertion and deletion */
|
||||
|
||||
list_node_t *list_insert_head(list_t *list, void *data)
|
||||
{
|
||||
list_node_t *list_insert_head(list_t *list, void *data) {
|
||||
list_node_t *node;
|
||||
|
||||
node = list_alloc_node();
|
||||
|
@ -76,8 +71,7 @@ list_node_t *list_insert_head(list_t *list, void *data)
|
|||
return node;
|
||||
}
|
||||
|
||||
list_node_t *list_insert_tail(list_t *list, void *data)
|
||||
{
|
||||
list_node_t *list_insert_tail(list_t *list, void *data) {
|
||||
list_node_t *node;
|
||||
|
||||
node = list_alloc_node();
|
||||
|
@ -97,8 +91,7 @@ list_node_t *list_insert_tail(list_t *list, void *data)
|
|||
return node;
|
||||
}
|
||||
|
||||
void list_unlink_node(list_t *list, list_node_t *node)
|
||||
{
|
||||
void list_unlink_node(list_t *list, list_node_t *node) {
|
||||
if(node->prev)
|
||||
node->prev->next = node->next;
|
||||
else
|
||||
|
@ -112,34 +105,29 @@ void list_unlink_node(list_t *list, list_node_t *node)
|
|||
list->count--;
|
||||
}
|
||||
|
||||
void list_delete_node(list_t *list, list_node_t *node)
|
||||
{
|
||||
void list_delete_node(list_t *list, list_node_t *node) {
|
||||
list_unlink_node(list, node);
|
||||
list_free_node(list, node);
|
||||
}
|
||||
|
||||
void list_delete_head(list_t *list)
|
||||
{
|
||||
void list_delete_head(list_t *list) {
|
||||
list_delete_node(list, list->head);
|
||||
}
|
||||
|
||||
void list_delete_tail(list_t *list)
|
||||
{
|
||||
void list_delete_tail(list_t *list) {
|
||||
list_delete_node(list, list->tail);
|
||||
}
|
||||
|
||||
/* Head/tail lookup */
|
||||
|
||||
void *list_get_head(list_t *list)
|
||||
{
|
||||
void *list_get_head(list_t *list) {
|
||||
if(list->head)
|
||||
return list->head->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *list_get_tail(list_t *list)
|
||||
{
|
||||
void *list_get_tail(list_t *list) {
|
||||
if(list->tail)
|
||||
return list->tail->data;
|
||||
else
|
||||
|
@ -148,8 +136,7 @@ void *list_get_tail(list_t *list)
|
|||
|
||||
/* Fast list deletion */
|
||||
|
||||
void list_delete_list(list_t *list)
|
||||
{
|
||||
void list_delete_list(list_t *list) {
|
||||
list_node_t *node, *next;
|
||||
|
||||
for(node = list->head; node; node = next) {
|
||||
|
@ -162,8 +149,7 @@ void list_delete_list(list_t *list)
|
|||
|
||||
/* Traversing */
|
||||
|
||||
void list_foreach_node(list_t *list, list_action_node_t action)
|
||||
{
|
||||
void list_foreach_node(list_t *list, list_action_node_t action) {
|
||||
list_node_t *node, *next;
|
||||
|
||||
for(node = list->head; node; node = next) {
|
||||
|
@ -172,8 +158,7 @@ void list_foreach_node(list_t *list, list_action_node_t action)
|
|||
}
|
||||
}
|
||||
|
||||
void list_foreach(list_t *list, list_action_t action)
|
||||
{
|
||||
void list_foreach(list_t *list, list_action_t action) {
|
||||
list_node_t *node, *next;
|
||||
|
||||
for(node = list->head; node; node = next) {
|
||||
|
|
12
lib/utils.c
12
lib/utils.c
|
@ -31,8 +31,7 @@ volatile int cp_index = 0;
|
|||
|
||||
const char hexadecimals[] = "0123456789ABCDEF";
|
||||
|
||||
int charhex2bin(char c)
|
||||
{
|
||||
int charhex2bin(char c) {
|
||||
if(isdigit(c))
|
||||
return c - '0';
|
||||
else
|
||||
|
@ -40,15 +39,13 @@ int charhex2bin(char c)
|
|||
}
|
||||
|
||||
|
||||
void hex2bin(char *src, char *dst, int length)
|
||||
{
|
||||
void hex2bin(char *src, char *dst, int length) {
|
||||
int i;
|
||||
for(i = 0; i < length; i++)
|
||||
dst[i] = charhex2bin(src[i * 2]) * 16 + charhex2bin(src[i * 2 + 1]);
|
||||
}
|
||||
|
||||
void bin2hex(char *src, char *dst, int length)
|
||||
{
|
||||
void bin2hex(char *src, char *dst, int length) {
|
||||
int i;
|
||||
for(i = length - 1; i >= 0; i--) {
|
||||
dst[i * 2 + 1] = hexadecimals[(unsigned char) src[i] & 15];
|
||||
|
@ -57,8 +54,7 @@ void bin2hex(char *src, char *dst, int length)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_TRACING
|
||||
void cp_trace()
|
||||
{
|
||||
void cp_trace() {
|
||||
logger(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d...",
|
||||
cp_file[(cp_index + 15) % 16], cp_line[(cp_index + 15) % 16],
|
||||
cp_file[(cp_index + 14) % 16], cp_line[(cp_index + 14) % 16],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue