[PATCH 11/15] libtracefs: my_yyinput() should return 0 when no data can be read

"Jerome Marchand" <[email protected]>
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
YY_INPUT() is redefined in sqlhist.l and basically just call
my_yyinput() to do the work. However, YY_INPUT is supposed to return
YY_NULL (0 on Unix system) when no data can be read, not -1. This can
cause an overflow error in the generated sqlhist-lex.c file.

Have my_yyinput() returns zero when no buffer is found.

Signed-off-by: Jerome Marchand <[email protected]>
---
 src/tracefs-sqlhist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c
index c7b9eff..0f678c1 100644
--- a/src/tracefs-sqlhist.c
+++ b/src/tracefs-sqlhist.c
@@ -121,7 +121,7 @@ __hidden int my_yyinput(void *extra, char *buf, int max)
 	struct sqlhist_bison *sb = extra;
 
 	if (!sb || !sb->buffer)
-		return -1;
+		return 0;
 
 	if (sb->buffer_idx + max > sb->buffer_size)
 		max = sb->buffer_size - sb->buffer_idx;
-- 
2.44.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.