Date: Sun, 21 Sep 2008 17:54:40 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 150220 for review Message-ID: <200809211754.m8LHseQ0033686@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=150220 Change 150220 by ed@ed_dull on 2008/09/21 17:54:16 Clean up the clists code: - Remove the now unused catq() and nextc() routines, which were only used by the TTY layer. - Change putc()'s argument to `char' instead of `int', there is no more space for quote bits. - Use ISO C prototypes. Affected files ... .. //depot/projects/mpsafetty/sys/kern/subr_clist.c#5 edit .. //depot/projects/mpsafetty/sys/sys/clist.h#3 edit Differences ... ==== //depot/projects/mpsafetty/sys/kern/subr_clist.c#5 (text+ko) ==== @@ -77,8 +77,7 @@ */ /* ARGSUSED*/ static void -clist_init(dummy) - void *dummy; +clist_init(void *dummy) { /* * Allocate an initial base set of cblocks as a 'slush'. @@ -96,7 +95,7 @@ * to it. */ static __inline struct cblock * -cblock_alloc() +cblock_alloc(void) { struct cblock *cblockp; @@ -113,8 +112,7 @@ * Add a cblock to the cfreelist queue. */ static __inline void -cblock_free(cblockp) - struct cblock *cblockp; +cblock_free(struct cblock *cblockp) { cblockp->c_next = cfreelist; cfreelist = cblockp; @@ -125,8 +123,7 @@ * Allocate some cblocks for the cfreelist queue. */ static void -cblock_alloc_cblocks(number) - int number; +cblock_alloc_cblocks(int number) { int i; struct cblock *cbp; @@ -152,10 +149,7 @@ * Must be called in process context at spltty(). */ void -clist_alloc_cblocks(clistp, ccmax, ccreserved) - struct clist *clistp; - int ccmax; - int ccreserved; +clist_alloc_cblocks(struct clist *clistp, int ccmax, int ccreserved) { int dcbr; @@ -184,8 +178,7 @@ * system malloc pool. */ static void -cblock_free_cblocks(number) - int number; +cblock_free_cblocks(int number) { int i; @@ -199,8 +192,7 @@ * Must be called at spltty(). */ void -clist_free_cblocks(clistp) - struct clist *clistp; +clist_free_cblocks(struct clist *clistp) { if (clistp->c_cbcount != 0) panic("freeing active clist cblocks"); @@ -213,8 +205,7 @@ * Get a character from the head of a clist. */ int -getc(clistp) - struct clist *clistp; +getc(struct clist *clistp) { int chr = -1; int s; @@ -261,10 +252,7 @@ * actually copied. */ int -q_to_b(clistp, dest, amount) - struct clist *clistp; - char *dest; - int amount; +q_to_b(struct clist *clistp, char *dest, int amount) { struct cblock *cblockp; struct cblock *cblockn; @@ -310,9 +298,7 @@ * Flush 'amount' of chars, beginning at head of clist 'clistp'. */ void -ndflush(clistp, amount) - struct clist *clistp; - int amount; +ndflush(struct clist *clistp, int amount) { struct cblock *cblockp; struct cblock *cblockn; @@ -355,9 +341,7 @@ * more clists, or 0 for success. */ int -putc(chr, clistp) - int chr; - struct clist *clistp; +putc(char chr, struct clist *clistp) { struct cblock *cblockp; int s; @@ -406,10 +390,7 @@ * number of characters not copied. */ int -b_to_q(src, amount, clistp) - char *src; - int amount; - struct clist *clistp; +b_to_q(char *src, int amount, struct clist *clistp) { struct cblock *cblockp; int numc, s; @@ -492,50 +473,10 @@ } /* - * Get the next character in the clist. Store it at dst. Don't - * advance any clist pointers, but return a pointer to the next - * character position. - */ -char * -nextc(clistp, cp, dst) - struct clist *clistp; - char *cp; - int *dst; -{ - struct cblock *cblockp; - - ++cp; - /* - * See if the next character is beyond the end of - * the clist. - */ - if (clistp->c_cc && (cp != clistp->c_cl)) { - /* - * If the next character is beyond the end of this - * cblock, advance to the next cblock. - */ - if (((intptr_t)cp & CROUND) == 0) - cp = ((struct cblock *)cp - 1)->c_next->c_info; - cblockp = (struct cblock *)((intptr_t)cp & ~CROUND); - - /* - * Get the character. Set the quote flag if this character - * is quoted. - */ - *dst = (u_char)*cp; - - return (cp); - } - - return (NULL); -} - -/* * "Unput" a character from a clist. */ int -unputc(clistp) - struct clist *clistp; +unputc(struct clist *clistp) { struct cblock *cblockp = 0, *cbp = 0; int s; @@ -590,45 +531,3 @@ splx(s); return (chr); } - -/* - * Move characters in source clist to destination clist, - * preserving quote bits. - */ -void -catq(src_clistp, dest_clistp) - struct clist *src_clistp, *dest_clistp; -{ - int chr, s; - - s = spltty(); - /* - * If the destination clist is empty (has no cblocks atttached), - * and there are no possible complications with the resource counters, - * then we simply assign the current clist to the destination. - */ - if (!dest_clistp->c_cf - && src_clistp->c_cbcount <= src_clistp->c_cbmax - && src_clistp->c_cbcount <= dest_clistp->c_cbmax) { - dest_clistp->c_cf = src_clistp->c_cf; - dest_clistp->c_cl = src_clistp->c_cl; - src_clistp->c_cf = src_clistp->c_cl = NULL; - - dest_clistp->c_cc = src_clistp->c_cc; - src_clistp->c_cc = 0; - dest_clistp->c_cbcount = src_clistp->c_cbcount; - src_clistp->c_cbcount = 0; - - splx(s); - return; - } - - splx(s); - - /* - * XXX This should probably be optimized to more than one - * character at a time. - */ - while ((chr = getc(src_clistp)) != -1) - putc(chr, dest_clistp); -} ==== //depot/projects/mpsafetty/sys/sys/clist.h#3 (text+ko) ==== @@ -57,13 +57,11 @@ extern int cfreecount; int b_to_q(char *cp, int cc, struct clist *q); -void catq(struct clist *from, struct clist *to); void clist_alloc_cblocks(struct clist *q, int ccmax, int ccres); void clist_free_cblocks(struct clist *q); int getc(struct clist *q); void ndflush(struct clist *q, int cc); -char *nextc(struct clist *q, char *cp, int *c); -int putc(int c, struct clist *q); +int putc(char c, struct clist *q); int q_to_b(struct clist *q, char *cp, int cc); int unputc(struct clist *q); #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809211754.m8LHseQ0033686>