*: Fix linter errors

Also adds one exception to linter rules:

    typedef struct {
      kvec_t(Object) stack;
    } EncodedData;

is completely valid (from the style guide point of view) code.
This commit is contained in:
ZyX
2016-06-24 17:16:11 +03:00
parent 50f5bb8ade
commit 458a4d0444
7 changed files with 21 additions and 20 deletions

View File

@@ -2515,7 +2515,8 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
'after the hash') 'after the hash')
cast_line = re.sub(r'^# *define +\w+\([^)]*\)', '', line) cast_line = re.sub(r'^# *define +\w+\([^)]*\)', '', line)
match = Search(r'\((?:const )?(?:struct )?[a-zA-Z_]\w*(?: *\*(?:const)?)*\)' match = Search(r'(?<!\bkvec_t)'
r'\((?:const )?(?:struct )?[a-zA-Z_]\w*(?: *\*(?:const)?)*\)'
r' +' r' +'
r'-?(?:\*+|&)?(?:\w+|\+\+|--|\()', cast_line) r'-?(?:\*+|&)?(?:\w+|\+\+|--|\()', cast_line)
if match and line[0] == ' ': if match and line[0] == ' ':

View File

@@ -323,20 +323,20 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
kv_push(edata->stack, NIL) kv_push(edata->stack, NIL)
#define TYPVAL_ENCODE_CONV_BOOL(num) \ #define TYPVAL_ENCODE_CONV_BOOL(num) \
kv_push(edata->stack, BOOLEAN_OBJ((Boolean) (num))) kv_push(edata->stack, BOOLEAN_OBJ((Boolean)(num)))
#define TYPVAL_ENCODE_CONV_NUMBER(num) \ #define TYPVAL_ENCODE_CONV_NUMBER(num) \
kv_push(edata->stack, INTEGER_OBJ((Integer) (num))) kv_push(edata->stack, INTEGER_OBJ((Integer)(num)))
#define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER TYPVAL_ENCODE_CONV_NUMBER #define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER TYPVAL_ENCODE_CONV_NUMBER
#define TYPVAL_ENCODE_CONV_FLOAT(flt) \ #define TYPVAL_ENCODE_CONV_FLOAT(flt) \
kv_push(edata->stack, FLOATING_OBJ((Float) (flt))) kv_push(edata->stack, FLOATING_OBJ((Float)(flt)))
#define TYPVAL_ENCODE_CONV_STRING(str, len) \ #define TYPVAL_ENCODE_CONV_STRING(str, len) \
do { \ do { \
const size_t len_ = (size_t) (len); \ const size_t len_ = (size_t)(len); \
const char *const str_ = (const char *) (str); \ const char *const str_ = (const char *)(str); \
assert(len_ == 0 || str_ != NULL); \ assert(len_ == 0 || str_ != NULL); \
kv_push(edata->stack, STRING_OBJ(((String) { \ kv_push(edata->stack, STRING_OBJ(((String) { \
.data = xmemdupz((len_?str_:""), len_), \ .data = xmemdupz((len_?str_:""), len_), \
@@ -372,7 +372,7 @@ static inline void typval_encode_list_start(EncodedData *const edata,
} }
#define TYPVAL_ENCODE_CONV_LIST_START(len) \ #define TYPVAL_ENCODE_CONV_LIST_START(len) \
typval_encode_list_start(edata, (size_t) (len)) typval_encode_list_start(edata, (size_t)(len))
static inline void typval_encode_between_list_items(EncodedData *const edata) static inline void typval_encode_between_list_items(EncodedData *const edata)
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL
@@ -413,7 +413,7 @@ static inline void typval_encode_dict_start(EncodedData *const edata,
} }
#define TYPVAL_ENCODE_CONV_DICT_START(len) \ #define TYPVAL_ENCODE_CONV_DICT_START(len) \
typval_encode_dict_start(edata, (size_t) (len)) typval_encode_dict_start(edata, (size_t)(len))
#define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, kv_pair) #define TYPVAL_ENCODE_CONV_SPECIAL_DICT_KEY_CHECK(label, kv_pair)

View File

@@ -18162,7 +18162,7 @@ void free_tv(typval_T *varp)
#define TYPVAL_ENCODE_CONV_NUMBER(ignored) \ #define TYPVAL_ENCODE_CONV_NUMBER(ignored) \
do { \ do { \
(void) ignored; \ (void)ignored; \
tv->vval.v_number = 0; \ tv->vval.v_number = 0; \
tv->v_lock = VAR_UNLOCKED; \ tv->v_lock = VAR_UNLOCKED; \
} while (0) } while (0)

View File

@@ -157,7 +157,7 @@ typedef struct list_stack_S {
/// Convert a hashitem value pointer to a dictitem pointer /// Convert a hashitem value pointer to a dictitem pointer
#define HIVAL2DI(p) \ #define HIVAL2DI(p) \
((dictitem_T *)(((char *) p) - offsetof(dictitem_T, di_tv))) ((dictitem_T *)(((char *)p) - offsetof(dictitem_T, di_tv)))
/// Convert a hashitem pointer to a dictitem pointer /// Convert a hashitem pointer to a dictitem pointer
#define HI2DI(hi) HIKEY2DI((hi)->hi_key) #define HI2DI(hi) HIKEY2DI((hi)->hi_key)

View File

@@ -857,8 +857,8 @@ static void log_server_msg(uint64_t channel_id,
log_msg_close(f, (msgpack_object) { log_msg_close(f, (msgpack_object) {
.type = MSGPACK_OBJECT_STR, .type = MSGPACK_OBJECT_STR,
.via.str = { .via.str = {
.ptr = (char *) msgpack_error_messages[result + MUR_OFF], .ptr = (char *)msgpack_error_messages[result + MUR_OFF],
.size = (uint32_t) strlen( .size = (uint32_t)strlen(
msgpack_error_messages[result + MUR_OFF]), msgpack_error_messages[result + MUR_OFF]),
}, },
}); });

View File

@@ -109,7 +109,7 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg)
if (cur.mobj->via.u64 > API_INTEGER_MAX) { if (cur.mobj->via.u64 > API_INTEGER_MAX) {
ret = false; ret = false;
} else { } else {
*cur.aobj = INTEGER_OBJ((Integer) cur.mobj->via.u64); *cur.aobj = INTEGER_OBJ((Integer)cur.mobj->via.u64);
} }
break; break;
} }
@@ -135,7 +135,7 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg)
const size_t size = cur.mobj->via.array.size; const size_t size = cur.mobj->via.array.size;
if (cur.container) { if (cur.container) {
if (cur.idx >= size) { if (cur.idx >= size) {
(void) kv_pop(stack); (void)kv_pop(stack);
} else { } else {
const size_t idx = cur.idx; const size_t idx = cur.idx;
cur.idx++; cur.idx++;
@@ -163,7 +163,7 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg)
const size_t size = cur.mobj->via.map.size; const size_t size = cur.mobj->via.map.size;
if (cur.container) { if (cur.container) {
if (cur.idx >= size) { if (cur.idx >= size) {
(void) kv_pop(stack); (void)kv_pop(stack);
} else { } else {
const size_t idx = cur.idx; const size_t idx = cur.idx;
cur.idx++; cur.idx++;
@@ -232,7 +232,7 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg)
#undef STR_CASE #undef STR_CASE
} }
if (!cur.container) { if (!cur.container) {
(void) kv_pop(stack); (void)kv_pop(stack);
} }
} }
kv_destroy(stack); kv_destroy(stack);
@@ -384,7 +384,7 @@ void msgpack_rpc_from_object(const Object result, msgpack_packer *const res)
const size_t size = cur.aobj->data.array.size; const size_t size = cur.aobj->data.array.size;
if (cur.container) { if (cur.container) {
if (cur.idx >= size) { if (cur.idx >= size) {
(void) kv_pop(stack); (void)kv_pop(stack);
} else { } else {
const size_t idx = cur.idx; const size_t idx = cur.idx;
cur.idx++; cur.idx++;
@@ -405,7 +405,7 @@ void msgpack_rpc_from_object(const Object result, msgpack_packer *const res)
const size_t size = cur.aobj->data.dictionary.size; const size_t size = cur.aobj->data.dictionary.size;
if (cur.container) { if (cur.container) {
if (cur.idx >= size) { if (cur.idx >= size) {
(void) kv_pop(stack); (void)kv_pop(stack);
} else { } else {
const size_t idx = cur.idx; const size_t idx = cur.idx;
cur.idx++; cur.idx++;
@@ -426,7 +426,7 @@ void msgpack_rpc_from_object(const Object result, msgpack_packer *const res)
} }
} }
if (!cur.container) { if (!cur.container) {
(void) kv_pop(stack); (void)kv_pop(stack);
} }
} }
kv_destroy(stack); kv_destroy(stack);

View File

@@ -4656,7 +4656,7 @@ set_option_value (
return NULL; return NULL;
} }
if (flags & P_STRING) { if (flags & P_STRING) {
const char *s = (char *) string; const char *s = (const char *)string;
if (s == NULL) { if (s == NULL) {
s = ""; s = "";
} }