From b3eecec38a538f44aa1440c622e4ed4f758d1265 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 13 Nov 2007 17:56:48 +0100 Subject: [PATCH] avoid casts in left hand sides of assignments. Recent gcc's don't like them. --- cl/cl_funcs.c | 8 ++--- cl/cl_screen.c | 2 +- common/conv.c | 8 ++--- common/db.c | 2 +- common/db1.c | 2 +- common/exf.c | 2 +- common/key.c | 2 +- common/log.c | 8 ++--- common/mem.h | 92 +++++++++++++++++++++++++++++----------------------------- common/msg.c | 8 ++--- ex/ex_cscope.c | 2 +- ex/ex_util.c | 2 +- vi/v_txt.c | 2 +- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/cl/cl_funcs.c b/cl/cl_funcs.c index 79e17542..adc109ad 100644 --- a/cl/cl_funcs.c +++ b/cl/cl_funcs.c @@ -381,7 +381,7 @@ cl_discard(SCR *discardp, SCR **acquirep) if (CLSP(discardp)) { delwin(CLSP(discardp)); - CLSP(discardp) = NULL; + discardp->cl_private = NULL; } } @@ -395,7 +395,7 @@ cl_discard(SCR *discardp, SCR **acquirep) if (CLSP(tsp)) delwin(CLSP(tsp)); - CLSP(tsp) = subwin(stdscr, tsp->rows, tsp->cols, + tsp->cl_private = subwin(stdscr, tsp->rows, tsp->cols, tsp->roff, tsp->coff); } @@ -716,9 +716,9 @@ cl_split(SCR *origp, SCR *newp) if (CLSP(origp)) delwin(CLSP(origp)); - CLSP(origp) = subwin(stdscr, origp->rows, origp->cols, + origp->cl_private = subwin(stdscr, origp->rows, origp->cols, origp->roff, origp->coff); - CLSP(newp) = subwin(stdscr, newp->rows, newp->cols, + newp->cl_private = subwin(stdscr, newp->rows, newp->cols, newp->roff, newp->coff); /* origp is the original screen, giving up space to newp. */ diff --git a/cl/cl_screen.c b/cl/cl_screen.c index 292b88d1..d8d16296 100644 --- a/cl/cl_screen.c +++ b/cl/cl_screen.c @@ -56,7 +56,7 @@ cl_screen(SCR *sp, u_int32_t flags) if (F_ISSET(gp, G_SRESTART)) { if (CLSP(sp)) { delwin(CLSP(sp)); - CLSP(sp) = NULL; + sp->cl_private = NULL; } if (cl_quit(gp)) return (1); diff --git a/common/conv.c b/common/conv.c index d163425c..02dfd32b 100644 --- a/common/conv.c +++ b/common/conv.c @@ -195,7 +195,7 @@ int2raw(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, size_t *tolen, char **tostr = (char **)&cw->bp1; size_t *blen = &cw->blen1; - BINC_RET(NULL, *tostr, *blen, len); + BINC_RETC(NULL, *tostr, *blen, len); *tolen = len; for (i = 0; i < len; ++i) @@ -235,7 +235,7 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, char *obp = (char *)cw->bp1 + offset; \ if (cw->blen1 < offset + MB_CUR_MAX) { \ nlen += 256; \ - BINC_RET(NULL, cw->bp1, cw->blen1, nlen); \ + BINC_RETC(NULL, cw->bp1, cw->blen1, nlen); \ } \ errno = 0; \ if (iconv(id, &bp, &len, &obp, &outleft) == -1 && \ @@ -250,7 +250,7 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, MEMSET(&mbs, 0, 1); - BINC_RET(NULL, *tostr, *blen, nlen); + BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; #ifdef USE_ICONV @@ -271,7 +271,7 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, CONVERT2(j, cw, offset); } else { nlen += 256; - BINC_RET(NULL, *tostr, *blen, nlen); + BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; } } diff --git a/common/db.c b/common/db.c index 38932946..dcaa08e1 100644 --- a/common/db.c +++ b/common/db.c @@ -159,7 +159,7 @@ nocache: nlen = 1024; retry: /* data.size contains length in bytes */ - BINC_GOTO(sp, (char *)sp->c_lp, sp->c_blen, nlen); + BINC_GOTO(sp, CHAR_T, sp->c_lp, sp->c_blen, nlen); /* Get the line from the underlying database. */ memset(&key, 0, sizeof(key)); diff --git a/common/db1.c b/common/db1.c index 7cb39651..86430daa 100644 --- a/common/db1.c +++ b/common/db1.c @@ -163,7 +163,7 @@ nocache: nlen = 1024; retry: /* data.size contains length in bytes */ - BINC_GOTO(sp, (char *)ep->c_lp, ep->c_blen, nlen); + BINC_GOTO(sp, CHAR_T, ep->c_lp, ep->c_blen, nlen); /* Get the line from the underlying database. */ key.data = &lno; diff --git a/common/exf.c b/common/exf.c index 1b7e6359..75c3d9fa 100644 --- a/common/exf.c +++ b/common/exf.c @@ -1156,7 +1156,7 @@ file_backup(SCR *sp, char *name, char *bname) * by one. */ if (version) { - GET_SPACE_GOTO(sp, bp, blen, cmd.argv[0]->len * 2 + 50); + GET_SPACE_GOTOC(sp, bp, blen, cmd.argv[0]->len * 2 + 50); INT2SYS(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, p, nlen); d = strdup(p); diff --git a/common/key.c b/common/key.c index 766ba5bc..6bdcce19 100644 --- a/common/key.c +++ b/common/key.c @@ -833,7 +833,7 @@ v_event_grow(SCR *sp, int add) wp = sp->wp; new_nelem = wp->i_nelem + add; olen = wp->i_nelem * sizeof(wp->i_event[0]); - BINC_RET(sp, (char *)wp->i_event, olen, new_nelem * sizeof(wp->i_event[0])); + BINC_RET(sp, EVENT, wp->i_event, olen, new_nelem * sizeof(EVENT)); wp->i_nelem = olen / sizeof(wp->i_event[0]); return (0); } diff --git a/common/log.c b/common/log.c index 642304bc..fa827e0b 100644 --- a/common/log.c +++ b/common/log.c @@ -201,7 +201,7 @@ log_cursor1(SCR *sp, int type) return 1; */ - BINC_RET(sp, sp->wp->l_lp, sp->wp->l_len, sizeof(u_char) + sizeof(MARK)); + BINC_RETC(sp, sp->wp->l_lp, sp->wp->l_len, sizeof(u_char) + sizeof(MARK)); sp->wp->l_lp[0] = type; memmove(sp->wp->l_lp + sizeof(u_char), &ep->l_cursor, sizeof(MARK)); @@ -293,7 +293,7 @@ log_line(SCR *sp, db_recno_t lno, u_int action) } else if (db_get(sp, lno, DBG_FATAL, &lp, &len)) return (1); - BINC_RET(sp, + BINC_RETC(sp, sp->wp->l_lp, sp->wp->l_len, len * sizeof(CHAR_T) + CHAR_T_OFFSET); sp->wp->l_lp[0] = action; @@ -371,7 +371,7 @@ log_mark(SCR *sp, LMARK *lmp) ep->l_win = sp->wp; } - BINC_RET(sp, sp->wp->l_lp, + BINC_RETC(sp, sp->wp->l_lp, sp->wp->l_len, sizeof(u_char) + sizeof(LMARK)); sp->wp->l_lp[0] = LOG_MARK; memmove(sp->wp->l_lp + sizeof(u_char), lmp, sizeof(LMARK)); @@ -409,7 +409,7 @@ vi_log_get(SCR *sp, db_recno_t *lnop, size_t *size) nlen = 1024; retry: - BINC_RET(sp, sp->wp->l_lp, sp->wp->l_len, nlen); + BINC_RETC(sp, sp->wp->l_lp, sp->wp->l_len, nlen); memset(&key, 0, sizeof(key)); key.data = lnop; /* Initialize db request. */ diff --git a/common/mem.h b/common/mem.h index 6d972391..0904281b 100644 --- a/common/mem.h +++ b/common/mem.h @@ -19,8 +19,8 @@ /* Increase the size of a malloc'd buffer. Two versions, one that * returns, one that jumps to an error label. */ -#define BINC_GOTO(sp, lp, llen, nlen) { \ - CHECK_TYPE(char *, lp) \ +#define BINC_GOTO(sp, type, lp, llen, nlen) { \ + CHECK_TYPE(type *, lp) \ void *L__bincp; \ if ((nlen) > llen) { \ if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \ @@ -32,12 +32,12 @@ lp = L__bincp; \ } \ } -#define BINC_GOTOW(sp, lp, llen, nlen) { \ - CHECK_TYPE(CHAR_T *, lp) \ - BINC_GOTO(sp, (char *)lp, llen, (nlen) * sizeof(CHAR_T)) \ -} -#define BINC_RET(sp, lp, llen, nlen) { \ - CHECK_TYPE(char *, lp) \ +#define BINC_GOTOC(sp, lp, llen, nlen) \ + BINC_GOTO(sp, char, lp, llen, nlen) +#define BINC_GOTOW(sp, lp, llen, nlen) \ + BINC_GOTO(sp, CHAR_T, lp, llen, (nlen) * sizeof(CHAR_T)) +#define BINC_RET(sp, type, lp, llen, nlen) { \ + CHECK_TYPE(type *, lp) \ void *L__bincp; \ if ((nlen) > llen) { \ if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \ @@ -49,85 +49,85 @@ lp = L__bincp; \ } \ } -#define BINC_RETW(sp, lp, llen, nlen) { \ - CHECK_TYPE(CHAR_T *, lp) \ - BINC_RET(sp, (char *)lp, llen, (nlen) * sizeof(CHAR_T)) \ -} +#define BINC_RETC(sp, lp, llen, nlen) \ + BINC_RET(sp, char, lp, llen, nlen) +#define BINC_RETW(sp, lp, llen, nlen) \ + BINC_RET(sp, CHAR_T, lp, llen, (nlen) * sizeof(CHAR_T)) /* * Get some temporary space, preferably from the global temporary buffer, * from a malloc'd buffer otherwise. Two versions, one that returns, one * that jumps to an error label. */ -#define GET_SPACE_GOTO(sp, bp, blen, nlen) { \ +#define GET_SPACE_GOTO(sp, type, bp, blen, nlen) { \ + CHECK_TYPE(type *, bp) \ WIN *L__wp = (sp) == NULL ? NULL : (sp)->wp; \ if (L__wp == NULL || F_ISSET(L__wp, W_TMP_INUSE)) { \ bp = NULL; \ blen = 0; \ - BINC_GOTO(sp, bp, blen, nlen); \ + BINC_GOTO(sp, type, bp, blen, nlen); \ } else { \ - BINC_GOTO(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ - bp = L__wp->tmp_bp; \ + BINC_GOTOC(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ + bp = (type *) L__wp->tmp_bp; \ blen = L__wp->tmp_blen; \ F_SET(L__wp, W_TMP_INUSE); \ } \ } -#define GET_SPACE_GOTOW(sp, bp, blen, nlen) { \ - CHAR_T *L__bp = bp; \ - GET_SPACE_GOTO(sp, (char *)bp, blen, (nlen) * sizeof(CHAR_T)) \ -} -#define GET_SPACE_RET(sp, bp, blen, nlen) { \ +#define GET_SPACE_GOTOC(sp, bp, blen, nlen) \ + GET_SPACE_GOTO(sp, char, bp, blen, nlen) +#define GET_SPACE_GOTOW(sp, bp, blen, nlen) \ + GET_SPACE_GOTO(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T)) +#define GET_SPACE_RET(sp, type, bp, blen, nlen) { \ + CHECK_TYPE(type *, bp) \ WIN *L__wp = (sp) == NULL ? NULL : (sp)->wp; \ if (L__wp == NULL || F_ISSET(L__wp, W_TMP_INUSE)) { \ bp = NULL; \ blen = 0; \ - BINC_RET(sp, bp, blen, nlen); \ + BINC_RET(sp, type, bp, blen, nlen); \ } else { \ - BINC_RET(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ - bp = L__wp->tmp_bp; \ + BINC_RETC(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ + bp = (type *) L__wp->tmp_bp; \ blen = L__wp->tmp_blen; \ F_SET(L__wp, W_TMP_INUSE); \ } \ } -#define GET_SPACE_RETW(sp, bp, blen, nlen) { \ - CHECK_TYPE(CHAR_T *, bp) \ - GET_SPACE_RET(sp, (char *)bp, blen, (nlen) * sizeof(CHAR_T)) \ -} +#define GET_SPACE_RETC(sp, bp, blen, nlen) \ + GET_SPACE_RET(sp, char, bp, blen, nlen) +#define GET_SPACE_RETW(sp, bp, blen, nlen) \ + GET_SPACE_RET(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T)) /* * Add space to a GET_SPACE returned buffer. Two versions, one that * returns, one that jumps to an error label. */ -#define ADD_SPACE_GOTO(sp, bp, blen, nlen) { \ +#define ADD_SPACE_GOTO(sp, type, bp, blen, nlen) { \ + CHECK_TYPE(type *, bp) \ WIN *L__wp = (sp) == NULL ? NULL : (sp)->wp; \ - if (L__wp == NULL || bp == L__wp->tmp_bp) { \ + if (L__wp == NULL || bp == (type *)L__wp->tmp_bp) { \ F_CLR(L__wp, W_TMP_INUSE); \ - BINC_GOTO(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ - bp = L__wp->tmp_bp; \ + BINC_GOTOC(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ + bp = (type *) L__wp->tmp_bp; \ blen = L__wp->tmp_blen; \ F_SET(L__wp, W_TMP_INUSE); \ } else \ - BINC_GOTO(sp, bp, blen, nlen); \ + BINC_GOTO(sp, type, bp, blen, nlen); \ } -#define ADD_SPACE_GOTOW(sp, bp, blen, nlen) { \ - CHECK_TYPE(CHAR_T *, bp) \ - ADD_SPACE_GOTO(sp, (char *)bp, blen, (nlen) * sizeof(CHAR_T)) \ -} -#define ADD_SPACE_RET(sp, bp, blen, nlen) { \ +#define ADD_SPACE_GOTOW(sp, bp, blen, nlen) \ + ADD_SPACE_GOTO(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T)) +#define ADD_SPACE_RET(sp, type, bp, blen, nlen) { \ + CHECK_TYPE(type *, bp) \ WIN *L__wp = (sp) == NULL ? NULL : (sp)->wp; \ - if (L__wp == NULL || bp == L__wp->tmp_bp) { \ + if (L__wp == NULL || bp == (type *)L__wp->tmp_bp) { \ F_CLR(L__wp, W_TMP_INUSE); \ - BINC_RET(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ - bp = L__wp->tmp_bp; \ + BINC_RETC(sp, L__wp->tmp_bp, L__wp->tmp_blen, nlen); \ + bp = (type *) L__wp->tmp_bp; \ blen = L__wp->tmp_blen; \ F_SET(L__wp, W_TMP_INUSE); \ } else \ - BINC_RET(sp, bp, blen, nlen); \ -} -#define ADD_SPACE_RETW(sp, bp, blen, nlen) { \ - CHECK_TYPE(CHAR_T *, bp) \ - ADD_SPACE_RET(sp, (char *)bp, blen, (nlen) * sizeof(CHAR_T)) \ + BINC_RET(sp, type, bp, blen, nlen); \ } +#define ADD_SPACE_RETW(sp, bp, blen, nlen) \ + ADD_SPACE_RET(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T)) /* Free a GET_SPACE returned buffer. */ #define FREE_SPACE(sp, bp, blen) { \ diff --git a/common/msg.c b/common/msg.c index 1386dc95..a47d986c 100644 --- a/common/msg.c +++ b/common/msg.c @@ -133,7 +133,7 @@ retry: FREE_SPACE(sp, bp, blen); } bp = NULL; blen = 0; - GET_SPACE_GOTO(sp, bp, blen, nlen); + GET_SPACE_GOTOC(sp, bp, blen, nlen); /* * Error prefix. @@ -487,7 +487,7 @@ mod_rpt(SCR *sp) } /* Build and display the message. */ - GET_SPACE_GOTO(sp, bp, blen, sizeof(action) * MAXNUM + 1); + GET_SPACE_GOTOC(sp, bp, blen, sizeof(action) * MAXNUM + 1); for (p = bp, first = 1, tlen = 0, ap = action, cnt = 0; cnt < ARSIZE(action); ++ap, ++cnt) if (sp->rptlines[cnt] != 0) { @@ -548,7 +548,7 @@ msgq_status(SCR *sp, db_recno_t lno, u_int flags) /* Get sufficient memory. */ len = strlen(sp->frp->name); - GET_SPACE_GOTO(sp, bp, blen, len * MAX_CHARACTER_COLUMNS + 128); + GET_SPACE_GOTOC(sp, bp, blen, len * MAX_CHARACTER_COLUMNS + 128); p = bp; /* Copy in the filename. */ @@ -898,7 +898,7 @@ retry: if (sp == NULL) if ((bp = malloc(nlen)) == NULL) goto alloc_err; } else - GET_SPACE_GOTO(sp, bp, blen, nlen); + GET_SPACE_GOTOC(sp, bp, blen, nlen); if (0) { alloc_err: return (""); } diff --git a/ex/ex_cscope.c b/ex/ex_cscope.c index 8ffbb3a7..698c1ef2 100644 --- a/ex/ex_cscope.c +++ b/ex/ex_cscope.c @@ -177,7 +177,7 @@ start_cscopes(SCR *sp, EXCMD *cmdp) if ((cscopes = getenv("CSCOPE_DIRS")) == NULL) return (0); len = strlen(cscopes); - GET_SPACE_RET(sp, bp, blen, len); + GET_SPACE_RETC(sp, bp, blen, len); memcpy(bp, cscopes, len + 1); for (cscopes = t = bp; (p = strsep(&t, "\t :")) != NULL;) diff --git a/ex/ex_util.c b/ex/ex_util.c index 8a5783c5..167d536a 100644 --- a/ex/ex_util.c +++ b/ex/ex_util.c @@ -64,7 +64,7 @@ ex_getline(SCR *sp, FILE *fp, size_t *lenp) exp = EXP(sp); for (errno = 0, off = 0, p = exp->ibp;;) { if (off >= exp->ibp_len) { - BINC_RET(sp, exp->ibp, exp->ibp_len, off + 1); + BINC_RETC(sp, exp->ibp, exp->ibp_len, off + 1); p = exp->ibp + off; } if ((ch = getc(fp)) == EOF && !feof(fp)) { diff --git a/vi/v_txt.c b/vi/v_txt.c index b3afaf87..76b56b81 100644 --- a/vi/v_txt.c +++ b/vi/v_txt.c @@ -589,7 +589,7 @@ next: if (v_event_get(sp, evp, 0, ec_flags)) /* Check to see if the character fits into the replay buffers. */ if (LF_ISSET(TXT_RECORD)) { - BINC_GOTO(sp, (char *)vip->rep, + BINC_GOTO(sp, EVENT, vip->rep, vip->rep_len, (rcol + 1) * sizeof(EVENT)); vip->rep[rcol++] = *evp; } -- 2.11.4.GIT