From 6054989b78b7a481770a1608c809a56e1cf5cc7d Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 1 Jun 2014 15:32:25 +0200 Subject: Fix -d (timediff) option in binlogsel. * src/binlogsel.c (selmem): Don't attempt to modify rec. --- src/binlogsel.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/binlogsel.c') diff --git a/src/binlogsel.c b/src/binlogsel.c index d44c1b8..b3fb75b 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -273,8 +273,8 @@ searchts(void *base, size_t recsize, size_t from, size_t to, time_t ts, void selmem(const char *name, void *base) { - struct binlog_file_header *hdr; - struct binlog_record *rec; + struct binlog_file_header const *hdr; + struct binlog_record const *rec; struct packenv *env; struct packinst *inst; char *p; @@ -350,15 +350,19 @@ selmem(const char *name, void *base) start = 0; for (i = 0; start < hdr->recnum; i++, start++) { + time_t ts; + rec = getrec(base, hdr->recsize, start); if ((timemask & STOP_TIME) && rec->ts > to_time) break; + + ts = rec->ts; if (timediff_option) { if (i == 0) - start_ts = rec->ts; - rec->ts -= start_ts; + start_ts = ts; + ts -= start_ts; } strftime(timebuf, sizeof timebuf, timefmt, localtime(&rec->ts)); @@ -372,7 +376,7 @@ selmem(const char *name, void *base) last_ts = rec->ts; if (module_record) - module_record(ip->name, rec->ts, env->buf_base); + module_record(ip->name, ts, env->buf_base); else { if (ip->name) printf("%s ", ip->name); -- cgit v1.2.1