Date: Fri, 25 Feb 2011 09:40:17 +0000 (UTC) From: Poul-Henning Kamp <phk@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r219027 - in head/usr.sbin/fifolog: fifolog_create fifolog_reader fifolog_writer lib Message-ID: <201102250940.p1P9eH7k006116@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: phk Date: Fri Feb 25 09:40:17 2011 New Revision: 219027 URL: http://svn.freebsd.org/changeset/base/219027 Log: Fix a bunch of trivial whitespace mistakes and update the miniobj.h file before the real work starts. Modified: head/usr.sbin/fifolog/fifolog_create/fifolog_create.c head/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c head/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c head/usr.sbin/fifolog/lib/fifolog.h head/usr.sbin/fifolog/lib/fifolog_create.c head/usr.sbin/fifolog/lib/fifolog_int.c head/usr.sbin/fifolog/lib/fifolog_reader.c head/usr.sbin/fifolog/lib/fifolog_write_poll.c head/usr.sbin/fifolog/lib/miniobj.h Modified: head/usr.sbin/fifolog/fifolog_create/fifolog_create.c ============================================================================== --- head/usr.sbin/fifolog/fifolog_create/fifolog_create.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/fifolog_create/fifolog_create.c Fri Feb 25 09:40:17 2011 (r219027) @@ -78,11 +78,11 @@ main(int argc, char * const *argv) } argc -= optind; argv += optind; - if (argc != 1) + if (argc != 1) usage(); if (size != 0 && reccnt != 0 && recsize != 0) { /* N N N */ - if (size != reccnt * recsize) + if (size != reccnt * recsize) errx(1, "Inconsistent -l, -r and -s values"); } else if (size != 0 && reccnt != 0 && recsize == 0) { /* N N Z */ if (size % reccnt) Modified: head/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c ============================================================================== --- head/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c Fri Feb 25 09:40:17 2011 (r219027) @@ -156,7 +156,7 @@ main(int argc, char * const *argv) errx(1, "Begin time not before End time"); fl = fifolog_reader_open(argv[0]); - + if (!strcmp(opt_o, "-")) fo = stdout; else { Modified: head/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c ============================================================================== --- head/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c Fri Feb 25 09:40:17 2011 (r219027) @@ -76,7 +76,7 @@ main(int argc, char * const *argv) } argc -= optind; argv += optind; - if (argc != 1) + if (argc != 1) usage(); if (z_opt > 9) Modified: head/usr.sbin/fifolog/lib/fifolog.h ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog.h Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/lib/fifolog.h Fri Feb 25 09:40:17 2011 (r219027) @@ -68,7 +68,7 @@ * present in these records as well: * 5 32be time_t containing POSIX's understanding of UTC. * - * These fields are immediately followed by the inner layer payload as + * These fields are immediately followed by the inner layer payload as * described below, which has variable length. * * If the inner layer payload is shorter than the available space in @@ -95,10 +95,10 @@ * * The inner layer: * ---------------- - * The inner layer contains data identification and to the second - * timestamping (the timestamp in the outer layer only marks the + * The inner layer contains data identification and to the second + * timestamping (the timestamp in the outer layer only marks the * first possible timestamp for content in the SYNC record). - * + * * offset type contents * -------------------------------------------------------------- * 0 32be ident Modified: head/usr.sbin/fifolog/lib/fifolog_create.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_create.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/lib/fifolog_create.c Fri Feb 25 09:40:17 2011 (r219027) @@ -91,7 +91,7 @@ fifolog_create(const char *fn, off_t siz if (size == 0 && S_ISREG(st.st_mode)) size = st.st_size; - if (size == 0) + if (size == 0) size = recsize * (off_t)(24*60*60); if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0) Modified: head/usr.sbin/fifolog/lib/fifolog_int.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_int.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/lib/fifolog_int.c Fri Feb 25 09:40:17 2011 (r219027) @@ -66,7 +66,7 @@ fifo_zfree(voidpf opaque __unused, voidp * Return value is NULL for success or a error description string to * be augmented by errno if non-zero. * - * The second function is just an error-handling wrapper around the + * The second function is just an error-handling wrapper around the * first which, does the actual work. */ @@ -88,7 +88,7 @@ fifolog_int_open_i(struct fifolog_file * if (i != 0) { i = fstat(f->fd, &st); - if (!S_ISREG(st.st_mode)) + if (!S_ISREG(st.st_mode)) return ("Neither disk nor regular file"); f->recsize = 512; f->logsize = st.st_size; Modified: head/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_reader.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/lib/fifolog_reader.c Fri Feb 25 09:40:17 2011 (r219027) @@ -48,7 +48,7 @@ struct fifolog_reader { #define FIFOLOG_READER_MAGIC 0x1036d139 struct fifolog_file *ff; unsigned olen; - unsigned char *obuf; + unsigned char *obuf; time_t now; }; @@ -75,7 +75,7 @@ fifolog_reader_open(const char *fname) i = inflateInit(fr->ff->zs); assert(i == Z_OK); - fr->magic = FIFOLOG_READER_MAGIC; + fr->magic = FIFOLOG_READER_MAGIC; return (fr); } @@ -144,7 +144,7 @@ fifolog_reader_seek(const struct fifolog e = fifolog_reader_findsync(fr->ff, &o); if (e == 0) return (0); /* empty fifolog */ - assert(e == 1); + assert(e == 1); assert(fr->ff->recbuf[4] & FIFOLOG_FLG_SYNC); seq = be32dec(fr->ff->recbuf); @@ -297,7 +297,7 @@ fifolog_reader_process(struct fifolog_re zs->avail_out, fr->olen); exit (250); #else - + i = Z_OK; #endif } @@ -312,7 +312,7 @@ fifolog_reader_process(struct fifolog_re if (zs->avail_out != fr->olen) { q = fr->obuf + (fr->olen - zs->avail_out); p = fifolog_reader_chop(fr, func, priv); - if (p < q) + if (p < q) (void)memmove(fr->obuf, p, q - p); zs->avail_out = fr->olen - (q - p); zs->next_out = fr->obuf + (q - p); Modified: head/usr.sbin/fifolog/lib/fifolog_write_poll.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_write_poll.c Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/lib/fifolog_write_poll.c Fri Feb 25 09:40:17 2011 (r219027) @@ -52,12 +52,12 @@ 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" + [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" }; /* @@ -182,7 +182,7 @@ fifolog_write_output(struct fifolog_writ return (0); - if (h + l < (long)f->ff->recsize && fl == Z_NO_FLUSH) + if (h + l < (long)f->ff->recsize && fl == Z_NO_FLUSH) return (0); w = f->ff->recsize - l; @@ -258,7 +258,7 @@ fprintf(stderr, "Z len %3d fin %d now %l #ifdef DBG if (i || f->ff->zs->avail_in) -fprintf(stderr, "fl = %d, i = %d ai = %u ao = %u fx=%02x\n", fl, i, +fprintf(stderr, "fl = %d, i = %d ai = %u ao = %u fx=%02x\n", fl, i, f->ff->zs->avail_in, f->ff->zs->avail_out, f->flag); #endif @@ -321,7 +321,7 @@ fifolog_write_bytes(struct fifolog_write if (now != f->last) { id |= FIFOLOG_TIMESTAMP; f->last = now; - } + } /* Emit instance+flag */ be32enc(buf, id); Modified: head/usr.sbin/fifolog/lib/miniobj.h ============================================================================== --- head/usr.sbin/fifolog/lib/miniobj.h Fri Feb 25 09:29:32 2011 (r219026) +++ head/usr.sbin/fifolog/lib/miniobj.h Fri Feb 25 09:40:17 2011 (r219027) @@ -26,11 +26,11 @@ * $FreeBSD$ */ -#define ALLOC_OBJ(to, type_magic) \ +#define ALLOC_OBJ(to, type_magic) \ do { \ (to) = calloc(sizeof *(to), 1); \ - assert((to) != NULL); \ - (to)->magic = (type_magic); \ + if ((to) != NULL) \ + (to)->magic = (type_magic); \ } while (0) #define FREE_OBJ(to) \ @@ -39,6 +39,9 @@ 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); \ @@ -50,6 +53,12 @@ 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); \ @@ -57,10 +66,9 @@ CHECK_OBJ((to), (type_magic)); \ } while (0) -#define CAST_OBJ_NOTNULL(to, from, type_magic) \ +#define CAST_OBJ_NOTNULL(to, from, type_magic) \ do { \ (to) = (from); \ assert((to) != NULL); \ CHECK_OBJ((to), (type_magic)); \ } while (0) -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102250940.p1P9eH7k006116>