From 58f7dbc0658b3d73816a1bc91b75c2bdac733510 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 13 Oct 2013 13:39:50 +0300 Subject: Fix error checking, add pack tests. * src/binlog.c (vmod_init): Fix error checking after packcomp. * src/binlogcat.c (catlog): Likewise. * tests/binpack.c (main): Likewise. * src/pack.c (Z_unpacker): Fix output format. (packcomp): allow for whitespace between specifiers. On error set errno and return NULL. * tests/Makefile.am: Add pack.at * tests/testsuite.at: Likewise. * tests/pack.at: New file. * tests/test02.at: Fix name pattern. --- src/binlogcat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/binlogcat.c') diff --git a/src/binlogcat.c b/src/binlogcat.c index bdeb992..505bbc2 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c @@ -92,8 +92,13 @@ catlog(const char *fname) fname, dataspec, header.recsize, header.recnum); inst = packcomp(dataspec, &p); - if (*p) { - error("%s: bad dataspec near %s", dataspec, p); + if (!inst) { + if (errno == EINVAL) { + error("%s: bad dataspec near %s", dataspec, p); + exit(1); + } + + error("%s", strerror(errno)); exit(1); } free(dataspec); @@ -101,7 +106,7 @@ catlog(const char *fname) rec = malloc(header.recsize); if (!rec) { error("not enough memory"); - abort(); + exit(1); } env = packenv_create(header.recsize - offsetof(struct binlog_record,data)); -- cgit v1.2.1