Skip to content

Commit

Permalink
Fix a few error messages in jparse/json_sem.c
Browse files Browse the repository at this point in the history
In some of the functions sem_member_value_*() (those that validate JSON
parse node types) the error message (if the type was wrong) reported
incorrectly the type expected and in particular all of them suggested
the type should be JTYPE_BOOL but none of the functions were for
booleans (though all were for numbers I think).
  • Loading branch information
xexyl committed Jul 14, 2024
1 parent 7fc8273 commit 49919fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

Add constants for `test_formed_timestamp_usec()` in `entry_util.c`.

Fix error messages in a number of `sem_member_value_*` functions in
`jparse/json_sem.c`, where the `*` is some of the number checks. In particular
a number of non-boolean checks reported incorrectly that the type was not a bool
when it actually expects something else.


## Release 1.2.3 2024-07-12

Expand Down
6 changes: 3 additions & 3 deletions jparse/json_sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ sem_member_value_int(struct json const *node, unsigned int depth, struct json_se
*/
if (value->type != JTYPE_NUMBER) {
if (val_err != NULL) {
*val_err = werr_sem_val(66, node, depth, sem, name, "node value type %s != JTYPE_BOOL",
*val_err = werr_sem_val(66, node, depth, sem, name, "node value type %s != JTYPE_NUMBER",
json_type_name(value->type));
}
return NULL;
Expand Down Expand Up @@ -1336,7 +1336,7 @@ sem_member_value_size_t(struct json const *node, unsigned int depth, struct json
*/
if (value->type != JTYPE_NUMBER) {
if (val_err != NULL) {
*val_err = werr_sem_val(69, node, depth, sem, name, "node value type %s != JTYPE_BOOL",
*val_err = werr_sem_val(69, node, depth, sem, name, "node value type %s != JTYPE_NUMBER",
json_type_name(value->type));
}
return NULL;
Expand Down Expand Up @@ -1414,7 +1414,7 @@ sem_member_value_time_t(struct json const *node, unsigned int depth, struct json
*/
if (value->type != JTYPE_NUMBER) {
if (val_err != NULL) {
*val_err = werr_sem_val(72, node, depth, sem, name, "node value type %s != JTYPE_BOOL",
*val_err = werr_sem_val(72, node, depth, sem, name, "node value type %s != JTYPE_NUMBER",
json_type_name(value->type));
}
return NULL;
Expand Down

0 comments on commit 49919fa

Please sign in to comment.