Skip to content

Commit

Permalink
build UPDATE uncrustify version 0.71 -> 0.75
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed Aug 2, 2022
1 parent f60d178 commit 26bbb27
Show file tree
Hide file tree
Showing 53 changed files with 567 additions and 3,407 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
shell: bash
working-directory: ${{ github.workspace }}
run: |
git clone --branch uncrustify-0.71.0 https://github.com/uncrustify/uncrustify
git clone --branch uncrustify-0.75.1 https://github.com/uncrustify/uncrustify
cd uncrustify
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ endif()

if ("${BUILD_TYPE_UPPER}" STREQUAL "DEBUG")
# enable before adding tests to let them detect that format checking is available - one of the tests is format checking
source_format_enable()
source_format_enable(0.75)
endif()

# generate files
Expand Down
6 changes: 5 additions & 1 deletion CMakeModules/SourceFormat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

# check that format checking is available - always use before SOURCE_FORMAT
macro(SOURCE_FORMAT_ENABLE)
find_package(Uncrustify 0.71)
if(NOT ${ARGC} EQUAL 1)
message(FATAL_ERROR "source_format_enable() needs the required Uncrustify version!")
endif()

find_package(Uncrustify ${ARGV0})
if(UNCRUSTIFY_FOUND)
set(SOURCE_FORMAT_ENABLED TRUE)
else()
Expand Down
1 change: 1 addition & 0 deletions compat/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ setenv(const char *name, const char *value, int overwrite)

