Mercurial > libjeffpc
changeset 467:1b00445e6dc1
val: be paranoid about macro expansion
The CALL and CALL_OR_FAIL helper macros assumed that ops did not expand to
something with operators with lower precedence than ->. This meant that
this sort of code would break:
CALL(&abc->ops, def, (ghi));
Specifically, it would turn into:
if (&abc->ops->def)
...
instead of:
if ((&abc->ops)->def)
...
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 01 Apr 2018 13:41:19 -0400 |
parents | 8635533bc2b6 |
children | c075052024ac |
files | val_impl_packing.h |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/val_impl_packing.h Sun Apr 01 13:24:30 2018 -0400 +++ b/val_impl_packing.h Sun Apr 01 13:41:19 2018 -0400 @@ -30,8 +30,8 @@ ({ \ int _ret = 0; \ \ - if (ops->op) \ - _ret = ops->op args; \ + if ((ops)->op) \ + _ret = (ops)->op args; \ \ _ret; \ }) @@ -40,8 +40,8 @@ ({ \ int _ret = -ENOTSUP; \ \ - if (ops->op) \ - _ret = ops->op args; \ + if ((ops)->op) \ + _ret = (ops)->op args; \ \ _ret; \ })