Skip to content

Commit

Permalink
global: rerun clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
prajnoha committed Nov 13, 2023
1 parent 0ec9969 commit aa6bedf
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 81 deletions.
8 changes: 4 additions & 4 deletions src/base/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ int sid_binary_encode(const unsigned char *src, size_t in_len, unsigned char *de
in = src;
pos = dest;
while (end - in >= 3) {
*pos++ = base64_table[in[0] >> 2];
*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*pos++ = base64_table[in[2] & 0x3f];
*pos++ = base64_table[in[0] >> 2];
*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*pos++ = base64_table[in[2] & 0x3f];
in += 3;
}

Expand Down
2 changes: 1 addition & 1 deletion src/base/buffer-type-linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static ssize_t _buffer_linear_read_with_size_prefix(struct sid_buffer *buf, int
n = read(fd, buf->mem + buf->stat.usage.used, buf->stat.usage.allocated - buf->stat.usage.used);

if (n > 0) {
previous_used = buf->stat.usage.used;
previous_used = buf->stat.usage.used;
buf->stat.usage.used += n;
if ((expected = EXPECTED(buf))) {
/* Message must start with a prefix that is SID_BUFFER_SIZE_PREFIX_LEN bytes! */
Expand Down
6 changes: 3 additions & 3 deletions src/base/buffer-type-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ static ssize_t _buffer_vector_write(struct sid_buffer *buf, int fd, size_t pos)
if (pos) {
for (; i < buf->stat.usage.used; i++) {
if (iov[i].iov_len > start_off) {
start_idx = i;
save_base = iov[i].iov_base;
save_len = iov[i].iov_len;
start_idx = i;
save_base = iov[i].iov_base;
save_len = iov[i].iov_len;
iov[i].iov_base += start_off;
iov[i].iov_len -= start_off;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/iface/service-link.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static const char *_get_arg_value(const char *str, const char *key_eq, size_t *s
if (!strncmp(key_eq, str, strlen(key_eq))) {
/* get the value and its size */
str += strlen(key_eq);
*size = line_end - str;
*size = line_end - str;
return str;
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/include/base/buffer-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ struct sid_buffer {
};

struct sid_buffer_type {
int (*create)(struct sid_buffer *buf);
int (*destroy)(struct sid_buffer *buf);
int (*reset)(struct sid_buffer *buf);
int (*add)(struct sid_buffer *buf, void *data, size_t len, const void **mem, size_t *pos);
int (*fmt_add)(struct sid_buffer *buf, const void **mem, size_t *pos, const char *fmt, va_list ap);
int (*release)(struct sid_buffer *buf, size_t pos, bool rewind);
int (*release_mem)(struct sid_buffer *buf, const void *mem, bool rewind);
bool (*is_complete)(struct sid_buffer *buf, int *ret_code);
int (*get_data)(struct sid_buffer *buf, size_t pos, const void **data, size_t *data_size);
int (*get_fd)(struct sid_buffer *buf);
size_t (*count)(struct sid_buffer *buf);
int (*create)(struct sid_buffer *buf);
int (*destroy)(struct sid_buffer *buf);
int (*reset)(struct sid_buffer *buf);
int (*add)(struct sid_buffer *buf, void *data, size_t len, const void **mem, size_t *pos);
int (*fmt_add)(struct sid_buffer *buf, const void **mem, size_t *pos, const char *fmt, va_list ap);
int (*release)(struct sid_buffer *buf, size_t pos, bool rewind);
int (*release_mem)(struct sid_buffer *buf, const void *mem, bool rewind);
bool (*is_complete)(struct sid_buffer *buf, int *ret_code);
int (*get_data)(struct sid_buffer *buf, size_t pos, const void **data, size_t *data_size);
int (*get_fd)(struct sid_buffer *buf);
size_t (*count)(struct sid_buffer *buf);
ssize_t (*read)(struct sid_buffer *buf, int fd);
ssize_t (*write)(struct sid_buffer *buf, int fd, size_t pos);
};
Expand Down
10 changes: 5 additions & 5 deletions src/include/internal/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ char *util_str_rstr(const char *haystack, const char *needle);
char *util_str_combstr(const char *haystack, const char *prefix, const char *needle, const char *suffix, bool ignorecase);

typedef int (*util_str_token_fn_t)(const char *token, size_t len, bool merge_back, void *data);
int util_str_iterate_tokens(const char *str,
const char *delims,
const char *quotes,
util_str_token_fn_t token_fn,
void *token_fn_data);
int util_str_iterate_tokens(const char *str,
const char *delims,
const char *quotes,
util_str_token_fn_t token_fn,
void *token_fn_data);

char *util_str_comb_to_str(util_mem_t *mem, const char *prefix, const char *str, const char *suffix);

Expand Down
22 changes: 11 additions & 11 deletions src/include/log/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ typedef enum {

struct log_target {
const char *name;
void (*open)(int verbose_mode);
void (*close)(void);
void (*output)(int level_id,
const char *prefix,
int class_id,
int errno_id,
const char *src_file_name,
int src_line_number,
const char *function_name,
const char *format,
va_list ap);
void (*open)(int verbose_mode);
void (*close)(void);
void (*output)(int level_id,
const char *prefix,
int class_id,
int errno_id,
const char *src_file_name,
int src_line_number,
const char *function_name,
const char *format,
va_list ap);
};

extern const struct log_target log_target_standard;
Expand Down
10 changes: 5 additions & 5 deletions src/include/resource/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ extern "C" {
typedef struct sid_resource sid_resource_t;

typedef struct sid_resource_type {
const char *name;
const char *short_name;
const char *description;
int (*init)(sid_resource_t *res, const void *kickstart_data, void **data);
int (*destroy)(sid_resource_t *res);
const char *name;
const char *short_name;
const char *description;
int (*init)(sid_resource_t *res, const void *kickstart_data, void **data);
int (*destroy)(sid_resource_t *res);
unsigned int with_event_loop:1;
unsigned int with_watchdog :1;
} sid_resource_type_t;
Expand Down
22 changes: 11 additions & 11 deletions src/internal/bptree.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ static bptree_record_t *_make_record(bptree_t *bptree, void *data, size_t data_s
if (!(rec = malloc(sizeof(bptree_record_t))))
return NULL;

rec->data_size = data_size;
rec->data = data;
rec->ref_count = 0;
rec->data_size = data_size;
rec->data = data;
rec->ref_count = 0;

bptree->meta_size += sizeof(*rec);
bptree->data_size += data_size;
Expand Down Expand Up @@ -372,7 +372,7 @@ static bptree_key_t *_make_bkey(bptree_t *bptree, const char *key)
return NULL;
}

bkey->ref_count = 0;
bkey->ref_count = 0;

bptree->meta_size += (sizeof(*bkey) + strlen(key) + 1);

Expand Down Expand Up @@ -429,9 +429,9 @@ static bptree_node_t *_make_node(bptree_t *bptree)
return NULL;
}

new_node->is_leaf = false;
new_node->num_keys = 0;
new_node->parent = NULL;
new_node->is_leaf = false;
new_node->num_keys = 0;
new_node->parent = NULL;

bptree->meta_size += (sizeof(*new_node) + pointers_size + bkeys_size);

Expand Down Expand Up @@ -814,9 +814,9 @@ int bptree_insert(bptree_t *bptree, const char *key, void *data, size_t data_siz
bptree_key_t *bkey;

if ((rec = _find(bptree, key, LOOKUP_EXACT, NULL, NULL, NULL))) {
rec->data = data;
rec->data = data;
bptree->data_size -= rec->data_size;
rec->data_size = data_size;
rec->data_size = data_size;
bptree->data_size += rec->data_size;
return 0;
}
Expand Down Expand Up @@ -937,9 +937,9 @@ int bptree_update(bptree_t *bptree,
switch (act) {
case BPTREE_UPDATE_WRITE:
if (rec) {
rec->data = data ? *data : NULL;
rec->data = data ? *data : NULL;
bptree->data_size -= rec->data_size;
rec->data_size = data_size ? *data_size : 0;
rec->data_size = data_size ? *data_size : 0;
bptree->data_size += rec->data_size;
} else
r = bptree_insert(bptree, key, data ? *data : NULL, data_size ? *data_size : 0);
Expand Down
4 changes: 2 additions & 2 deletions src/internal/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ static unsigned long _hash(const char *key, unsigned key_len)

for (i = 0; i < key_len; i++) {
h <<= 4;
h += _nums[(unsigned char) *key++];
g = h & ((unsigned long) 0xf << 16u);
h += _nums[(unsigned char) *key++];
g = h & ((unsigned long) 0xf << 16u);
if (g) {
h ^= g >> 16u;
h ^= g >> 5u;
Expand Down
2 changes: 1 addition & 1 deletion src/internal/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int _copy_token_to_strv(const char *token, size_t len, bool merge_back, v

memcpy(copier->s, token, len);
copier->s += len;
*copier->s = '\0';
*copier->s = '\0';

copier->s++;
copier->i++;
Expand Down
10 changes: 5 additions & 5 deletions src/resource/kv-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static struct kv_store_value *_create_kv_store_value(struct iovec *i
memcpy(p, iov[i].iov_base, iov[i].iov_len);
if (flags & KV_STORE_VALUE_AUTOFREE)
free(iov[i].iov_base);
iov[i].iov_base = p;
iov[i].iov_base = p;
p += iov[i].iov_len;
}

Expand All @@ -289,9 +289,9 @@ static struct kv_store_value *_create_kv_store_value(struct iovec *i
p += iov[i].iov_len;
}

value->size = data_size;
value->size = data_size;
flags &= ~KV_STORE_VALUE_VECTOR;
value->int_flags = KV_STORE_VALUE_INT_ALLOC;
value->int_flags = KV_STORE_VALUE_INT_ALLOC;
} else {
/* E */
value_size = sizeof(*value) + iov_cnt * sizeof(struct iovec) + data_size;
Expand All @@ -304,8 +304,8 @@ static struct kv_store_value *_create_kv_store_value(struct iovec *i

for (i = 0; i < iov_cnt; i++) {
memcpy(p, iov[i].iov_base, iov[i].iov_len);
iov2[i].iov_base = p;
iov2[i].iov_len = iov[i].iov_len;
iov2[i].iov_base = p;
iov2[i].iov_len = iov[i].iov_len;
p += iov[i].iov_len;
}

Expand Down
2 changes: 1 addition & 1 deletion src/resource/module-registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static int _init_module(sid_resource_t *module_res, const void *kickstart_data,
goto fail;

symbol_params.flags |= MODULE_SYMBOL_FAIL_ON_MISSING;
symbol_params.name = MODULE_INIT_NAME;
symbol_params.name = MODULE_INIT_NAME;
if (_load_module_symbol(module_res, module->handle, &symbol_params, (void **) &module->init_fn) < 0)
goto fail;

Expand Down
34 changes: 17 additions & 17 deletions src/resource/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ struct cmd_exec_arg {
struct cmd_reg {
const char *name;
uint32_t flags;
int (*exec)(struct cmd_exec_arg *exec_arg);
int (*exec)(struct cmd_exec_arg *exec_arg);
};

typedef struct {
Expand Down Expand Up @@ -1222,18 +1222,18 @@ static int _build_cmd_kv_buffers(sid_resource_t *cmd_res, const struct cmd_reg *
vector = kv_store_value_flags & KV_STORE_VALUE_VECTOR;

if (vector) {
vvalue = raw_value;
vvalue_size = size;
svalue = NULL;
vvalue = raw_value;
vvalue_size = size;
svalue = NULL;
VVALUE_FLAGS(vvalue) &= ~KV_SYNC;
if (cmd_reg->flags & CMD_KV_EXPORT_PERSISTENT) {
if (!(VVALUE_FLAGS(vvalue) & KV_PERSIST))
continue;
}
} else {
vvalue = NULL;
vvalue_size = 0;
svalue = raw_value;
vvalue = NULL;
vvalue_size = 0;
svalue = raw_value;
svalue->flags &= ~KV_SYNC;
if (cmd_reg->flags & CMD_KV_EXPORT_PERSISTENT) {
if (!(svalue->flags & KV_PERSIST))
Expand Down Expand Up @@ -2359,7 +2359,7 @@ void *sid_ucmd_set_kv(struct module *mod,
return NULL;

if (ns == KV_NS_UDEV) {
dom = NULL;
dom = NULL;
flags |= KV_SYNC_P;
} else
dom = KV_KEY_DOM_USER;
Expand Down Expand Up @@ -2407,7 +2407,7 @@ static const void *_cmd_get_key_spec_value(struct module *mod,
if (flags)
*flags = svalue->flags;

ext_data_offset = _svalue_ext_data_offset(svalue);
ext_data_offset = _svalue_ext_data_offset(svalue);
size -= (SVALUE_HEADER_SIZE + ext_data_offset);

if (value_size)
Expand Down Expand Up @@ -5376,7 +5376,7 @@ static int _sync_main_kv_store(sid_resource_t *res, struct sid_ucmd_common_ctx *
goto out;
}

end = p + msg_size;
end = p + msg_size;
p += sizeof(msg_size);

if (kv_store_transaction_begin(common_ctx->kv_store_res) < 0) {
Expand All @@ -5394,7 +5394,7 @@ static int _sync_main_kv_store(sid_resource_t *res, struct sid_ucmd_common_ctx *
memcpy(&value_size, p, sizeof(value_size));
p += sizeof(value_size);

key = p;
key = p;
p += key_size;

/*
Expand All @@ -5419,7 +5419,7 @@ static int _sync_main_kv_store(sid_resource_t *res, struct sid_ucmd_common_ctx *
for (i = 0; i < value_size; i++) {
memcpy(&vvalue[i].iov_len, p, sizeof(size_t));
p += sizeof(size_t);
vvalue[i].iov_base = p;
vvalue[i].iov_base = p;
p += vvalue[i].iov_len;
}
/* Copy values to aligned memory */
Expand Down Expand Up @@ -5476,12 +5476,12 @@ static int _sync_main_kv_store(sid_resource_t *res, struct sid_ucmd_common_ctx *
memcpy(svalue, p, value_size);
p += value_size;

ext_data_offset = _svalue_ext_data_offset(svalue);
unset = ((svalue->flags != KV_RS) && (value_size == SVALUE_HEADER_SIZE + ext_data_offset));
ext_data_offset = _svalue_ext_data_offset(svalue);
unset = ((svalue->flags != KV_RS) && (value_size == SVALUE_HEADER_SIZE + ext_data_offset));

update_arg.owner = svalue->data;
update_arg.res = common_ctx->kv_store_res;
update_arg.ret_code = 0;
update_arg.owner = svalue->data;
update_arg.res = common_ctx->kv_store_res;
update_arg.ret_code = 0;

log_debug(ID(res), syncing_msg, key, unset ? "NULL" : svalue->data + ext_data_offset, svalue->seqnum);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_bptree.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void verify_node(bptree_t *bptree,
*bkey = n->bkeys[i];
assert_true((*bkey)->ref_count == ref);
*meta_size += sizeof(bptree_key_t) + strlen((*bkey)->key) + 1 + sizeof(bptree_record_t);
rec = n->pointers[i];
rec = n->pointers[i];
assert_true(rec->ref_count > 0);
*data_size += rec->data_size;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_kv_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ static size_t add_sequential_test_data(char *key,
int strlen = snprintf(NULL, 0, "%d", i);
char *str = malloc(strlen + 1);
snprintf(str, strlen + 1, "%d", i);
test_iov[i].iov_base = str;
test_iov[i].iov_len = strlen + 1;
test_iov[i].iov_base = str;
test_iov[i].iov_len = strlen + 1;
size += strlen + 1;
}
assert_ptr_not_equal(kv_store_set_value(kv_store_res, MERGE_KEY, test_iov, MAX_TEST_ENTRIES, flags, op_flags, NULL, NULL),
Expand Down

0 comments on commit aa6bedf

Please sign in to comment.