diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-08-24 21:07:30 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-08-24 21:27:23 -0700 |
commit | 5737e77061a36b004d815aaff9cb0fff914e1e47 (patch) | |
tree | b666b834763823694a28a8872125adc5456c4c6f | |
parent | c03c2264ada7c3edc06f7f2f759fcf5f38c2bd1b (diff) |
Convert STRING_BYTES & STORE_STRING from macros to inline functions
Solves gcc errors from passing an auto-allocated array in some of the calls:
xfindproxy.c:288:20: error: the address of ‘authName’ will always evaluate as ‘true’
xfindproxy.c:288:20: error: the address of ‘authName’ will always evaluate as ‘true’
xfindproxy.c:302:2: error: the address of ‘authName’ will always evaluate as ‘true’
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | xfindproxy.h | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/xfindproxy.h b/xfindproxy.h index b755043..9eb84fd 100644 --- a/xfindproxy.h +++ b/xfindproxy.h @@ -47,9 +47,11 @@ from The Open Group. * Compute the number of bytes for a STRING representation */ -#define STRING_BYTES(_str) (2 + (_str ? strlen (_str) : 0) + \ - PAD64 (2 + (_str ? strlen (_str) : 0))) - +static inline int +STRING_BYTES(const char *string) { + int len = string ? strlen (string) : 0; + return (2 + len + PAD64 (2 + len)); +} #define SKIP_STRING(_pBuf, _swap) \ @@ -71,18 +73,21 @@ from The Open Group. _pBuf += 2; \ } -#define STORE_STRING(_pBuf, _string) \ -{ \ - int _len = _string ? strlen (_string) : 0; \ - STORE_CARD16 (_pBuf, _len); \ - if (_len) { \ - memcpy (_pBuf, _string, _len); \ - _pBuf += _len; \ - } \ - if (PAD64 (2 + _len)) \ - _pBuf += PAD64 (2 + _len); \ +static inline char * +store_string(char *pBuf, const char *string) +{ + int len = string ? strlen (string) : 0; + STORE_CARD16 (pBuf, len); + if (len) { + memcpy (pBuf, string, len); + pBuf += len; + } + if (PAD64 (2 + len)) + pBuf += PAD64 (2 + len); + return pBuf; } +#define STORE_STRING(_pBuf, _string) _pBuf = store_string(_pBuf, _string) /* * EXTRACT macros |