Skip to content

Commit

Permalink
Apply indentation rules
Browse files Browse the repository at this point in the history
Unfortunately this is a large patch. All changes here is from running
`./indent-all.sh`, which applies the projects indentation rules on all
source files.

Signed-off-by: Aksel Sjögren <[email protected]>
  • Loading branch information
sjoegren authored and sni committed Oct 13, 2020
1 parent 4322351 commit 491ba93
Show file tree
Hide file tree
Showing 65 changed files with 2,416 additions and 2,396 deletions.
14 changes: 7 additions & 7 deletions lib/bufferqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ int nm_bufferqueue_peek(nm_bufferqueue *bq, size_t size, void *buffer)
while ((left_in_buffer = current_buf->bqb_bufsize - current_buf->bqb_offset) <= size) {
if (buffer)
memcpy(
buffer + used,
current_buf->bqb_buf + current_buf->bqb_offset,
left_in_buffer);
buffer + used,
current_buf->bqb_buf + current_buf->bqb_offset,
left_in_buffer);
current_buf = current_buf->bqb_next;
size -= left_in_buffer;
used += left_in_buffer;
Expand All @@ -95,9 +95,9 @@ int nm_bufferqueue_peek(nm_bufferqueue *bq, size_t size, void *buffer)
if (size) {
if (buffer)
memcpy(
buffer + used,
current_buf->bqb_buf + current_buf->bqb_offset,
size);
buffer + used,
current_buf->bqb_buf + current_buf->bqb_offset,
size);
}

