exp: fix issues around int vs size_t
authorJens Axboe <axboe@fb.com>
Tue, 7 Oct 2014 15:09:57 +0000 (09:09 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 7 Oct 2014 15:09:57 +0000 (09:09 -0600)
This seems to be the easiest way - just wrap the call in a
macro that always passes a size_t, then it doesn't matter what
yy_n_chars is typed as (int or size_t).

Signed-off-by: Jens Axboe <axboe@fb.com>
exp/expression-parser.l

index 7d5e787..d659c4f 100644 (file)
 
 #define YYSTYPE PARSER_VALUE_TYPE
 
-extern int lexer_input(char* buffer, int *nbytes, int buffersize);
+extern int lexer_input(char* buffer, size_t *nbytes, int buffersize);
 
 #undef YY_INPUT
-#define YY_INPUT(buffer, bytes_read, bytes_requested) \
-               lexer_input((buffer), &(bytes_read), (bytes_requested))
+#define YY_INPUT(buffer, bytes_read, bytes_requested)  \
+({                                                     \
+       int __ret;                                      \
+       size_t __bread = bytes_read;                    \
+       __ret = lexer_input((buffer), &__bread, (bytes_requested));     \
+       bytes_read = __bread;                                           \
+       __ret;                                          \
+})
 
 extern int yyerror(long long *result, double *dresult,
                int *has_error, int *units_specified, const char *msg);