Change PB_RETURN_ERROR() macro to avoid compiler warnings.
Update issue 140 Status: FixedInGit
This commit is contained in:
21
pb.h
21
pb.h
@@ -508,22 +508,21 @@ struct pb_extension_s {
|
|||||||
* is the true/false return value from functions.
|
* is the true/false return value from functions.
|
||||||
* Some code space can be saved by disabling the error
|
* Some code space can be saved by disabling the error
|
||||||
* messages if not used.
|
* messages if not used.
|
||||||
|
*
|
||||||
|
* PB_SET_ERROR() sets the error message if none has been set yet.
|
||||||
|
* msg must be a constant string literal.
|
||||||
|
* PB_GET_ERROR() always returns a pointer to a string.
|
||||||
|
* PB_RETURN_ERROR() sets the error and returns false from current
|
||||||
|
* function.
|
||||||
*/
|
*/
|
||||||
#ifdef PB_NO_ERRMSG
|
#ifdef PB_NO_ERRMSG
|
||||||
#define PB_RETURN_ERROR(stream,msg) \
|
#define PB_SET_ERROR(stream, msg) PB_UNUSED(stream)
|
||||||
do {\
|
|
||||||
PB_UNUSED(stream); \
|
|
||||||
return false; \
|
|
||||||
} while(0)
|
|
||||||
#define PB_GET_ERROR(stream) "(errmsg disabled)"
|
#define PB_GET_ERROR(stream) "(errmsg disabled)"
|
||||||
#else
|
#else
|
||||||
#define PB_RETURN_ERROR(stream,msg) \
|
#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
|
||||||
do {\
|
|
||||||
if ((stream)->errmsg == NULL) \
|
|
||||||
(stream)->errmsg = (msg); \
|
|
||||||
return false; \
|
|
||||||
} while(0)
|
|
||||||
#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
|
#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -121,9 +121,6 @@ elif 'cl' in env['CC']:
|
|||||||
|
|
||||||
# More strict checks on the nanopb core
|
# More strict checks on the nanopb core
|
||||||
env.Append(CORECFLAGS = '/W4')
|
env.Append(CORECFLAGS = '/W4')
|
||||||
|
|
||||||
# PB_RETURN_ERROR triggers C4127 because of while(0)
|
|
||||||
env.Append(CFLAGS = '/wd4127')
|
|
||||||
elif 'tcc' in env['CC']:
|
elif 'tcc' in env['CC']:
|
||||||
# Tiny C Compiler
|
# Tiny C Compiler
|
||||||
env.Append(CFLAGS = '-Wall -Werror -g')
|
env.Append(CFLAGS = '-Wall -Werror -g')
|
||||||
|
|||||||
Reference in New Issue
Block a user