Index: stable/11/usr.sbin/fifolog/lib/fifolog_create.c =================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_create.c (revision 306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_create.c (revision 306909) @@ -1,122 +1,122 @@ /*- * Copyright (c) 2005-2008 Poul-Henning Kamp * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include "fifolog.h" #include "libfifolog.h" const char * fifolog_create(const char *fn, off_t size, ssize_t recsize) { int i, fd; ssize_t u; off_t ms; struct stat st; char *buf; int created; fd = open(fn, O_WRONLY | O_TRUNC | O_EXCL | O_CREAT, 0644); if (fd < 0) { created = 0; fd = open(fn, O_WRONLY); if (fd < 0) return ("Could not open"); } else created = 1; /* Default sectorsize is 512 */ if (recsize == 0) recsize = 512; /* See what we got... */ i = fstat(fd, &st); assert(i == 0); if (!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode) && !S_ISREG(st.st_mode)) { assert(!close (fd)); return ("Wrong file type"); } if(!created && S_ISREG(st.st_mode)) { assert(!close (fd)); return ("Wrong file type"); } /* For raw disk with larger sectors: use 1 sector */ i = ioctl(fd, DIOCGSECTORSIZE, &u); if (i == 0 && (u > recsize || (recsize % u) != 0)) recsize = u; /* If no configured size, or too large for disk, use device size */ i = ioctl(fd, DIOCGMEDIASIZE, &ms); if (i == 0 && (size == 0 || size > ms)) size = ms; if (size == 0 && S_ISREG(st.st_mode)) size = st.st_size; if (size == 0) size = recsize * (off_t)(24*60*60); if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0) return ("Could not ftrunc"); - buf = calloc(recsize, 1); + buf = calloc(1, recsize); if (buf == NULL) return ("Could not malloc"); strcpy(buf, FIFOLOG_FMT_MAGIC); /*lint !e64 */ be32enc(buf + FIFOLOG_OFF_BS, recsize); if (recsize != pwrite(fd, buf, recsize, 0)) { i = errno; free(buf); errno = i; return ("Could not write first sector"); } memset(buf, 0, recsize); if ((int)recsize != pwrite(fd, buf, recsize, recsize)) { i = errno; free(buf); errno = i; return ("Could not write second sector"); } free(buf); assert(0 == close(fd)); return (NULL); } Index: stable/11/usr.sbin/fifolog/lib/fifolog_reader.c =================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_reader.c (revision 306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_reader.c (revision 306909) @@ -1,322 +1,322 @@ /*- * Copyright (c) 2005-2008 Poul-Henning Kamp * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include "fifolog.h" #include "libfifolog.h" #include "libfifolog_int.h" #include "miniobj.h" /*--------------------------------------------------------------------*/ struct fifolog_reader { unsigned magic; #define FIFOLOG_READER_MAGIC 0x1036d139 struct fifolog_file *ff; unsigned olen; unsigned char *obuf; time_t now; }; struct fifolog_reader * fifolog_reader_open(const char *fname) { const char *retval; struct fifolog_reader *fr; int i; fr = calloc(sizeof *fr, 1); if (fr == NULL) err(1, "Cannot malloc"); retval = fifolog_int_open(&fr->ff, fname, 0); if (retval != NULL) err(1, "%s", retval); - fr->olen = fr->ff->recsize * 16; - fr->obuf = calloc(fr->olen, 1); + fr->obuf = calloc(16, fr->ff->recsize); if (fr->obuf == NULL) err(1, "Cannot malloc"); + fr->olen = fr->ff->recsize * 16; i = inflateInit(fr->ff->zs); assert(i == Z_OK); fr->magic = FIFOLOG_READER_MAGIC; return (fr); } /* * Find the next SYNC block * * Return: * 0 - empty fifolog * 1 - found sync block * 2 - would have wrapped around * 3 - End of written log. */ static int fifolog_reader_findsync(const struct fifolog_file *ff, off_t *o) { int e; unsigned seq, seqs; assert(*o < ff->logsize); e = fifolog_int_read(ff, *o); if (e) err(1, "Read error (%d) while looking for SYNC", e); seq = be32dec(ff->recbuf); if (*o == 0 && seq == 0) return (0); if (ff->recbuf[4] & FIFOLOG_FLG_SYNC) return (1); /* That was easy... */ while(1) { assert(*o < ff->logsize); (*o)++; seq++; if (*o == ff->logsize) return (2); /* wraparound */ e = fifolog_int_read(ff, *o); if (e) err(1, "Read error (%d) while looking for SYNC", e); seqs = be32dec(ff->recbuf); if (seqs != seq) return (3); /* End of log */ if (ff->recbuf[4] & FIFOLOG_FLG_SYNC) return (1); /* Bingo! */ } } /* * Seek out a given timestamp */ off_t fifolog_reader_seek(const struct fifolog_reader *fr, time_t t0) { off_t o, s, st; time_t t, tt; unsigned seq, seqs; const char *retval; int e; CHECK_OBJ_NOTNULL(fr, FIFOLOG_READER_MAGIC); /* * First, find the first SYNC block */ o = 0; e = fifolog_reader_findsync(fr->ff, &o); if (e == 0) return (0); /* empty fifolog */ assert(e == 1); assert(fr->ff->recbuf[4] & FIFOLOG_FLG_SYNC); seq = be32dec(fr->ff->recbuf); t = be32dec(fr->ff->recbuf + 5); if (t > t0) { /* Check if there is a second older part we can use */ retval = fifolog_int_findend(fr->ff, &s); if (retval != NULL) err(1, "%s", retval); s++; e = fifolog_reader_findsync(fr->ff, &s); if (e == 0) return (0); /* empty fifolog */ if (e == 1) { o = s; seq = be32dec(fr->ff->recbuf); t = be32dec(fr->ff->recbuf + 5); } } /* Now do a binary search to find the sync block right before t0 */ s = st = (fr->ff->logsize - o) / 2; while (s > 1) { /* We know we shouldn't wrap */ if (o + st > fr->ff->logsize + 1) { s = st = s / 2; continue; } e = fifolog_int_read(fr->ff, o + st); if (e) { s = st = s / 2; continue; } /* If not in same part, sequence won't match */ seqs = be32dec(fr->ff->recbuf); if (seqs != seq + st) { s = st = s / 2; continue; } /* If not sync block, try next */ if (!(fr->ff->recbuf[4] & FIFOLOG_FLG_SYNC)) { st++; continue; } /* Check timestamp */ tt = be32dec(fr->ff->recbuf + 5); if (tt >= t0) { s = st = s / 2; continue; } o += st; seq = seqs; } fprintf(stderr, "Read from %jx\n", o * fr->ff->recsize); return (o); } static unsigned char * fifolog_reader_chop(struct fifolog_reader *fr, fifolog_reader_render_t *func, void *priv) { u_char *p, *q; uint32_t v, w, u; p = fr->obuf; q = fr->obuf + (fr->olen - fr->ff->zs->avail_out); while (1) { /* Make sure we have a complete header */ if (p + 5 >= q) return (p); w = 4; u = be32dec(p); if (u & FIFOLOG_TIMESTAMP) { fr->now = be32dec(p + 4); w += 4; } if (u & FIFOLOG_LENGTH) { v = p[w]; w++; if (p + w + v >= q) return (p); } else { for (v = 0; p + v + w < q && p[v + w] != '\0'; v++) continue; if (p + v + w >= q) return (p); v++; } func(priv, fr->now, u, p + w, v); p += w + v; } } /* * Process fifolog until end of written log or provided timestamp */ void fifolog_reader_process(struct fifolog_reader *fr, off_t from, fifolog_reader_render_t *func, void *priv, time_t end) { uint32_t seq, lseq; off_t o = from; int i, e; time_t t; u_char *p, *q; z_stream *zs; CHECK_OBJ_NOTNULL(fr, FIFOLOG_READER_MAGIC); zs = fr->ff->zs; lseq = 0; while (1) { e = fifolog_int_read(fr->ff, o); if (e) err(1, "Read error (%d)", e); if (++o >= fr->ff->logsize) o = 0; seq = be32dec(fr->ff->recbuf); if (lseq != 0 && seq != lseq + 1) break; lseq = seq; zs->avail_in = fr->ff->recsize - 5; zs->next_in = fr->ff->recbuf + 5; if (fr->ff->recbuf[4] & FIFOLOG_FLG_1BYTE) zs->avail_in -= fr->ff->recbuf[fr->ff->recsize - 1]; if (fr->ff->recbuf[4] & FIFOLOG_FLG_4BYTE) zs->avail_in -= be32dec(fr->ff->recbuf + fr->ff->recsize - 4); if (fr->ff->recbuf[4] & FIFOLOG_FLG_SYNC) { i = inflateReset(zs); assert(i == Z_OK); zs->next_out = fr->obuf; zs->avail_out = fr->olen; t = be32dec(fr->ff->recbuf + 5); if (t > end) break; zs->next_in += 4; zs->avail_in -= 4; } while(zs->avail_in > 0) { i = inflate(zs, 0); if (i == Z_BUF_ERROR) { #if 1 fprintf(stderr, "Z_BUF_ERROR [%d,%d] [%d,%d,%d]\n", (int)(zs->next_in - fr->ff->recbuf), zs->avail_in, (int)(zs->next_out - fr->obuf), zs->avail_out, fr->olen); exit (250); #else i = Z_OK; #endif } if (i == Z_STREAM_END) { i = inflateReset(zs); } if (i != Z_OK) { fprintf(stderr, "inflate = %d\n", i); exit (250); } assert(i == Z_OK); if (zs->avail_out != fr->olen) { q = fr->obuf + (fr->olen - zs->avail_out); p = fifolog_reader_chop(fr, func, priv); if (p < q) (void)memmove(fr->obuf, p, q - p); zs->avail_out = fr->olen - (q - p); zs->next_out = fr->obuf + (q - p); } } } } Index: stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c =================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c (revision 306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c (revision 306909) @@ -1,412 +1,412 @@ /*- * Copyright (c) 2005-2008 Poul-Henning Kamp * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include "fifolog.h" #include "libfifolog_int.h" #include "fifolog_write.h" #include "miniobj.h" static int fifolog_write_gzip(struct fifolog_writer *f, time_t now); #define ALLOC(ptr, size) do { \ - (*(ptr)) = calloc(size, 1); \ + (*(ptr)) = calloc(1, size); \ assert(*(ptr) != NULL); \ } while (0) const char *fifolog_write_statnames[] = { [FIFOLOG_PT_BYTES_PRE] = "Bytes before compression", [FIFOLOG_PT_BYTES_POST] = "Bytes after compression", [FIFOLOG_PT_WRITES] = "Writes", [FIFOLOG_PT_FLUSH] = "Flushes", [FIFOLOG_PT_SYNC] = "Syncs", [FIFOLOG_PT_RUNTIME] = "Runtime" }; /********************************************************************** * Check that everything is all right */ static void fifolog_write_assert(const struct fifolog_writer *f) { CHECK_OBJ_NOTNULL(f, FIFOLOG_WRITER_MAGIC); assert(f->ff->zs->next_out + f->ff->zs->avail_out == \ f->obuf + f->obufsize); } /********************************************************************** * Allocate/Destroy a new fifolog writer instance */ struct fifolog_writer * fifolog_write_new(void) { struct fifolog_writer *f; ALLOC_OBJ(f, FIFOLOG_WRITER_MAGIC); assert(f != NULL); return (f); } void fifolog_write_destroy(struct fifolog_writer *f) { free(f->obuf); free(f->ibuf); FREE_OBJ(f); } /********************************************************************** * Open/Close the fifolog */ void fifolog_write_close(struct fifolog_writer *f) { time_t now; CHECK_OBJ_NOTNULL(f, FIFOLOG_WRITER_MAGIC); fifolog_write_assert(f); f->cleanup = 1; time(&now); fifolog_write_gzip(f, now); fifolog_write_assert(f); fifolog_int_close(&f->ff); free(f->ff); } const char * fifolog_write_open(struct fifolog_writer *f, const char *fn, unsigned writerate, unsigned syncrate, unsigned compression) { const char *es; int i; time_t now; off_t o; CHECK_OBJ_NOTNULL(f, FIFOLOG_WRITER_MAGIC); /* Check for legal compression value */ if (compression > Z_BEST_COMPRESSION) return ("Illegal compression value"); f->writerate = writerate; f->syncrate = syncrate; f->compression = compression; /* Reset statistics */ memset(f->cnt, 0, sizeof f->cnt); es = fifolog_int_open(&f->ff, fn, 1); if (es != NULL) return (es); es = fifolog_int_findend(f->ff, &o); if (es != NULL) return (es); i = fifolog_int_read(f->ff, o); if (i) return ("Read error, looking for seq"); f->seq = be32dec(f->ff->recbuf); if (f->seq == 0) { /* Empty fifolog */ f->seq = random(); } else { f->recno = o + 1; f->seq++; } f->obufsize = f->ff->recsize; ALLOC(&f->obuf, f->obufsize); f->ibufsize = f->obufsize * 10; ALLOC(&f->ibuf, f->ibufsize); f->ibufptr = 0; i = deflateInit(f->ff->zs, (int)f->compression); assert(i == Z_OK); f->flag |= FIFOLOG_FLG_RESTART; f->flag |= FIFOLOG_FLG_SYNC; f->ff->zs->next_out = f->obuf + 9; f->ff->zs->avail_out = f->obufsize - 9; time(&now); f->starttime = now; f->lastsync = now; f->lastwrite = now; fifolog_write_assert(f); return (NULL); } /********************************************************************** * Write an output record * Returns -1 if there are trouble writing data */ static int fifolog_write_output(struct fifolog_writer *f, int fl, time_t now) { long h, l = f->ff->zs->next_out - f->obuf; ssize_t i, w; int retval = 0; h = 4; /* seq */ be32enc(f->obuf, f->seq); f->obuf[h] = f->flag; h += 1; /* flag */ if (f->flag & FIFOLOG_FLG_SYNC) { be32enc(f->obuf + h, now); h += 4; /* timestamp */ } assert(l <= (long)f->ff->recsize); /* NB: l includes h */ assert(l >= h); /* We will never write an entirely empty buffer */ if (l == h) return (0); if (l < (long)f->ff->recsize && fl == Z_NO_FLUSH) return (0); w = f->ff->recsize - l; if (w > 255) { be32enc(f->obuf + f->ff->recsize - 4, w); f->obuf[4] |= FIFOLOG_FLG_4BYTE; } else if (w > 0) { f->obuf[f->ff->recsize - 1] = (uint8_t)w; f->obuf[4] |= FIFOLOG_FLG_1BYTE; } f->cnt[FIFOLOG_PT_BYTES_POST] += l - h; i = pwrite(f->ff->fd, f->obuf, f->ff->recsize, (f->recno + 1) * f->ff->recsize); if (i != f->ff->recsize) retval = -1; else retval = 1; f->cnt[FIFOLOG_PT_WRITES]++; f->cnt[FIFOLOG_PT_RUNTIME] = now - f->starttime; f->lastwrite = now; /* * We increment these even on error, so as to properly skip bad, * sectors or other light trouble. */ f->seq++; f->recno++; f->flag = 0; memset(f->obuf, 0, f->obufsize); f->ff->zs->next_out = f->obuf + 5; f->ff->zs->avail_out = f->obufsize - 5; return (retval); } /********************************************************************** * Run the compression engine * Returns -1 if there are trouble writing data */ static int fifolog_write_gzip(struct fifolog_writer *f, time_t now) { int i, fl, retval = 0; assert(now != 0); if (f->cleanup || now >= (int)(f->lastsync + f->syncrate)) { f->cleanup = 0; fl = Z_FINISH; f->cnt[FIFOLOG_PT_SYNC]++; } else if (now >= (int)(f->lastwrite + f->writerate)) { fl = Z_SYNC_FLUSH; f->cnt[FIFOLOG_PT_FLUSH]++; } else if (f->ibufptr == 0) return (0); else fl = Z_NO_FLUSH; f->ff->zs->avail_in = f->ibufptr; f->ff->zs->next_in = f->ibuf; while (1) { i = deflate(f->ff->zs, fl); assert(i == Z_OK || i == Z_BUF_ERROR || i == Z_STREAM_END); i = fifolog_write_output(f, fl, now); if (i == 0) break; if (i < 0) retval = -1; } assert(f->ff->zs->avail_in == 0); f->ibufptr = 0; if (fl == Z_FINISH) { f->flag |= FIFOLOG_FLG_SYNC; f->ff->zs->next_out = f->obuf + 9; f->ff->zs->avail_out = f->obufsize - 9; f->lastsync = now; assert(Z_OK == deflateReset(f->ff->zs)); } return (retval); } /********************************************************************** * Poll to see if we need to flush out a record * Returns -1 if there are trouble writing data */ int fifolog_write_poll(struct fifolog_writer *f, time_t now) { if (now == 0) time(&now); return (fifolog_write_gzip(f, now)); } /********************************************************************** * Attempt to write an entry into the ibuf. * Return zero if there is no space, one otherwise */ int fifolog_write_record(struct fifolog_writer *f, uint32_t id, time_t now, const void *ptr, ssize_t len) { const unsigned char *p; uint8_t buf[9]; ssize_t bufl; fifolog_write_assert(f); assert(!(id & (FIFOLOG_TIMESTAMP|FIFOLOG_LENGTH))); assert(ptr != NULL); p = ptr; if (len == 0) { len = strlen(ptr); len++; } else { assert(len <= 255); id |= FIFOLOG_LENGTH; } assert (len > 0); /* Do a timestamp, if needed */ if (now == 0) time(&now); if (now != f->last) id |= FIFOLOG_TIMESTAMP; /* Emit instance+flag */ be32enc(buf, id); bufl = 4; if (id & FIFOLOG_TIMESTAMP) { be32enc(buf + bufl, (uint32_t)now); bufl += 4; } if (id & FIFOLOG_LENGTH) buf[bufl++] = (u_char)len; if (bufl + len + f->ibufptr > f->ibufsize) return (0); memcpy(f->ibuf + f->ibufptr, buf, bufl); f->ibufptr += bufl; memcpy(f->ibuf + f->ibufptr, p, len); f->ibufptr += len; f->cnt[FIFOLOG_PT_BYTES_PRE] += bufl + len; if (id & FIFOLOG_TIMESTAMP) f->last = now; return (1); } /********************************************************************** * Write an entry, polling the gzip/writer until success. * Long binary entries are broken into 255 byte chunks. * Returns -1 if there are problems writing data */ int fifolog_write_record_poll(struct fifolog_writer *f, uint32_t id, time_t now, const void *ptr, ssize_t len) { u_int l; const unsigned char *p; int retval = 0; if (now == 0) time(&now); fifolog_write_assert(f); assert(!(id & (FIFOLOG_TIMESTAMP|FIFOLOG_LENGTH))); assert(ptr != NULL); if (len == 0) { if (!fifolog_write_record(f, id, now, ptr, len)) { if (fifolog_write_gzip(f, now) < 0) retval = -1; /* The string could be too long for the ibuf, so... */ if (!fifolog_write_record(f, id, now, ptr, len)) retval = -1; } } else { for (p = ptr; len > 0; len -= l, p += l) { l = len; if (l > 255) l = 255; while (!fifolog_write_record(f, id, now, p, l)) if (fifolog_write_gzip(f, now) < 0) retval = -1; } } if (fifolog_write_gzip(f, now) < 0) retval = -1; fifolog_write_assert(f); return (retval); } Index: stable/11/usr.sbin/fifolog/lib/miniobj.h =================================================================== --- stable/11/usr.sbin/fifolog/lib/miniobj.h (revision 306908) +++ stable/11/usr.sbin/fifolog/lib/miniobj.h (revision 306909) @@ -1,74 +1,74 @@ /*- * Copyright (c) 2005-2008 Poul-Henning Kamp * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0) #define FREE_OBJ(to) \ do { \ (to)->magic = (0); \ free(to); \ } while (0) #define VALID_OBJ(ptr, type_magic) \ ((ptr) != NULL && (ptr)->magic == (type_magic)) #define CHECK_OBJ(ptr, type_magic) \ do { \ assert((ptr)->magic == type_magic); \ } while (0) #define CHECK_OBJ_NOTNULL(ptr, type_magic) \ do { \ assert((ptr) != NULL); \ assert((ptr)->magic == type_magic); \ } while (0) #define CHECK_OBJ_ORNULL(ptr, type_magic) \ do { \ if ((ptr) != NULL) \ assert((ptr)->magic == type_magic); \ } while (0) #define CAST_OBJ(to, from, type_magic) \ do { \ (to) = (from); \ if ((to) != NULL) \ CHECK_OBJ((to), (type_magic)); \ } while (0) #define CAST_OBJ_NOTNULL(to, from, type_magic) \ do { \ (to) = (from); \ assert((to) != NULL); \ CHECK_OBJ((to), (type_magic)); \ } while (0) Index: stable/11 =================================================================== --- stable/11 (revision 306908) +++ stable/11 (revision 306909) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r305812