Skip to content

Commit

Permalink
pvv_is_int(): Be even more flexible
Browse files Browse the repository at this point in the history
This patch further improves commit 6191f27, where the macro will now
also work with code such as:

(excerpt from pv_set_count()):
    ...
    pv_val.flags = PV_TYPE_INT;
    pv_val.ri = pv_name->pvp.pvi.u.ival-1;
    ...

Notice how the flags are poorly set, since the PV_VAL_INT bit should
have been used instead.

(cherry picked from commit 34af3c4)
  • Loading branch information
liviuchircu committed Feb 4, 2021
1 parent 0d76143 commit 0f884da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pvar.h
Expand Up @@ -61,7 +61,7 @@

/* @v: a (pv_value_t *) */
#define pvv_is_int(v) \
((v)->flags & PV_VAL_INT && \
((v)->flags & (PV_VAL_INT|PV_TYPE_INT) && \
((v)->flags & PV_TYPE_INT || !((v)->flags & PV_VAL_STR)))
#define pvv_is_str(v) \
((v)->flags & PV_VAL_STR && !((v)->flags & PV_TYPE_INT))
Expand Down

0 comments on commit 0f884da

Please sign in to comment.