if (!overwrite) {
size_t envsize = 0;

errcode = getenv_s(&envsize, NULL, 0, name);
if (errcode || envsize) {
return errcode;
Expand Down
1 change: 1 addition & 0 deletions compat/strptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ strptime(const char * restrict s, const char * restrict f, struct tm * restrict
}
if (isdigit(*f)) {
char *new_f;

w = strtoul(f, &new_f, 10);
f = new_f;
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,12 +614,14 @@ lysc_node_clear_all_priv(struct lys_module *mod)
*/
if (mod->parsed) {
struct lysp_ext_instance *exts_p;

exts_p = mod->parsed->exts;
LY_ARRAY_FOR(exts_p, u) {
if (exts_p[u].parsed) {
/* lys_compile_extension_instance() was called */
struct lysc_ext_substmt *substmts;
struct lysc_node *root;

/* set NULL for all ::lysc_node.priv pointers in extensions */
substmts = mod->compiled->exts[u].substmts;
LY_ARRAY_FOR(substmts, v) {
Expand Down
2 changes: 2 additions & 0 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ lyd_diff_apply_r(struct lyd_node **first_node, struct lyd_node *parent_node, con
LY_CHECK_ERR_RET(ret && (ret != LY_EEXIST), LOGERR_UNEXPVAL(ctx, match, "data"), LY_EINVAL);
} else {
struct lyd_node_any *any = (struct lyd_node_any *)diff_node;

LY_CHECK_RET(lyd_any_copy_value(match, &any->value, any->value_type));
}

Expand Down Expand Up @@ -1936,6 +1937,7 @@ lyd_diff_reverse_value(struct lyd_node *node, const struct lys_module *mod)
LY_CHECK_GOTO(ret = lyd_change_term(node, val1), cleanup);
} else {
union lyd_any_value anyval = {.str = val1};

LY_CHECK_GOTO(ret = lyd_any_copy_value(node, &anyval, LYD_ANYDATA_STRING), cleanup);
}
node->flags = flags;
Expand Down
1 change: 1 addition & 0 deletions src/hash_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ lyht_resize(struct hash_table *ht, int operation)
rec = lyht_get_rec(old_recs, ht->rec_size, i);
if (rec->hits > 0) {
LY_ERR ret = lyht_insert(ht, rec->val, rec->hash, NULL);

assert(!ret);
(void)ret;
}
Expand Down
2 changes: 2 additions & 0 deletions src/in_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ struct ly_in {
const char *func_start; /**< Input data position when the last parser function was executed */
const char *start; /**< Input data start */
size_t length; /**< mmap() length (if used) */

union {
int fd; /**< file descriptor for LY_IN_FD type */
FILE *f; /**< file structure for LY_IN_FILE and LY_IN_FILEPATH types */

struct {
int fd; /**< file descriptor for LY_IN_FILEPATH */
char *filepath; /**< stored original filepath */
Expand Down
1 change: 1 addition & 0 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ ly_log_location(const struct lysc_node *scnode, const struct lyd_node *dnode, co

if (path) {
char *s = strdup(path);

LY_CHECK_ERR_RET(!s, LOGMEM(NULL), );
ly_set_add(&log_location.paths, s, 1, NULL);
} else if (reset) {
Expand Down
3 changes: 1 addition & 2 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ typedef uint8_t ly_bool;
* @typedef LY_LOG_LEVEL
* @brief Verbosity levels of the libyang logger.
*/
typedef enum
{
typedef enum {
LY_LLERR = 0, /**< Print only error messages. */
LY_LLWRN = 1, /**< Print error and warning messages, default value. */
LY_LLVRB = 2, /**< Besides errors and warnings, print some other verbose messages. */
Expand Down
2 changes: 2 additions & 0 deletions src/out.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ ly_write_(struct ly_out *out, const char *buf, size_t len)
break;
case LY_OUT_FD: {
ssize_t r;

r = write(out->method.fd, buf, len);
if (r < 0) {
ret = LY_ESYS;
Expand All @@ -608,6 +609,7 @@ ly_write_(struct ly_out *out, const char *buf, size_t len)
break;
case LY_OUT_CALLBACK: {
ssize_t r;

r = out->method.clb.func(out->method.clb.arg, buf, len);
if (r < 0) {
ret = LY_ESYS;
Expand Down
2 changes: 2 additions & 0 deletions src/out_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ struct lyd_node;
*/
struct ly_out {
LY_OUT_TYPE type; /**< type of the output to select the output method */

union {
int fd; /**< file descriptor for LY_OUT_FD type */
FILE *f; /**< file structure for LY_OUT_FILE, LY_OUT_FDSTREAM and LY_OUT_FILEPATH types */

struct {
FILE *f; /**< file stream from the original file descriptor, variable is mapped to the LY_OUT_FILE's f */
int fd; /**< original file descriptor, which was not used directly because of missing vdprintf() */
Expand Down
2 changes: 2 additions & 0 deletions src/parser_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct lyd_ctx {
uint32_t val_opts; /**< various @ref datavalidationoptions. */
uint32_t int_opts; /**< internal parser options */
uint32_t path_len; /**< used bytes in the path buffer */

#define LYD_PARSER_BUFSIZE 4078
char path[LYD_PARSER_BUFSIZE]; /**< buffer for the generated path */
struct ly_set node_when; /**< set of nodes with "when" conditions */
Expand Down Expand Up @@ -120,6 +121,7 @@ struct lyd_json_ctx {
*/
struct lyd_lyb_ctx {
const struct lysc_ext_instance *ext;

union {
struct {
uint32_t parse_opts;
Expand Down
9 changes: 9 additions & 0 deletions src/parser_yin.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,27 +355,31 @@ subelems_allocator(struct lys_yin_parser_ctx *ctx, size_t count, struct lysp_nod
/* DEST */
if (IS_NODE_ELEM((*result)[i].type)) {
struct tree_node_meta *node_meta = NULL;

node_meta = calloc(1, sizeof *node_meta);
LY_CHECK_GOTO(!node_meta, mem_err);
node_meta->parent = parent;
node_meta->nodes = va_arg(ap, void *);
(*result)[i].dest = node_meta;
} else if ((*result)[i].type == LY_STMT_IMPORT) {
struct import_meta *imp_meta = NULL;

imp_meta = calloc(1, sizeof *imp_meta);
LY_CHECK_GOTO(!imp_meta, mem_err);
imp_meta->prefix = va_arg(ap, const char *);
imp_meta->imports = va_arg(ap, struct lysp_import **);
(*result)[i].dest = imp_meta;
} else if ((*result)[i].type == LY_STMT_INCLUDE) {
struct include_meta *inc_meta = NULL;

inc_meta = calloc(1, sizeof *inc_meta);
LY_CHECK_GOTO(!inc_meta, mem_err);
inc_meta->name = va_arg(ap, const char *);
inc_meta->includes = va_arg(ap, struct lysp_include **);
(*result)[i].dest = inc_meta;
} else if (((*result)[i].type == LY_STMT_INPUT) || ((*result)[i].type == LY_STMT_OUTPUT)) {
struct inout_meta *inout_meta = NULL;

inout_meta = calloc(1, sizeof *inout_meta);
LY_CHECK_GOTO(!inout_meta, mem_err);
inout_meta->parent = parent;
Expand Down Expand Up @@ -1250,6 +1254,7 @@ yin_parse_type(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct yin_s
/* type as child of another type */
if (parent == LY_STMT_TYPE) {
struct lysp_type *nested_type = NULL;

LY_ARRAY_NEW_RET(ctx->xmlctx->ctx, type->types, nested_type, LY_EMEM);
type->flags |= LYS_SET_TYPE;
type = nested_type;
Expand Down Expand Up @@ -2691,6 +2696,7 @@ yin_parse_deviate(struct lys_yin_parser_ctx *ctx, struct lysp_deviate **deviates
struct yin_subelement subelems[] = {
{LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};

ret = yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_DEVIATE, NULL, &d->exts);

} else if (dev_mod == LYS_DEV_ADD) {
Expand All @@ -2710,6 +2716,7 @@ yin_parse_deviate(struct lys_yin_parser_ctx *ctx, struct lysp_deviate **deviates
{LY_STMT_UNITS, &d_add->units, YIN_SUBELEM_UNIQUE},
{LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};

ret = yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_DEVIATE, NULL, &d_add->exts);

} else if (dev_mod == LYS_DEV_REPLACE) {
Expand All @@ -2728,6 +2735,7 @@ yin_parse_deviate(struct lys_yin_parser_ctx *ctx, struct lysp_deviate **deviates
{LY_STMT_UNITS, &d_rpl->units, YIN_SUBELEM_UNIQUE},
{LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};

ret = yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_DEVIATE, NULL, &d_rpl->exts);

} else {
Expand All @@ -2741,6 +2749,7 @@ yin_parse_deviate(struct lys_yin_parser_ctx *ctx, struct lysp_deviate **deviates
{LY_STMT_UNITS, &d_del->units, YIN_SUBELEM_UNIQUE},
{LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};

ret = yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_DEVIATE, NULL, &d_del->exts);
}
LY_CHECK_GOTO(ret, cleanup);
Expand Down
1 change: 1 addition & 0 deletions src/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum ly_path_pred_type {
struct ly_path_predicate {
union {
uint64_t position; /**< position value for the position-predicate */

struct {
const struct lysc_node *key; /**< key node of the predicate, NULL in
case of a leaf-list predicate */
Expand Down
1 change: 1 addition & 0 deletions src/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ plugins_load(void *dlhandler, const char *pathname, enum LYPLG type)
/* ... get types plugins information ... */
if (!(plugins = dlsym(dlhandler, plugins_load_info[type].plugins_var))) {
char *errstr = dlerror();

LOGERR(NULL, LY_EINVAL, "Processing user %s plugin \"%s\" failed, missing %s plugins information (%s).",
plugins_load_info[type].id, pathname, plugins_load_info[type].id, errstr);
return LY_EINVAL;
Expand Down
5 changes: 5 additions & 0 deletions src/plugins_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ lyplg_type_parse_dec64(uint8_t fraction_digits, const char *value, size_t value_
if (len + trailing_zeros < value_len) {
/* consume trailing whitespaces to check that there is nothing after it */
uint64_t u;

for (u = len + trailing_zeros; u < value_len && isspace(value[u]); ++u) {}
if (u != value_len) {
return ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL,
Expand Down Expand Up @@ -531,6 +532,7 @@ lyplg_type_validate_range(LY_DATA_TYPE basetype, struct lysc_range *range, int64
/* unsigned */
if ((uint64_t)value < range->parts[u].min_u64) {
char *eapptag = range->eapptag ? strdup(range->eapptag) : NULL;

if (range->emsg) {
return ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, eapptag, "%s", range->emsg);
} else {
Expand All @@ -543,6 +545,7 @@ lyplg_type_validate_range(LY_DATA_TYPE basetype, struct lysc_range *range, int64
} else if (u == LY_ARRAY_COUNT(range->parts) - 1) {
/* we have the last range part, so the value is out of bounds */
char *eapptag = range->eapptag ? strdup(range->eapptag) : NULL;

if (range->emsg) {
return ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, eapptag, "%s", range->emsg);
} else {
Expand All @@ -554,6 +557,7 @@ lyplg_type_validate_range(LY_DATA_TYPE basetype, struct lysc_range *range, int64
/* signed */
if (value < range->parts[u].min_64) {
char *eapptag = range->eapptag ? strdup(range->eapptag) : NULL;

if (range->emsg) {
return ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, eapptag, "%s", range->emsg);
} else {
Expand All @@ -565,6 +569,7 @@ lyplg_type_validate_range(LY_DATA_TYPE basetype, struct lysc_range *range, int64
} else if (u == LY_ARRAY_COUNT(range->parts) - 1) {
/* we have the last range part, so the value is out of bounds */
char *eapptag = range->eapptag ? strdup(range->eapptag) : NULL;

if (range->emsg) {
return ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, eapptag, "%s", range->emsg);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins_types/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ binary_base64_decode(const char *value, size_t value_len, void **data, size_t *s

for (uint32_t i = 0, j = 0; i < octet_count; i += 4) {
int n = b64_dtable[ptr[i]] << 18 | b64_dtable[ptr[i + 1]] << 12 | b64_dtable[ptr[i + 2]] << 6 | b64_dtable[ptr[i + 3]];

str[j++] = n >> 16;
str[j++] = n >> 8 & 0xFF;
str[j++] = n & 0xFF;
}
if (pad_chars) {
int n = b64_dtable[ptr[octet_count]] << 18 | b64_dtable[ptr[octet_count + 1]] << 12;

str[*size - pad_chars] = n >> 16;

if (pad_chars == 2) {
Expand Down Expand Up @@ -205,6 +207,7 @@ binary_base64_validate(const char *value, size_t value_len, const struct lysc_ty
/* length restriction of the binary value */
if (type->length) {
const uint32_t octet_count = ((idx + pad) / 4) * 3 - pad;

LY_CHECK_RET(lyplg_type_validate_range(LY_TYPE_BINARY, type->length, octet_count, value, value_len, err));
}

Expand Down
1 change: 1 addition & 0 deletions src/plugins_types/decimal64.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ decimal64_num2str(int64_t num, struct lysc_type_dec *type, char **str)

if (num) {
int count = sprintf(ret, "%" PRId64 " ", num);

if (((num > 0) && ((count - 1) <= type->fraction_digits)) || ((count - 2) <= type->fraction_digits)) {
/* we have 0. value, print the value with the leading zeros
* (one for 0. and also keep the correct with of num according
Expand Down
3 changes: 3 additions & 0 deletions src/printer_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ matching_node(const struct lyd_node *node1, const struct lyd_node *node2)
/* compare node names */
struct lyd_node_opaq *onode1 = (struct lyd_node_opaq *)node1;
struct lyd_node_opaq *onode2 = (struct lyd_node_opaq *)node2;

if ((onode1->name.name != onode2->name.name) || (onode1->name.prefix != onode2->name.prefix)) {
return 0;
}
Expand Down Expand Up @@ -197,6 +198,7 @@ json_nscmp(const struct lyd_node *node1, const struct lyd_node *node2)
} else {
const char *pref1 = node_prefix(node1);
const char *pref2 = node_prefix(node2);

if ((pref1 && pref2) && (pref1 == pref2)) {
return 0;
} else {
Expand Down Expand Up @@ -224,6 +226,7 @@ json_print_string(struct ly_out *out, const char *text)
ly_write_(out, "\"", 1);
for (i = n = 0; text[i]; i++) {
const unsigned char ascii = text[i];

if (ascii < 0x20) {
/* control character */
ly_print_(out, "\\u%.4X", ascii);
Expand Down
2 changes: 2 additions & 0 deletions src/printer_lyb.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ lyb_hash_sequence_check(struct hash_table *ht, struct lysc_node *sibling, LYB_HA
lyht_set_cb(ht, lyb_ptr_equal_cb);
do {
int64_t j;

for (j = (int64_t)compare_col_id; j > -1; --j) {
if (lyb_get_hash(sibling, j) != lyb_get_hash(*col_node, j)) {
/* one non-colliding hash */
Expand Down Expand Up @@ -145,6 +146,7 @@ lyb_hash_siblings(struct lysc_node *sibling, struct hash_table **ht_p)
for (i = 0; i < LYB_HASH_BITS; ++i) {
/* check that we are not colliding with nodes inserted with a lower collision ID than ours */
int64_t j;

for (j = (int64_t)i - 1; j > -1; --j) {
if (lyb_hash_sequence_check(ht, sibling, (LYB_HASH)j, i)) {
break;
Expand Down
Loading

0 comments on commit 26bbb27

Please sign in to comment.