From owner-svn-soc-all@FreeBSD.ORG Tue Jul 19 00:00:47 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id DCBCB106570A for ; Tue, 19 Jul 2011 00:00:44 +0000 (UTC) (envelope-from zy@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 19 Jul 2011 00:00:44 +0000 Date: Tue, 19 Jul 2011 00:00:44 +0000 From: zy@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110719000044.DCBCB106570A@hub.freebsd.org> Cc: Subject: socsvn commit: r224426 - in soc2011/zy/nvi-iconv/head/contrib/nvi2: cl common ex vi X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2011 00:00:47 -0000 Author: zy Date: Tue Jul 19 00:00:44 2011 New Revision: 224426 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224426 Log: Updates to git:25ff93c. The memory leak problem is solved. * No extra copying on line cache in 8-bit mode; * Allow strict-aliasing optimization. Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_read.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/gs.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/line.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/msg.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.c soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_subst.c soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_visual.c soc2011/zy/nvi-iconv/head/contrib/nvi2/vi/vs_line.c Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c Tue Jul 19 00:00:44 2011 (r224426) @@ -259,7 +259,9 @@ cl_clrtoeol(SCR *sp) { WINDOW *win; +#if 0 size_t spcnt, y, x; +#endif win = CLSP(sp) ? CLSP(sp) : stdscr; Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_read.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_read.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_read.c Tue Jul 19 00:00:44 2011 (r224426) @@ -152,7 +152,6 @@ struct timeval poll; CL_PRIVATE *clp; GS *gp; - SCR *tsp; fd_set rdfd; input_t rval; int maxfd, nr, term_reset; Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c Tue Jul 19 00:00:44 2011 (r224426) @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp $ (Berkeley) $Date: 2001/08/18 21:41:41 $"; +static const char sccsid[] = "$Id: conv.c,v 1.28 2011/07/16 14:40:06 zy Exp $ (Berkeley) $Date: 2011/07/16 14:40:06 $"; #endif /* not lint */ #include @@ -46,7 +46,7 @@ CHAR_T **dst) { int i; - CHAR_T **tostr = (CHAR_T **)&cw->bp1; + CHAR_T **tostr = &cw->b_wc1; size_t *blen = &cw->blen1; BINC_RETW(NULL, *tostr, *blen, len); @@ -55,7 +55,7 @@ for (i = 0; i < len; ++i) (*tostr)[i] = (u_char) str[i]; - *dst = cw->bp1; + *dst = cw->b_wc1; return 0; } @@ -90,7 +90,7 @@ size_t *tolen, CHAR_T **dst, char *enc) { int i = 0, j; - CHAR_T **tostr = (CHAR_T **)&cw->bp1; + CHAR_T **tostr = &cw->b_wc1; size_t *blen = &cw->blen1; mbstate_t mbs; size_t n; @@ -134,14 +134,14 @@ if (id != (iconv_t)-1) iconv_close(id); - *dst = cw->bp1; + *dst = cw->b_wc1; return 0; err: *tolen = i; if (id != (iconv_t)-1) iconv_close(id); - *dst = cw->bp1; + *dst = cw->b_wc1; return error; } @@ -192,7 +192,7 @@ char **dst) { int i; - char **tostr = (char **)&cw->bp1; + char **tostr = &cw->b_c1; size_t *blen = &cw->blen1; BINC_RETC(NULL, *tostr, *blen, len); @@ -201,7 +201,7 @@ for (i = 0; i < len; ++i) (*tostr)[i] = str[i]; - *dst = cw->bp1; + *dst = cw->b_wc1; return 0; } @@ -211,7 +211,7 @@ size_t *tolen, char **pdst, char *enc) { size_t i, j, offset = 0; - char **tostr = (char **)&cw->bp1; + char **tostr = &cw->b_c1; size_t *blen = &cw->blen1; mbstate_t mbs; size_t n; @@ -232,10 +232,10 @@ char *bp = buffer; \ while (len != 0) { \ size_t outleft = cw->blen1 - offset; \ - char *obp = (char *)cw->bp1 + offset; \ + char *obp = cw->b_c1 + offset; \ if (cw->blen1 < offset + MB_CUR_MAX) { \ nlen += 256; \ - BINC_RETC(NULL, cw->bp1, cw->blen1, nlen); \ + BINC_RETC(NULL, cw->b_c1, cw->blen1, nlen); \ } \ errno = 0; \ if (iconv(id, &bp, &len, &obp, &outleft) == -1 && \ @@ -286,13 +286,13 @@ *tolen = offset; } - *pdst = cw->bp1; + *pdst = cw->b_c1; return 0; err: *tolen = j; - *pdst = cw->bp1; + *pdst = cw->b_c1; return 1; } Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.h Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.h Tue Jul 19 00:00:44 2011 (r224426) @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: conv.h,v 1.27 2001/08/18 21:41:41 skimo Exp $ (Berkeley) $Date: 2001/08/18 21:41:41 $ + * $Id: conv.h,v 1.28 2011/07/16 14:40:38 zy Exp $ (Berkeley) $Date: 2011/07/16 14:40:38 $ */ #define KEY_COL(sp, ch) \ @@ -15,7 +15,10 @@ KEY_LEN(sp,ch)) struct _conv_win { - void *bp1; + union { + char *b_c1; + CHAR_T *b_wc1; + }; size_t blen1; }; Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h Tue Jul 19 00:00:44 2011 (r224426) @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: cut.h,v 10.9 2000/07/22 17:31:18 skimo Exp $ (Berkeley) $Date: 2000/07/22 17:31:18 $ + * $Id: cut.h,v 10.10 2011/07/16 18:06:00 zy Exp $ (Berkeley) $Date: 2011/07/16 18:06:00 $ */ typedef struct _texth TEXTH; /* TEXT list head structure. */ @@ -16,8 +16,7 @@ struct _cb { LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */ TEXTH textq; /* Linked list of TEXT structures. */ - /* XXXX Needed ? Can non ascii-chars be cut buffer names ? */ - CHAR_T name; /* Cut buffer name. */ + char name; /* Cut buffer name. */ size_t len; /* Total length of cut text. */ #define CB_LMODE 0x01 /* Cut was in line mode. */ Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c Tue Jul 19 00:00:44 2011 (r224426) @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: exf.c,v 10.50 2011/06/26 21:14:46 zy Exp $ (Berkeley) $Date: 2011/06/26 21:14:46 $"; +static const char sccsid[] = "$Id: exf.c,v 10.52 2011/07/18 16:58:54 zy Exp $ (Berkeley) $Date: 2011/07/18 16:58:54 $"; #endif /* not lint */ #include @@ -407,6 +407,9 @@ /* Set the initial cursor position, queue initial command. */ file_cinit(sp); + /* Report conversion errors again. */ + F_CLR(sp, SC_CONV_ERROR); + /* Redraw the screen from scratch, schedule a welcome message. */ F_SET(sp, SC_SCR_REFORMAT | SC_STATUS); @@ -718,6 +721,8 @@ free(ep->rcv_path); if (ep->rcv_mpath != NULL) free(ep->rcv_mpath); + if (ep->c_lp != NULL) + free(ep->c_lp); free(ep); return (0); Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/gs.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/gs.h Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/gs.h Tue Jul 19 00:00:44 2011 (r224426) @@ -124,8 +124,8 @@ #define KEY_VAL(sp, ch) \ ((UCHAR_T)(ch) <= MAX_FAST_KEY ? \ - sp->gp->special_key[(UCHAR_T)ch] : \ - (UCHAR_T)(ch) > sp->gp->max_special ? 0 : v_key_val(sp,ch)) + sp->gp->special_key[(UCHAR_T)ch] : \ + (UCHAR_T)(ch) > sp->gp->max_special ? K_NOTUSED : v_key_val(sp,ch)) CHAR_T max_special; /* Max special character. */ u_char /* Fast lookup table. */ special_key[MAX_FAST_KEY + 1]; Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/line.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/line.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/line.c Tue Jul 19 00:00:44 2011 (r224426) @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: line.c,v 10.22 2011/07/01 02:30:16 zy Exp $ (Berkeley) $Date: 2011/07/01 02:30:16 $"; +static const char sccsid[] = "$Id: line.c,v 10.24 2011/07/18 16:10:48 zy Exp $ (Berkeley) $Date: 2011/07/18 16:10:48 $"; #endif /* not lint */ #include @@ -139,7 +139,7 @@ } /* Look-aside into the cache, and see if the line we want is there. */ - if (0 && lno == ep->c_lno) { + if (lno == ep->c_lno) { #if defined(DEBUG) && 0 TRACE(sp, "retrieve cached line %lu\n", (u_long)lno); #endif @@ -154,14 +154,11 @@ nocache: nlen = 1024; retry: - /* data.size contains length in bytes */ - BINC_GOTO(sp, CHAR_T, ep->c_lp, ep->c_blen, nlen); - /* Get the line from the underlying database. */ key.data = &lno; key.size = sizeof(lno); switch (ep->db->get(ep->db, &key, &data, 0)) { - case -1: + case -1: goto err2; case 1: err1: if (LF_ISSET(DBG_FATAL)) @@ -176,23 +173,23 @@ if (data.size > nlen) { nlen = data.size; goto retry; - } else - memcpy(ep->c_lp, data.data, nlen); + } } if (FILE2INT(sp, data.data, data.size, wp, wlen)) { - if (!F_ISSET(sp, SC_CONV_ERROR)) { - F_SET(sp, SC_CONV_ERROR); - msgq(sp, M_ERR, "324|Conversion error on line %d", lno); - } - goto err3; + if (!F_ISSET(sp, SC_CONV_ERROR)) { + F_SET(sp, SC_CONV_ERROR); + msgq(sp, M_ERR, "324|Conversion error on line %d", lno); + } + goto err3; } /* Reset the cache. */ if (wp != data.data) { - BINC_GOTOW(sp, ep->c_lp, ep->c_blen, wlen); - MEMCPYW(ep->c_lp, wp, wlen); - } + BINC_GOTOW(sp, ep->c_lp, ep->c_blen, wlen); + MEMCPYW(ep->c_lp, wp, wlen); + } else + ep->c_lp = data.data; ep->c_lno = lno; ep->c_len = wlen; @@ -547,30 +544,31 @@ key.size = sizeof(lno); switch (ep->db->seq(ep->db, &key, &data, R_LAST)) { - case 1: - *lnop = 0; - return (0); case -1: alloc_err: - msgq(sp, M_DBERR, "007|unable to get last line"); + msgq(sp, M_SYSERR, "007|unable to get last line"); *lnop = 0; return (1); - case 0: + case 1: + *lnop = 0; + return (0); + case 0: ; } memcpy(&lno, key.data, sizeof(lno)); if (lno != ep->c_lno) { - FILE2INT(sp, data.data, data.size, wp, wlen); + FILE2INT(sp, data.data, data.size, wp, wlen); - /* Fill the cache. */ - if (wp != data.data) { - BINC_GOTOW(sp, ep->c_lp, ep->c_blen, wlen); - MEMCPYW(ep->c_lp, wp, wlen); - } - ep->c_lno = lno; - ep->c_len = wlen; + /* Fill the cache. */ + if (wp != data.data) { + BINC_GOTOW(sp, ep->c_lp, ep->c_blen, wlen); + MEMCPYW(ep->c_lp, wp, wlen); + } else + ep->c_lp = data.data; + ep->c_lno = lno; + ep->c_len = wlen; } ep->c_nlines = lno; Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h Tue Jul 19 00:00:44 2011 (r224426) @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: mark.h,v 10.6 2011/07/04 14:41:51 zy Exp $ (Berkeley) $Date: 2011/07/04 14:41:51 $ + * $Id: mark.h,v 10.7 2011/07/16 18:07:30 zy Exp $ (Berkeley) $Date: 2011/07/16 18:07:30 $ */ /* @@ -31,8 +31,7 @@ LIST_ENTRY(_lmark) q; /* Linked list of marks. */ recno_t lno; /* Line number. */ size_t cno; /* Column number. */ - /* XXXX Needed ? Can non ascii-chars be mark names ? */ - CHAR_T name; /* Mark name. */ + char name; /* Mark name. */ #define MARK_DELETED 0x01 /* Mark was deleted. */ #define MARK_USERSET 0x02 /* User set this mark. */ Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/msg.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/msg.h Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/msg.h Tue Jul 19 00:00:44 2011 (r224426) @@ -38,7 +38,7 @@ * of them by the message routines. */ typedef enum { - M_NONE = 1, M_BERR, M_ERR, M_INFO, M_SYSERR, M_VINFO, M_DBERR } mtype_t; + M_NONE = 1, M_BERR, M_ERR, M_INFO, M_SYSERR, M_VINFO } mtype_t; /* * There are major problems with error messages being generated by routines Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h Tue Jul 19 00:00:44 2011 (r224426) @@ -1,3 +1,14 @@ +/*- + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1992, 1993, 1994, 1995, 1996 + * Keith Bostic. All rights reserved. + * + * See the LICENSE file for redistribution information. + * + * $Id: multibyte.h,v 1.28 2011/07/16 18:40:01 zy Exp $ (Berkeley) $Date: 2011/07/16 18:40:01 $ + */ + #ifndef MULTIBYTE_H #define MULTIBYTE_H @@ -13,18 +24,15 @@ * * If no integral type can hold a character, don't even try the port. */ -typedef u_int ARG_CHAR_T; +typedef int ARG_CHAR_T; #ifdef USE_WIDECHAR #include #include -typedef wchar_t RCHAR_T; -#define RCHAR_T_MAX ((1 << 24)-1) typedef wchar_t CHAR_T; -#define MAX_CHAR_T 0xffffff /* XXXX */ +#define MAX_CHAR_T 0x7fffffff typedef u_int UCHAR_T; -#define RCHAR_BIT 24 #define STRLEN wcslen #define STRTOL wcstol @@ -34,16 +42,14 @@ #define STRPBRK wcspbrk #define TOUPPER towupper #define STRSET wmemset +#define VSPRINTF vswprintf #define L(ch) L ## ch #else -typedef char RCHAR_T; -#define RCHAR_T_MAX CHAR_MAX typedef u_char CHAR_T; #define MAX_CHAR_T 0xff typedef u_char UCHAR_T; -#define RCHAR_BIT CHAR_BIT #define STRLEN strlen #define STRTOL strtol @@ -53,6 +59,7 @@ #define STRPBRK strpbrk #define TOUPPER toupper #define STRSET memset +#define VSPRINTF vsnprintf #define L(ch) ch Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.c Tue Jul 19 00:00:44 2011 (r224426) @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: screen.c,v 10.23 2011/06/26 23:11:11 zy Exp $ (Berkeley) $Date: 2011/06/26 23:11:11 $"; +static const char sccsid[] = "$Id: screen.c,v 10.24 2011/07/18 16:58:31 zy Exp $ (Berkeley) $Date: 2011/07/18 16:58:31 $"; #endif /* not lint */ #include @@ -188,6 +188,8 @@ free(sp->repl); if (sp->newl != NULL) free(sp->newl); + if (sp->cw.b_c1 != NULL) + free(sp->cw.b_c1); /* Free all the options */ opts_free(sp); Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_subst.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_subst.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_subst.c Tue Jul 19 00:00:44 2011 (r224426) @@ -353,7 +353,7 @@ int cflag, lflag, nflag, pflag, rflag; int didsub, do_eol_match, eflags, empty_ok, eval; int linechanged, matched, quit, rval; - CHAR_T *p, *lb, *bp; + CHAR_T *bp, *lb; enum nresult nret; NEEDFILE(sp, cmdp); Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_visual.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_visual.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_visual.c Tue Jul 19 00:00:44 2011 (r224426) @@ -81,9 +81,9 @@ if (FL_ISSET(cmdp->iflags, E_C_COUNT)) len = snprintf(buf, sizeof(buf), - "%luz%c%lu", sp->lno, pos, cmdp->count); + "%luz%c%lu", (u_long)sp->lno, pos, cmdp->count); else - len = snprintf(buf, sizeof(buf), "%luz%c", sp->lno, pos); + len = snprintf(buf, sizeof(buf), "%luz%c", (u_long)sp->lno, pos); CHAR2INT(sp, buf, len, wp, wlen); (void)v_event_push(sp, NULL, wp, wlen, CH_NOMAP | CH_QUOTED); Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/vi/vs_line.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/vi/vs_line.c Mon Jul 18 22:00:21 2011 (r224425) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/vi/vs_line.c Tue Jul 19 00:00:44 2011 (r224426) @@ -139,7 +139,7 @@ cols_per_screen -= O_NUMBER_LENGTH; if ((!dne || smp->lno == 1) && skip_cols == 0) { nlen = snprintf((char*)cbuf, - sizeof(cbuf), O_NUMBER_FMT, smp->lno); + sizeof(cbuf), O_NUMBER_FMT, (u_long)smp->lno); (void)gp->scr_addstr(sp, (char*)cbuf, nlen); } } @@ -532,7 +532,7 @@ break; (void)gp->scr_move(sp, smp - HMAP, 0); - len = snprintf(nbuf, sizeof(nbuf), O_NUMBER_FMT, smp->lno); + len = snprintf(nbuf, sizeof(nbuf), O_NUMBER_FMT, (u_long)smp->lno); (void)gp->scr_addstr(sp, nbuf, len); } (void)gp->scr_move(sp, oldy, oldx); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 22 11:19:55 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7805E106566C for ; Fri, 22 Jul 2011 11:19:53 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 22 Jul 2011 11:19:53 +0000 Date: Fri, 22 Jul 2011 11:19:53 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110722111953.7805E106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r224488 - in soc2011/oleksandr/oleksandr-head/head/sys: cam kern sys X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2011 11:19:55 -0000 Author: oleksandr Date: Fri Jul 22 11:19:53 2011 New Revision: 224488 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224488 Log: Add new type of disk error:other that including errors associated with requests for control Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c ============================================================================== --- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c Fri Jul 22 09:39:49 2011 (r224487) +++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c Fri Jul 22 11:19:53 2011 (r224488) @@ -4142,58 +4142,66 @@ { struct cam_sim *sim; int first; - int i,num_error=0; + int i, num_error = 0; struct devstat *device_error; devstat_error_flags error_flag[NUMBER_TYPE_ERRORS]; /* * If the error is fatal refer it to the type of non retry able. */ - if ((done_ccb->ccb_h.status_test==CAM_REQ_CMP_ERR)|| - (done_ccb->ccb_h.status_test==CAM_TID_INVALID)|| - (done_ccb->ccb_h.status_test==CAM_SCSI_STATUS_ERROR)|| - (done_ccb->ccb_h.status_test==CAM_AUTOSENSE_FAIL)|| - (done_ccb->ccb_h.status_test==CAM_LUN_INVALID)) { - error_flag[num_error]=DEVSTAT_ERROR_NON_RETRIABLE; + if (done_ccb->ccb_h.status_test == CAM_REQ_CMP_ERR || + done_ccb->ccb_h.status_test == CAM_TID_INVALID || + done_ccb->ccb_h.status_test == CAM_SCSI_STATUS_ERROR || + done_ccb->ccb_h.status_test == CAM_AUTOSENSE_FAIL || + done_ccb->ccb_h.status_test == CAM_LUN_INVALID) { + error_flag[num_error] = DEVSTAT_ERROR_NON_RETRIABLE; num_error++; } /* * If the error is not fatal refer it to the type of retry able. */ - if ((done_ccb->ccb_h.status_test==CAM_SEL_TIMEOUT)|| - (done_ccb->ccb_h.status_test==CAM_SCSI_BUSY)|| - (done_ccb->ccb_h.status_test==CAM_SIM_QUEUED)|| - (done_ccb->ccb_h.status_test==CAM_FUNC_NOTAVAIL)|| - (done_ccb->ccb_h.status_test==CAM_REQ_INVALID)|| - (done_ccb->ccb_h.status_test==CAM_REQUEUE_REQ)) { - error_flag[num_error]=DEVSTAT_ERROR_RETRIABLE; + if (done_ccb->ccb_h.status_test == CAM_SEL_TIMEOUT || + done_ccb->ccb_h.status_test == CAM_SCSI_BUSY || + done_ccb->ccb_h.status_test == CAM_SIM_QUEUED || + done_ccb->ccb_h.status_test == CAM_FUNC_NOTAVAIL || + done_ccb->ccb_h.status_test == CAM_REQ_INVALID || + done_ccb->ccb_h.status_test == CAM_REQUEUE_REQ) { + error_flag[num_error] = DEVSTAT_ERROR_RETRIABLE; num_error++; } /* - * If the error is write error refer it to the type of write error + * If the error is write error refer it to the type of write error. */ - if ((done_ccb->ccb_h.flags==CAM_DIR_OUT)&& - (done_ccb->ccb_h.status_test!=CAM_REQ_CMP)) { - error_flag[num_error]=DEVSTAT_ERROR_WRITE_ERROR; + if (done_ccb->ccb_h.flags == CAM_DIR_OUT && + done_ccb->ccb_h.status_test != CAM_REQ_CMP) { + error_flag[num_error] = DEVSTAT_ERROR_WRITE_ERROR; num_error++; } /* * If the error is read error refer it to the type of read error */ - if ((done_ccb->ccb_h.flags==CAM_DIR_IN)&& - (done_ccb->ccb_h.status_test!=CAM_REQ_CMP)) { - error_flag[num_error]=DEVSTAT_ERROR_READ_ERROR; + if (done_ccb->ccb_h.flags == CAM_DIR_IN && + done_ccb->ccb_h.status_test != CAM_REQ_CMP) { + error_flag[num_error] = DEVSTAT_ERROR_READ_ERROR; + num_error++; + } + /* + * If the request is countrol and there is no action with data * refer it to the type of other error. + */ + if (((done_ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) && + done_ccb->ccb_h.status_test != CAM_REQ_CMP) { + error_flag[num_error]=DEVSTAT_ERROR_OTHER_ERROR; num_error++; } /* * If an error is present, search for an appropriate structure * in devstat and increase the corresponding counter of errors. */ - for (i=0;iccb_h.path->periph->periph_name, - done_ccb->ccb_h.path->periph->unit_number); - if (device_error!=NULL) + device_error = devstat_search( + done_ccb->ccb_h.path->periph->periph_name, + done_ccb->ccb_h.path->periph->unit_number); + if (device_error != NULL) devstat_add_error(device_error, error_flag[i]); } } Modified: soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c ============================================================================== --- soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c Fri Jul 22 09:39:49 2011 (r224487) +++ soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c Fri Jul 22 11:19:53 2011 (r224488) @@ -212,11 +212,11 @@ mtx_assert(&devstat_mutex, MA_NOTOWNED); int status_match = 0; devstat_head = &device_statq; - if (STAILQ_EMPTY(&device_statq)==0) { + if (STAILQ_EMPTY(&device_statq) == 0) { STAILQ_FOREACH(dv_error, devstat_head, dev_links) { - if ((strcmp(dev_name,dv_error->device_name)==0)&& - (unit_number==dv_error->unit_number)) { - status_match=1; + if (strcmp(dev_name,dv_error->device_name) == 0 && + unit_number == dv_error->unit_number) { + status_match = 1; break; } } @@ -227,7 +227,7 @@ printf("devstat_search: HELP! " "no appropriate device " "for name %p unit %d\n", - dev_name, unit_number); + dev_name, unit_number); return NULL; } } @@ -375,14 +375,16 @@ void devstat_add_error(struct devstat *ds, devstat_error_flags error_flag) { - if (error_flag==DEVSTAT_ERROR_RETRIABLE) + if (error_flag == DEVSTAT_ERROR_RETRIABLE) ds->dev_error.retriable++; - if (error_flag==DEVSTAT_ERROR_NON_RETRIABLE) + if (error_flag == DEVSTAT_ERROR_NON_RETRIABLE) ds->dev_error.non_retriable++; - if (error_flag==DEVSTAT_ERROR_WRITE_ERROR) + if (error_flag == DEVSTAT_ERROR_WRITE_ERROR) ds->dev_error.write_error++; - if (error_flag==DEVSTAT_ERROR_READ_ERROR) + if (error_flag == DEVSTAT_ERROR_READ_ERROR) ds->dev_error.read_error++; + if (error_flag == DEVSTAT_ERROR_OTHER_ERROR) + ds->dev_error.other_error++; } /* * This is the sysctl handler for the devstat package. The data pushed out Modified: soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h ============================================================================== --- soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h Fri Jul 22 09:39:49 2011 (r224487) +++ soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h Fri Jul 22 11:19:53 2011 (r224488) @@ -102,7 +102,8 @@ DEVSTAT_ERROR_RETRIABLE = 0x01, DEVSTAT_ERROR_NON_RETRIABLE = 0x02, DEVSTAT_ERROR_READ_ERROR = 0x03, - DEVSTAT_ERROR_WRITE_ERROR = 0x04 + DEVSTAT_ERROR_WRITE_ERROR = 0x04, + DEVSTAT_ERROR_OTHER_ERROR = 0x05 } devstat_error_flags; /* * These types are intended to aid statistics gathering/display programs. @@ -145,6 +146,7 @@ int non_retriable; int read_error; int write_error; + int other_error; } devstat_device_error; /* * XXX: Next revision should add From owner-svn-soc-all@FreeBSD.ORG Fri Jul 22 11:23:27 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 65DC51065672 for ; Fri, 22 Jul 2011 11:23:25 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 22 Jul 2011 11:23:25 +0000 Date: Fri, 22 Jul 2011 11:23:25 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110722112325.65DC51065672@hub.freebsd.org> Cc: Subject: socsvn commit: r224489 - soc2011/oleksandr/oleksandr-head/head/usr.sbin/iostat X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2011 11:23:27 -0000 Author: oleksandr Date: Fri Jul 22 11:23:25 2011 New Revision: 224489 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224489 Log: Add new type of disk error:other to iostat Modified: soc2011/oleksandr/oleksandr-head/head/usr.sbin/iostat/iostat.c Modified: soc2011/oleksandr/oleksandr-head/head/usr.sbin/iostat/iostat.c ============================================================================== --- soc2011/oleksandr/oleksandr-head/head/usr.sbin/iostat/iostat.c Fri Jul 22 11:19:53 2011 (r224488) +++ soc2011/oleksandr/oleksandr-head/head/usr.sbin/iostat/iostat.c Fri Jul 22 11:23:25 2011 (r224489) @@ -764,8 +764,7 @@ } if (Eflag>0) { printf(" error device statistics\n"); - printf("device retriable non-retriable read error write error" - ); + printf("device retriable non-retriable read write other"); printf("\n"); } for (dn = 0; dn < num_devices; dn++) { @@ -818,11 +817,12 @@ cur.dinfo->devices[di].device_name, cur.dinfo->devices[di].unit_number) == -1) err(1, "asprintf"); - printf("%-8.8s %-12d %-12d %-12d %-12d", + printf("%-8.8s %-10d %-14d %-5d %-6d %-6d", devname, cur.dinfo->devices[di].dev_error.retriable, cur.dinfo->devices[di].dev_error.non_retriable, cur.dinfo->devices[di].dev_error.read_error, - cur.dinfo->devices[di].dev_error.write_error); + cur.dinfo->devices[di].dev_error.write_error, + cur.dinfo->devices[di].dev_error.other_error); printf("\n"); free(devname); }