libyang REFACTOR add more compiler printf attributes
Some bugs fixed because of the new warnings.
diff --git a/src/common.c b/src/common.c
index f3b1d6b..806a016 100644
--- a/src/common.c
+++ b/src/common.c
@@ -338,10 +338,10 @@
return len;
}
-size_t
+int
LY_VCODE_INSTREXP_len(const char *str)
{
- size_t len = 0;
+ int len = 0;
if (!str) {
return len;
diff --git a/src/common.h b/src/common.h
index 8364b21..4009f3c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -87,7 +87,7 @@
* @param[in] no Error type code.
* @param[in] format Format string to print.
*/
-void ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, const char *format, ...);
+void ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, const char *format, ...) _FORMAT_PRINTF(4, 5);
/**
* @brief Print Validation error and store it into the context (if provided).
@@ -97,7 +97,7 @@
* @param[in] code Validation error code.
* @param[in] format Format string to print.
*/
-void ly_vlog(const struct ly_ctx *ctx, const char *apptag, LY_VECODE code, const char *format, ...);
+void ly_vlog(const struct ly_ctx *ctx, const char *apptag, LY_VECODE code, const char *format, ...) _FORMAT_PRINTF(4, 5);
/**
* @brief Move error items from source to target context replacing any previous ones.
@@ -234,7 +234,8 @@
DUMMY) (CTX, __VA_ARGS__)
/* count sequence size for LY_VCODE_INCHILDSTMT validation error code */
-size_t LY_VCODE_INSTREXP_len(const char *str);
+int LY_VCODE_INSTREXP_len(const char *str);
+
/* default maximum characters to print in LY_VCODE_INCHILDSTMT */
#define LY_VCODE_INSTREXP_MAXLEN 20
@@ -457,7 +458,8 @@
* If no string remains, it is set to NULL.
* @return LY_ERR value.
*/
-LY_ERR ly_value_prefix_next(const char *str_begin, const char *str_end, uint32_t *len, ly_bool *is_prefix, const char **str_next);
+LY_ERR ly_value_prefix_next(const char *str_begin, const char *str_end, uint32_t *len, ly_bool *is_prefix,
+ const char **str_next);
/**
* @brief Wrapper around strlen() to handle NULL strings.
@@ -647,6 +649,6 @@
* @param[in] format Formating string (as for printf) which is supposed to be added after @p dest.
* @return LY_SUCCESS or LY_EMEM.
*/
-LY_ERR ly_strcat(char **dest, const char *format, ...);
+LY_ERR ly_strcat(char **dest, const char *format, ...) _FORMAT_PRINTF(2, 3);
#endif /* LY_COMMON_H_ */
diff --git a/src/out.c b/src/out.c
index 5567387..a2054cd 100644
--- a/src/out.c
+++ b/src/out.c
@@ -630,9 +630,9 @@
}
LOGERR(NULL, LY_ESYS, "%s: writing data failed (%s).", __func__, strerror(errno));
written = 0;
- } else if ((size_t)written != len) {
- LOGERR(NULL, LY_ESYS, "%s: writing data failed (unable to write %u from %u data).", __func__,
- len - (size_t)written, len);
+ } else if (written != len) {
+ LOGERR(NULL, LY_ESYS, "%s: writing data failed (unable to write %" PRIu32 " from %" PRIu32 " data).", __func__,
+ (uint32_t)(len - written), (uint32_t)len);
ret = LY_ESYS;
} else {
if (out->type == LY_OUT_FDSTREAM) {
diff --git a/src/parser_common.c b/src/parser_common.c
index 693ca65..a859925 100644
--- a/src/parser_common.c
+++ b/src/parser_common.c
@@ -667,7 +667,7 @@
static LY_ERR
lysp_stmt_status(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint16_t *flags, struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
if (*flags & LYS_STATUS_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "status");
@@ -760,7 +760,7 @@
static LY_ERR
lysp_stmt_config(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint16_t *flags, struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
if (*flags & LYS_CONFIG_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "config");
@@ -806,7 +806,7 @@
lysp_stmt_mandatory(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint16_t *flags,
struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
if (*flags & LYS_MAND_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "mandatory");
@@ -976,7 +976,7 @@
lysp_stmt_type_enum_value_pos(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, int64_t *value, uint16_t *flags,
struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
char *ptr = NULL;
long long num = 0;
unsigned long long unum = 0;
@@ -1011,7 +1011,7 @@
}
}
/* we have not parsed the whole argument */
- if ((size_t)(ptr - stmt->arg) != arg_len) {
+ if (ptr - stmt->arg != arg_len) {
LOGVAL_PARSER(ctx, LY_VCODE_INVAL, arg_len, stmt->arg, lyplg_ext_stmt2str(stmt->kw));
goto error;
}
@@ -1118,7 +1118,7 @@
struct lysp_ext_instance **exts)
{
char *ptr;
- size_t arg_len;
+ int arg_len;
unsigned long long num;
if (*fracdig) {
@@ -1136,7 +1136,7 @@
errno = 0;
num = strtoull(stmt->arg, &ptr, LY_BASE_DEC);
/* we have not parsed the whole argument */
- if ((size_t)(ptr - stmt->arg) != arg_len) {
+ if (ptr - stmt->arg != arg_len) {
LOGVAL_PARSER(ctx, LY_VCODE_INVAL, arg_len, stmt->arg, "fraction-digits");
return LY_EVALID;
}
@@ -1174,7 +1174,7 @@
lysp_stmt_type_reqinstance(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint8_t *reqinst, uint16_t *flags,
struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
if (*flags & LYS_SET_REQINST) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "require-instance");
@@ -1217,7 +1217,7 @@
lysp_stmt_type_pattern_modifier(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, const char **pat,
struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
char *buf;
if ((*pat)[0] == LYSP_RESTR_PATTERN_NACK) {
@@ -1400,7 +1400,7 @@
} else if (!strcmp(stmt->arg, "1.1")) {
*version = LYS_VERSION_1_1;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, strlen(stmt->arg), stmt->arg, "yang-version");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)strlen(stmt->arg), stmt->arg, "yang-version");
return LY_EVALID;
}
@@ -1480,7 +1480,7 @@
} else if (!strcmp(stmt->arg, "false")) {
*flags |= LYS_YINELEM_FALSE;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, strlen(stmt->arg), stmt->arg, "yin-element");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)strlen(stmt->arg), stmt->arg, "yin-element");
return LY_EVALID;
}
@@ -2008,7 +2008,7 @@
lysp_stmt_maxelements(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint32_t *max, uint16_t *flags,
struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
char *ptr;
unsigned long long num;
@@ -2031,7 +2031,7 @@
errno = 0;
num = strtoull(stmt->arg, &ptr, LY_BASE_DEC);
/* we have not parsed the whole argument */
- if ((size_t)(ptr - stmt->arg) != arg_len) {
+ if (ptr - stmt->arg != arg_len) {
LOGVAL_PARSER(ctx, LY_VCODE_INVAL, arg_len, stmt->arg, "max-elements");
return LY_EVALID;
}
@@ -2074,7 +2074,7 @@
lysp_stmt_minelements(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint32_t *min, uint16_t *flags,
struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
char *ptr;
unsigned long long num;
@@ -2096,7 +2096,7 @@
errno = 0;
num = strtoull(stmt->arg, &ptr, LY_BASE_DEC);
/* we have not parsed the whole argument */
- if ((size_t)(ptr - stmt->arg) != arg_len) {
+ if (ptr - stmt->arg != arg_len) {
LOGVAL_PARSER(ctx, LY_VCODE_INVAL, arg_len, stmt->arg, "min-elements");
return LY_EVALID;
}
@@ -2132,7 +2132,7 @@
static LY_ERR
lysp_stmt_orderedby(struct lysp_ctx *ctx, const struct lysp_stmt *stmt, uint16_t *flags, struct lysp_ext_instance **exts)
{
- size_t arg_len;
+ int arg_len;
if (*flags & LYS_ORDBY_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "ordered-by");
diff --git a/src/parser_xml.c b/src/parser_xml.c
index fb1b50e..225fe15 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -396,7 +396,7 @@
if ((*snode)->nodetype & LYD_NODE_TERM) {
/* value may not be valid in which case we parse it as an opaque node */
if (ly_value_validate(NULL, *snode, xmlctx->value, xmlctx->value_len, LY_VALUE_XML, &xmlctx->ns, LYD_HINT_DATA)) {
- LOGVRB("Parsing opaque term node \"%s\" with invalid value \"%.*s\".", (*snode)->name, xmlctx->value_len,
+ LOGVRB("Parsing opaque term node \"%s\" with invalid value \"%.*s\".", (*snode)->name, (int)xmlctx->value_len,
xmlctx->value);
*snode = NULL;
}
@@ -557,7 +557,13 @@
unknown_module:
if (lydctx->parse_opts & LYD_PARSE_STRICT) {
- LOGVAL(ctx, LYVE_REFERENCE, "No module with namespace \"%s\" in the context.", ns->uri);
+ if (ns) {
+ LOGVAL(ctx, LYVE_REFERENCE, "No module with namespace \"%s\" in the context.", ns->uri);
+ } else if (prefix_len) {
+ LOGVAL(ctx, LYVE_REFERENCE, "No module with namespace \"%.*s\" in the context.", (int)prefix_len, prefix);
+ } else {
+ LOGVAL(ctx, LYVE_REFERENCE, "No default namespace in the context.");
+ }
return LY_EVALID;
}
return LY_SUCCESS;
@@ -862,7 +868,7 @@
if ((snode->nodetype == LYS_ANYDATA) && !xmlctx->ws_only) {
/* value in anydata node, we expect a tree */
LOGVAL(xmlctx->ctx, LYVE_SYNTAX, "Text value \"%.*s\" inside an anydata node \"%s\" found.",
- (int)xmlctx->value_len < 20 ? xmlctx->value_len : 20, xmlctx->value, snode->name);
+ xmlctx->value_len < 20 ? (int)xmlctx->value_len : 20, xmlctx->value, snode->name);
r = LY_EVALID;
LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);
}
@@ -983,7 +989,7 @@
}
goto cleanup;
} else if (!snode && !(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
- LOGVRB("Skipping parsing of unknown node \"%.*s\".", name_len, name);
+ LOGVRB("Skipping parsing of unknown node \"%.*s\".", (int)name_len, name);
/* skip element with children */
rc = lydxml_data_skip(xmlctx);
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 03131da..49ea8b7 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -934,7 +934,8 @@
LY_ARRAY_NEW_RET(PARSER_CTX(ctx), *exts, e, LY_EMEM);
if (!ly_strnchr(ext_name, ':', ext_name_len)) {
- LOGVAL_PARSER(ctx, LYVE_SYNTAX, "Extension instance \"%*.s\" without the mandatory prefix.", ext_name_len, ext_name);
+ LOGVAL_PARSER(ctx, LYVE_SYNTAX, "Extension instance \"%.*s\" without the mandatory prefix.",
+ (int)ext_name_len, ext_name);
return LY_EVALID;
}
@@ -1041,7 +1042,7 @@
} else if ((word_len == ly_strlen_const("1.1")) && !strncmp(word, "1.1", word_len)) {
mod->version = LYS_VERSION_1_1;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "yang-version");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "yang-version");
free(buf);
return LY_EVALID;
}
@@ -1452,7 +1453,7 @@
} else if ((word_len == ly_strlen_const("false")) && !strncmp(word, "false", word_len)) {
*flags |= LYS_CONFIG_R;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "config");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "config");
free(buf);
return LY_EVALID;
}
@@ -1503,7 +1504,7 @@
} else if ((word_len == ly_strlen_const("false")) && !strncmp(word, "false", word_len)) {
*flags |= LYS_MAND_FALSE;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "mandatory");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "mandatory");
free(buf);
return LY_EVALID;
}
@@ -1624,7 +1625,7 @@
} else if ((word_len == ly_strlen_const("obsolete")) && !strncmp(word, "obsolete", word_len)) {
*flags |= LYS_STATUS_OBSLT;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "status");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "status");
free(buf);
return LY_EVALID;
}
@@ -1805,7 +1806,7 @@
LY_CHECK_RET(get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len));
if (!word_len || (word[0] == '+') || ((word[0] == '0') && (word_len > 1)) || ((val_kw == LY_STMT_POSITION) && !strncmp(word, "-0", 2))) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, lyplg_ext_stmt2str(val_kw));
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, lyplg_ext_stmt2str(val_kw));
ret = LY_EVALID;
goto cleanup;
}
@@ -1814,26 +1815,26 @@
if (val_kw == LY_STMT_VALUE) {
num = strtoll(word, &ptr, LY_BASE_DEC);
if ((num < INT64_C(-2147483648)) || (num > INT64_C(2147483647))) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, lyplg_ext_stmt2str(val_kw));
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, lyplg_ext_stmt2str(val_kw));
ret = LY_EVALID;
goto cleanup;
}
} else {
unum = strtoull(word, &ptr, LY_BASE_DEC);
if (unum > UINT64_C(4294967295)) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, lyplg_ext_stmt2str(val_kw));
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, lyplg_ext_stmt2str(val_kw));
ret = LY_EVALID;
goto cleanup;
}
}
/* we have not parsed the whole argument */
if ((size_t)(ptr - word) != word_len) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, lyplg_ext_stmt2str(val_kw));
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, lyplg_ext_stmt2str(val_kw));
ret = LY_EVALID;
goto cleanup;
}
if (errno == ERANGE) {
- LOGVAL_PARSER(ctx, LY_VCODE_OOB, word_len, word, lyplg_ext_stmt2str(val_kw));
+ LOGVAL_PARSER(ctx, LY_VCODE_OOB, (int)word_len, word, lyplg_ext_stmt2str(val_kw));
ret = LY_EVALID;
goto cleanup;
}
@@ -1955,7 +1956,7 @@
LY_CHECK_GOTO(ret = get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len), cleanup);
if (!word_len || (word[0] == '0') || !isdigit(word[0])) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "fraction-digits");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "fraction-digits");
ret = LY_EVALID;
goto cleanup;
}
@@ -1964,12 +1965,12 @@
num = strtoull(word, &ptr, LY_BASE_DEC);
/* we have not parsed the whole argument */
if ((size_t)(ptr - word) != word_len) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "fraction-digits");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "fraction-digits");
ret = LY_EVALID;
goto cleanup;
}
if ((errno == ERANGE) || (num > LY_TYPE_DEC64_FD_MAX)) {
- LOGVAL_PARSER(ctx, LY_VCODE_OOB, word_len, word, "fraction-digits");
+ LOGVAL_PARSER(ctx, LY_VCODE_OOB, (int)word_len, word, "fraction-digits");
ret = LY_EVALID;
goto cleanup;
}
@@ -2020,7 +2021,7 @@
if ((word_len == ly_strlen_const("true")) && !strncmp(word, "true", word_len)) {
type->require_instance = 1;
} else if ((word_len != ly_strlen_const("false")) || strncmp(word, "false", word_len)) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "require-instance");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "require-instance");
ret = LY_EVALID;
goto cleanup;
}
@@ -2067,7 +2068,7 @@
LY_CHECK_GOTO(ret = get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len), cleanup);
if ((word_len != ly_strlen_const("invert-match")) || strncmp(word, "invert-match", word_len)) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "modifier");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "modifier");
ret = LY_EVALID;
goto cleanup;
}
@@ -2397,7 +2398,7 @@
LY_CHECK_GOTO(ret = get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len), cleanup);
if (!word_len || (word[0] == '0') || ((word[0] != 'u') && !isdigit(word[0]))) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "max-elements");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "max-elements");
ret = LY_EVALID;
goto cleanup;
}
@@ -2407,12 +2408,12 @@
num = strtoull(word, &ptr, LY_BASE_DEC);
/* we have not parsed the whole argument */
if ((size_t)(ptr - word) != word_len) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "max-elements");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "max-elements");
ret = LY_EVALID;
goto cleanup;
}
if ((errno == ERANGE) || (num > UINT32_MAX)) {
- LOGVAL_PARSER(ctx, LY_VCODE_OOB, word_len, word, "max-elements");
+ LOGVAL_PARSER(ctx, LY_VCODE_OOB, (int)word_len, word, "max-elements");
ret = LY_EVALID;
goto cleanup;
}
@@ -2469,7 +2470,7 @@
LY_CHECK_GOTO(ret = get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len), cleanup);
if (!word_len || !isdigit(word[0]) || ((word[0] == '0') && (word_len > 1))) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "min-elements");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "min-elements");
ret = LY_EVALID;
goto cleanup;
}
@@ -2478,12 +2479,12 @@
num = strtoull(word, &ptr, LY_BASE_DEC);
/* we have not parsed the whole argument */
if ((size_t)(ptr - word) != word_len) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "min-elements");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "min-elements");
ret = LY_EVALID;
goto cleanup;
}
if ((errno == ERANGE) || (num > UINT32_MAX)) {
- LOGVAL_PARSER(ctx, LY_VCODE_OOB, word_len, word, "min-elements");
+ LOGVAL_PARSER(ctx, LY_VCODE_OOB, (int)word_len, word, "min-elements");
ret = LY_EVALID;
goto cleanup;
}
@@ -2535,7 +2536,7 @@
} else if ((word_len == ly_strlen_const("user")) && !strncmp(word, "user", word_len)) {
llist->flags |= LYS_ORDBY_USER;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "ordered-by");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "ordered-by");
ret = LY_EVALID;
goto cleanup;
}
@@ -3712,7 +3713,7 @@
} else if ((word_len == ly_strlen_const("false")) && !strncmp(word, "false", word_len)) {
ext->flags |= LYS_YINELEM_FALSE;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "yin-element");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "yin-element");
free(buf);
return LY_EVALID;
}
@@ -3865,7 +3866,7 @@
} else if ((word_len == ly_strlen_const("delete")) && !strncmp(word, "delete", word_len)) {
dev_mod = LYS_DEV_DELETE;
} else {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, "deviate");
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)word_len, word, "deviate");
ret = LY_EVALID;
goto cleanup;
}
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 088e79d..36b49f1 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -488,7 +488,7 @@
INSERT_STRING_RET(ctx->xmlctx->ctx, ctx->xmlctx->value, ctx->xmlctx->value_len, ctx->xmlctx->dynamic, *arg_val);
LY_CHECK_RET(!(*arg_val), LY_EMEM);
} else {
- LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_ATTR, ctx->xmlctx->name_len,
+ LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_ATTR, (int)ctx->xmlctx->name_len,
ctx->xmlctx->name, lyplg_ext_stmt2str(current_element));
return LY_EVALID;
}
@@ -3185,7 +3185,7 @@
ctx->xmlctx->prefix_len, parent_stmt);
if (((parent_stmt == LY_STMT_ERROR_MESSAGE) && (child != LY_STMT_ARG_VALUE)) ||
((parent_stmt != LY_STMT_ERROR_MESSAGE) && (child != LY_STMT_ARG_TEXT))) {
- LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, ctx->xmlctx->name_len, ctx->xmlctx->name,
+ LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, (int)ctx->xmlctx->name_len, ctx->xmlctx->name,
lyplg_ext_stmt2str(parent_stmt));
return LY_EVALID;
}
@@ -3256,7 +3256,7 @@
last = (*element)->child;
if ((*element)->kw == LY_STMT_NONE) {
/* unrecognized element */
- LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, ctx->xmlctx->name_len, ctx->xmlctx->name,
+ LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, (int)ctx->xmlctx->name_len, ctx->xmlctx->name,
lyplg_ext_stmt2str(parent_stmt));
ret = LY_EVALID;
goto cleanup;
@@ -3422,7 +3422,7 @@
}
} else if (ctx->xmlctx->value_len) {
/* invalid text content */
- LOGVAL_PARSER(ctx, LYVE_SYNTAX, "Extension instance \"%s\" with unexpected text content \".*s\".", ext_name,
+ LOGVAL_PARSER(ctx, LYVE_SYNTAX, "Extension instance \"%s\" with unexpected text content \"%.*s\".", ext_name,
(int)ctx->xmlctx->value_len, ctx->xmlctx->value);
return LY_EVALID;
}
@@ -3479,7 +3479,7 @@
if ((parent_stmt == LY_STMT_DEVIATE) && isdevsub(cur_stmt)) {
LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_INDEV_YIN, lyplg_ext_stmt2str(cur_stmt));
} else {
- LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, ctx->xmlctx->name_len,
+ LOGVAL_PARSER((struct lysp_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, (int)ctx->xmlctx->name_len,
ctx->xmlctx->name, lyplg_ext_stmt2str(parent_stmt));
}
ret = LY_EVALID;
diff --git a/src/path.c b/src/path.c
index d691696..847249d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -285,7 +285,7 @@
LY_CHECK_RET(lyxp_next_token(ctx, exp, tok_idx, LYXP_TOKEN_FUNCNAME), LY_EVALID);
if (!strncmp(&exp->expr[exp->tok_pos[*tok_idx]], "deref", 5)) {
LOGVAL(ctx, LYVE_XPATH, "Unexpected XPath function \"%.*s\" in path, expected \"deref(...)\"",
- exp->tok_len[*tok_idx], exp->tok_pos[*tok_idx]);
+ exp->tok_len[*tok_idx], exp->expr + exp->tok_pos[*tok_idx]);
return LY_EVALID;
}
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index b99ec64..820e81e 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -701,7 +701,7 @@
if (value_len > UINT32_MAX) {
LOGERR(lybctx->ctx, LY_EINT, "The maximum length of the LYB data "
- "from a term node must not exceed %lu.", UINT32_MAX);
+ "from a term node must not exceed %" PRIu32 ".", UINT32_MAX);
ret = LY_EINT;
goto cleanup;
}
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 9d77a1f..1232228 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -1048,7 +1048,8 @@
if (!llist->dflts[u]->realtype->plugin->compare(llist->dflts[u], llist->dflts[v])) {
lysc_update_path(ctx, llist->parent ? llist->parent->module : NULL, llist->name);
LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Configuration leaf-list has multiple defaults of the same value \"%s\".",
- llist->dflts[u]->realtype->plugin->print(ctx->ctx, llist->dflts[u], LY_VALUE_CANON, NULL, NULL, NULL));
+ (char *)llist->dflts[u]->realtype->plugin->print(ctx->ctx, llist->dflts[u], LY_VALUE_CANON,
+ NULL, NULL, NULL));
lysc_update_path(ctx, NULL, NULL);
return LY_EVALID;
}
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 9ca4e2e..e986188 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -1351,7 +1351,7 @@
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflt, &((struct lysp_node_leaf *)target)->dflt), cleanup);
break;
case LYS_CHOICE:
- DEV_CHECK_PRESENCE(struct lysp_node_choice *, dflt.str, "replacing", "default", d->dflt);
+ DEV_CHECK_PRESENCE(struct lysp_node_choice *, dflt.str, "replacing", "default", d->dflt.str);
lydict_remove(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &d->dflt, &((struct lysp_node_choice *)target)->dflt), cleanup);
diff --git a/src/tree_data_common.c b/src/tree_data_common.c
index 8d1de06..b19ba3a 100644
--- a/src/tree_data_common.c
+++ b/src/tree_data_common.c
@@ -489,8 +489,8 @@
LOGVAL_ERRITEM(ctx, err);
ly_err_free(err);
} else {
- LOGVAL(ctx, LYVE_OTHER, "Resolving value \"%s\" failed.", type->plugin->print(ctx, val, LY_VALUE_CANON,
- NULL, NULL, NULL));
+ LOGVAL(ctx, LYVE_OTHER, "Resolving value \"%s\" failed.",
+ (char *)type->plugin->print(ctx, val, LY_VALUE_CANON, NULL, NULL, NULL));
}
return ret;
}
diff --git a/src/tree_data_new.c b/src/tree_data_new.c
index 090e7ac..f9f9abf 100644
--- a/src/tree_data_new.c
+++ b/src/tree_data_new.c
@@ -976,7 +976,8 @@
LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
if (parent && !parent->schema) {
- LOGERR(ctx, LY_EINVAL, "Cannot add metadata to an opaque node \"%s\".", ((struct lyd_node_opaq *)parent)->name);
+ LOGERR(ctx, LY_EINVAL, "Cannot add metadata to an opaque node \"%s\".",
+ ((struct lyd_node_opaq *)parent)->name.name);
return LY_EINVAL;
}
if (meta) {
diff --git a/src/tree_schema_common.c b/src/tree_schema_common.c
index 5580809..a6e2036 100644
--- a/src/tree_schema_common.c
+++ b/src/tree_schema_common.c
@@ -104,7 +104,7 @@
error:
if (stmt) {
- LOGVAL_PARSER(ctx, LY_VCODE_INVAL, date_len, date, stmt);
+ LOGVAL_PARSER(ctx, LY_VCODE_INVAL, (int)date_len, date, stmt);
}
return LY_EINVAL;
}
@@ -140,10 +140,10 @@
(int)name_len, name);
return LY_EVALID;
} else {
- for (size_t u = 0; u < name_len; ++u) {
+ for (uint32_t u = 0; u < name_len; ++u) {
if (iscntrl(name[u])) {
- LOGWRN(PARSER_CTX(ctx), "Control characters in enum name should be avoided (\"%.*s\", character number %d).",
- (int)name_len, name, u + 1);
+ LOGWRN(PARSER_CTX(ctx), "Control characters in enum name should be avoided "
+ "(\"%.*s\", character number %" PRIu32 ").", (int)name_len, name, u + 1);
break;
}
}
diff --git a/src/xml.c b/src/xml.c
index a4226d6..2bdbdf3 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -435,12 +435,11 @@
lyxml_parse_value(struct lyxml_ctx *xmlctx, char endchar, char **value, size_t *length, ly_bool *ws_only, ly_bool *dynamic)
{
const struct ly_ctx *ctx = xmlctx->ctx; /* shortcut */
- const char *in = xmlctx->in->current, *start, *in_aux;
+ const char *in = xmlctx->in->current, *start, *in_aux, *p;
char *buf = NULL;
size_t offset; /* read offset in input buffer */
size_t len; /* length of the output string (write offset in output buffer) */
size_t size = 0; /* size of the output buffer */
- void *p;
uint32_t n;
size_t u;
ly_bool ws = 1;
@@ -487,7 +486,7 @@
}
offset = 0;
} else {
- p = (void *)&in[offset - 1];
+ p = &in[offset - 1];
/* character reference */
++offset;
if (isdigit(in[offset])) {
@@ -506,7 +505,7 @@
n = (LY_BASE_HEX * n) + u;
}
} else {
- LOGVAL(ctx, LYVE_SYNTAX, "Invalid character reference \"%.*s\".", 12, p);
+ LOGVAL(ctx, LYVE_SYNTAX, "Invalid character reference \"%.12s\".", p);
goto error;
}
@@ -517,7 +516,7 @@
}
++offset;
if (ly_pututf8(&buf[len], n, &u)) {
- LOGVAL(ctx, LYVE_SYNTAX, "Invalid character reference \"%.*s\" (0x%08x).", 12, p, n);
+ LOGVAL(ctx, LYVE_SYNTAX, "Invalid character reference \"%.12s\" (0x%08x).", p, n);
goto error;
}
len += u;
diff --git a/src/xpath.c b/src/xpath.c
index 259fd9c..9a197ac 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -2981,7 +2981,7 @@
parsed++;
ncname_len = parse_ncname(&expr_str[parsed]);
LY_CHECK_ERR_GOTO(ncname_len < 1, LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed - ncname_len],
- parsed - ncname_len + 1, expr_str); ret = LY_EVALID, error);
+ (uint32_t)(parsed - ncname_len + 1), expr_str); ret = LY_EVALID, error);
tok_len = ncname_len;
LY_CHECK_ERR_GOTO(expr_str[parsed + tok_len] == ':',
LOGVAL(ctx, LYVE_XPATH, "Variable with prefix is not supported."); ret = LY_EVALID,
@@ -3071,7 +3071,7 @@
ret = LY_EVALID;
goto error;
} else {
- LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed], parsed + 1, expr_str);
+ LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed], (uint32_t)(parsed + 1), expr_str);
ret = LY_EVALID;
goto error;
}
@@ -3083,7 +3083,7 @@
} else {
ncname_len = parse_ncname(&expr_str[parsed]);
LY_CHECK_ERR_GOTO(ncname_len < 1, LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed - ncname_len],
- parsed - ncname_len + 1, expr_str); ret = LY_EVALID, error);
+ (uint32_t)(parsed - ncname_len + 1), expr_str); ret = LY_EVALID, error);
}
tok_len = ncname_len;
@@ -3091,7 +3091,8 @@
if (!strncmp(&expr_str[parsed + tok_len], "::", 2)) {
/* axis */
LY_CHECK_ERR_GOTO(expr_parse_axis(&expr_str[parsed], ncname_len),
- LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed], parsed + 1, expr_str); ret = LY_EVALID, error);
+ LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed], (uint32_t)(parsed + 1), expr_str); ret = LY_EVALID,
+ error);
tok_type = LYXP_TOKEN_AXISNAME;
LY_CHECK_GOTO(ret = exp_add_token(ctx, expr, tok_type, parsed, tok_len), error);
@@ -3109,7 +3110,7 @@
} else {
ncname_len = parse_ncname(&expr_str[parsed]);
LY_CHECK_ERR_GOTO(ncname_len < 1, LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed - ncname_len],
- parsed - ncname_len + 1, expr_str); ret = LY_EVALID, error);
+ (uint32_t)(parsed - ncname_len + 1), expr_str); ret = LY_EVALID, error);
}
tok_len = ncname_len;
@@ -3123,7 +3124,7 @@
} else {
ncname_len = parse_ncname(&expr_str[parsed + tok_len]);
LY_CHECK_ERR_GOTO(ncname_len < 1, LOGVAL(ctx, LY_VCODE_XP_INEXPR, expr_str[parsed - ncname_len],
- parsed - ncname_len + 1, expr_str); ret = LY_EVALID, error);
+ (uint32_t)(parsed - ncname_len + 1), expr_str); ret = LY_EVALID, error);
tok_len += ncname_len;
}
/* remove old flags to prevent ambiguities */
@@ -5591,7 +5592,7 @@
/* check for errors and non-implemented modules, as they are not valid */
if (!mod || !mod->implemented) {
- LOGVAL(set->ctx, LY_VCODE_XP_INMOD, pref_len, *qname);
+ LOGVAL(set->ctx, LY_VCODE_XP_INMOD, (int)pref_len, *qname);
return LY_EVALID;
}