do not call fprintf from yyerror in expression parser
authorStephen M. Cameron <stephenmcameron@gmail.com>
Tue, 30 Sep 2014 14:31:04 +0000 (09:31 -0500)
committerJens Axboe <axboe@fb.com>
Tue, 30 Sep 2014 16:41:46 +0000 (10:41 -0600)
Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
exp/expression-parser.y
exp/test-expression-parser.c

index 6ab6408..87ead8a 100644 (file)
@@ -229,9 +229,10 @@ int evaluate_arithmetic_expression(const char *buffer, long long *ival, double *
 int yyerror(__attribute__((unused)) long long *result,
                __attribute__((unused)) double *dresult,
                __attribute__((unused)) int *has_error,
-               __attribute__((unused)) int *bye, const char *msg)
+               __attribute__((unused)) int *bye,
+               __attribute__((unused)) const char *msg)
 {
-       fprintf(stderr, "%s\n", msg);
+       /* We do not need to do anything here. */
        return 0;
 }
 
index 022df01..4515144 100644 (file)
@@ -44,6 +44,7 @@ int main(int argc, char *argv[])
                if (!rc) {
                        printf("%lld (%20.20lf)\n", result, dresult);
                } else {
+                       fprintf(stderr, "Syntax error\n");
                        result = 0;
                        dresult = 0;
                }