return 0;
Expand Down Expand Up @@ -199,7 +199,7 @@ int nm_bufferqueue_unshift_to_delim(nm_bufferqueue *bq, const char *delim, size_
*size += (size_t)ptr - ioc_start;
*size += delim_len;

if ((*buffer = calloc(*size, 1)) == NULL )
if ((*buffer = calloc(*size, 1)) == NULL)
return -1;

if (nm_bufferqueue_unshift(bq, *size, *buffer)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/iobroker.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ int iobroker_poll(iobroker_set *iobs, int timeout)

#if defined(IOBROKER_USES_EPOLL)
nfds = epoll_wait(iobs->epfd, iobs->ep_events,
/* to gain consistent "idling" behaviour with the other mechanisms,
* we avoid returning immediately here by "faking" maxevents */
!iobs->num_fds ? 1 : iobs->num_fds,
timeout);
/* to gain consistent "idling" behaviour with the other mechanisms,
* we avoid returning immediately here by "faking" maxevents */
!iobs->num_fds ? 1 : iobs->num_fds,
timeout);
if (nfds < 0) {
return IOBROKER_ELIB;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/kvvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@ struct key_value *kvvec_fetch(struct kvvec *kvv, const char *key, int keylen)
if (kvv->kvv_sorted) {
int low = 0;
int high = kvv->kv_pairs;
while(low < high) {
int mid = (low + high)/2;
while (low < high) {
int mid = (low + high) / 2;
struct key_value *midkv = &(kvv->kv[mid]);

int diff = val_compare(midkv->key, midkv->key_len, key, keylen);

if (diff > 0) {
high = mid;
} else if (diff < 0) {
low = mid+1;
low = mid + 1;
} else {
return midkv;
}
Expand All @@ -187,7 +187,7 @@ struct key_value *kvvec_fetch(struct kvvec *kvv, const char *key, int keylen)
}

/* If unsorted, lookup until found. O(n) */
for (i=0;i<kvv->kv_pairs;i++) {
for (i = 0; i < kvv->kv_pairs; i++) {
if (keylen != kvv->kv[i].key_len)
continue;
if (memcmp(kvv->kv[i].key, key, keylen) != 0)
Expand Down Expand Up @@ -237,7 +237,7 @@ void kvvec_free_kvpairs(struct kvvec *kvv, int flags)

int kvvec_destroy(struct kvvec *kvv, int flags)
{
if(kvv == NULL)
if (kvv == NULL)
return 0;
kvvec_free_kvpairs(kvv, flags);
free(kvv->kv);
Expand Down
115 changes: 61 additions & 54 deletions lib/kvvec_ekvstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
* which char should follow the backslash
*/
static const char table_escape[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 116, 110, 1,
1, 114, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1
};

/**
* Which character should be used if given the character after a backslash.
Expand All @@ -31,22 +32,23 @@ static const char table_escape[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 116, 110, 1,
* This should be mapped inverse to table_escape
*/
static const char table_unescape[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
0, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 10, 111, 112, 113, 13, 115,
9, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 };
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
0, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 10, 111, 112, 113, 13, 115,
9, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
};

/**
* To unpack hex values. Given ascii value for a char, map it to the numeric
Expand All @@ -57,34 +59,37 @@ static const char table_unescape[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
* other values maps to 255, which is handled as errors.
*/
static const char table_dehex[256] = { 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 10, 11,
12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255 };
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 10, 11,
12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255
};

/**
* Table of how to format 0-15 in hex. Should match table_dehex
*/
static const char table_hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a', 'b', 'c', 'd', 'e', 'f' };
'9', 'a', 'b', 'c', 'd', 'e', 'f'
};

static char *expect_string(const char **inptr, int *length, char endchar, char reserved);

char *kvvec_to_ekvstr(const struct kvvec *kvv) {
char *kvvec_to_ekvstr(const struct kvvec *kvv)
{
register unsigned char *buf;
register unsigned char *ptr;
register unsigned char *inptr;
Expand All @@ -103,7 +108,7 @@ char *kvvec_to_ekvstr(const struct kvvec *kvv) {
for (i = 0; i < kvv->kv_pairs; i++) {
kv = &kvv->kv[i];
bufsize += 2;
ptr = (unsigned char*) kv->key;
ptr = (unsigned char *) kv->key;
for (j = kv->key_len; j; j--) {
switch (table_escape[*(ptr++)]) {
case 0:
Expand All @@ -117,7 +122,7 @@ char *kvvec_to_ekvstr(const struct kvvec *kvv) {
break;
}
}
ptr = (unsigned char*) kv->value;
ptr = (unsigned char *) kv->value;
for (j = kv->value_len; j; j--) {
switch (table_escape[*(ptr++)]) {
case 0:
Expand Down Expand Up @@ -147,7 +152,7 @@ char *kvvec_to_ekvstr(const struct kvvec *kvv) {
for (i = 0; i < kvv->kv_pairs; i++) {
kv = &kvv->kv[i];

inptr = (unsigned char*) kv->key;
inptr = (unsigned char *) kv->key;
inlen = kv->key_len;

while (inlen--) {
Expand All @@ -168,7 +173,7 @@ char *kvvec_to_ekvstr(const struct kvvec *kvv) {

*(ptr++) = '=';

inptr = (unsigned char*) kv->value;
inptr = (unsigned char *) kv->value;
inlen = kv->value_len;

while (inlen--) {
Expand All @@ -195,10 +200,11 @@ char *kvvec_to_ekvstr(const struct kvvec *kvv) {
ptr++;

*(--ptr) = '\0'; /* Overwrite last ; */
return (char*) buf;
return (char *) buf;
}

static char *expect_string(const char **inptr, int *length, char endchar, char reserved) {
static char *expect_string(const char **inptr, int *length, char endchar, char reserved)
{
char *buf = NULL;
register const char *inp;
register char *outp;
Expand Down Expand Up @@ -278,7 +284,8 @@ static char *expect_string(const char **inptr, int *length, char endchar, char r
}

#define FAIL_IF(_EXPR) do { if(_EXPR) { free(key); free(value); kvvec_destroy(kvv, KVVEC_FREE_ALL); return NULL; } } while(0)
struct kvvec *ekvstr_to_kvvec(const char *inbuf) {
struct kvvec *ekvstr_to_kvvec(const char *inbuf)
{
struct kvvec *kvv = kvvec_create(35);

const char *inptr = inbuf;
Expand Down
2 changes: 1 addition & 1 deletion lib/nsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int nsock_write_all(int fd, const void *buf, size_t nbyte)
{
size_t c = 0;
int ret = 0;
while ( c < nbyte ) {
while (c < nbyte) {
ret = write(fd, (char *) buf + c, nbyte - c);
if (ret < 0) {
if (errno == EINTR || errno == EAGAIN)
Expand Down
2 changes: 1 addition & 1 deletion lib/objutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ guint nm_service_hash(gconstpointer key)
return (g_str_hash(k->hostname) ^ g_str_hash(k->service_description));
}

nm_service_key * nm_service_key_create(const char *hostname, const char *service_description)
nm_service_key *nm_service_key_create(const char *hostname, const char *service_description)
{
nm_service_key *k = calloc(1, sizeof(*k));
if (!k)
Expand Down
2 changes: 1 addition & 1 deletion lib/runcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int runcmd_cmd2strv(const char *str, int *out_argc, char **out_argv)
set_state(STATE_INSQ | STATE_INARG);
continue;
}
/* FALLTHROUGH */
/* FALLTHROUGH */
case '"':
if (have_state(STATE_INSQ))
break;
Expand Down
8 changes: 4 additions & 4 deletions lib/snprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,20 +493,20 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
break;
case 'X':
cnk->flags |= DP_F_UP;
/* FALLTHROUGH */
/* FALLTHROUGH */
case 'x':
cnk->type = CNK_HEX;
cnk->flags |= DP_F_UNSIGNED;
break;
case 'A':
/* hex float not supported yet */
/* hex float not supported yet */
case 'E':
case 'G':
case 'F':
cnk->flags |= DP_F_UP;
/* FALLTHROUGH */
/* FALLTHROUGH */
case 'a':
/* hex float not supported yet */
/* hex float not supported yet */
case 'e':
case 'f':
case 'g':
Expand Down
2 changes: 1 addition & 1 deletion src/naemon/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ void broker_contact_status(int type, int flags, int attr, contact *cntct)


/* send notification data to broker */
neb_cb_resultset * broker_notification_data(int type, int flags, int attr, int notification_type, int reason_type, struct timeval start_time, struct timeval end_time, void *data, char *ack_author, char *ack_data, int escalated, int contacts_notified)
neb_cb_resultset *broker_notification_data(int type, int flags, int attr, int notification_type, int reason_type, struct timeval start_time, struct timeval end_time, void *data, char *ack_author, char *ack_data, int escalated, int contacts_notified)
{
nebstruct_notification_data ds;
host *temp_host = NULL;
Expand Down
Loading

0 comments on commit 491ba93

Please sign in to comment.