From bd2179053a5c09c63e7032a9f48496ccd21e36e0 Mon Sep 17 00:00:00 2001 From: Aggelos Economopoulos Date: Mon, 15 Feb 2010 14:06:23 +0200 Subject: [PATCH] libevtr: handle eof properly --- lib/libevtr/evtr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/libevtr/evtr.c b/lib/libevtr/evtr.c index c7a13b07da..743a987498 100644 --- a/lib/libevtr/evtr.c +++ b/lib/libevtr/evtr.c @@ -1561,12 +1561,18 @@ _evtr_next_event(evtr_t evtr, evtr_event_t ev, struct evtr_query *q) struct trace_event_header *evhdr = (struct trace_event_header *)buf; for (ret = 0; !ret;) { + if (evtr_read(evtr, &evhdr->type, 1)) { + if (feof(evtr->f)) { + evtr->errmsg = NULL; + evtr->err = 0; + return -1; + } + return !0; + } /* * skip pad records -- this will only happen if there's a * variable sized record close to the boundary */ - if (evtr_read(evtr, &evhdr->type, 1)) - return feof(evtr->f) ? -1 : !0; if (evhdr->type == EVTR_TYPE_PAD) { evtr_skip_to_record(evtr); continue; -- 2.41.0