From 24338ae85538707c42408a953900374910c04771 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 1 Oct 2005 00:56:15 -0700 Subject: [PATCH] Fix more compiler warnings Better initializers, and more proper function types. --- display.c | 1 + edef.h | 2 +- efunc.h | 13 +++++++--- eval.c | 1 + evar.h | 78 +++++++++++++++++++++++++++---------------------------- exec.c | 2 +- ibmpc.c | 2 +- isearch.c | 32 ++++++++++++----------- pklock.c | 2 ++ search.c | 4 +-- tcap.c | 2 +- 11 files changed, 76 insertions(+), 63 deletions(-) diff --git a/display.c b/display.c index aa7f7dc..e364a8f 100644 --- a/display.c +++ b/display.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/edef.h b/edef.h index ff69d0d..292280c 100644 --- a/edef.h +++ b/edef.h @@ -119,7 +119,7 @@ extern window_t *wheadp; /* Head of list of windows */ extern BUFFER *bheadp; /* Head of list of buffers */ extern BUFFER *blistp; /* Buffer for C-X C-B */ -extern BUFFER *bfind(); /* Lookup a buffer by name */ +extern BUFFER *bfind(char *bname, int cflag, int bflag); /* Lookup a buffer by name */ extern window_t *wpopup(); /* Pop up window creation */ extern LINE *lalloc(); /* Allocate a line */ extern char sres[NBUFN]; /* current screen resolution */ diff --git a/efunc.h b/efunc.h index 80eb0e3..777c411 100644 --- a/efunc.h +++ b/efunc.h @@ -273,7 +273,7 @@ extern int storeproc(int f, int n); extern int execproc(int f, int n); extern int execbuf(int f, int n); extern int dobuf(BUFFER *bp); -extern int freewhile(WHBLOCK *wp); +extern void freewhile(WHBLOCK *wp); extern int execfile(int f, int n); extern int dofile(char *fname); extern int cbuf(int f, int n, int bufnum); @@ -336,7 +336,7 @@ extern int forwhunt(int f, int n); extern int backsearch(int f, int n); extern int backhunt(int f, int n); extern int mcscanner(MC *mcpatrn, int direct, int beg_or_end); -extern int scanner(unsigned char *patrn, int direct, int beg_or_end); +extern int scanner(const char *patrn, int direct, int beg_or_end); extern int eq(unsigned char bc, unsigned char pc); extern void savematch(void); extern void rvstrcpy(char *rvstr, char *str); @@ -358,7 +358,7 @@ extern int match_pat(char *patrn); extern int promptpattern(char *prompt); extern int get_char(void); extern int uneat(void); -extern int reeat(int c); +extern void reeat(int c); /* eval.c */ extern void varinit(void); @@ -394,3 +394,10 @@ extern void lckerror(char *errstr); /* names.c */ extern NBIND names[]; + +/* pklock.c */ +extern char *dolock(char *fname); +extern char *undolock(char *fname); + +/* tcap.c */ +extern void spal(char *dummy); diff --git a/eval.c b/eval.c index b872917..dbc20b5 100644 --- a/eval.c +++ b/eval.c @@ -839,6 +839,7 @@ char *getval(char *token) case TKCMD: return (token); } + return (errorm); } /* diff --git a/evar.h b/evar.h index e0906d3..d693176 100644 --- a/evar.h +++ b/evar.h @@ -126,45 +126,45 @@ typedef struct UFUNC { #define TRINAMIC 3 UFUNC funcs[] = { - "add", DYNAMIC, /* add two numbers together */ - "sub", DYNAMIC, /* subtraction */ - "tim", DYNAMIC, /* multiplication */ - "div", DYNAMIC, /* division */ - "mod", DYNAMIC, /* mod */ - "neg", MONAMIC, /* negate */ - "cat", DYNAMIC, /* concatinate string */ - "lef", DYNAMIC, /* left string(string, len) */ - "rig", DYNAMIC, /* right string(string, pos) */ - "mid", TRINAMIC, /* mid string(string, pos, len) */ - "not", MONAMIC, /* logical not */ - "equ", DYNAMIC, /* logical equality check */ - "les", DYNAMIC, /* logical less than */ - "gre", DYNAMIC, /* logical greater than */ - "seq", DYNAMIC, /* string logical equality check */ - "sle", DYNAMIC, /* string logical less than */ - "sgr", DYNAMIC, /* string logical greater than */ - "ind", MONAMIC, /* evaluate indirect value */ - "and", DYNAMIC, /* logical and */ - "or", DYNAMIC, /* logical or */ - "len", MONAMIC, /* string length */ - "upp", MONAMIC, /* uppercase string */ - "low", MONAMIC, /* lower case string */ - "tru", MONAMIC, /* Truth of the universe logical test */ - "asc", MONAMIC, /* char to integer conversion */ - "chr", MONAMIC, /* integer to char conversion */ - "gtk", NILNAMIC, /* get 1 charater */ - "rnd", MONAMIC, /* get a random number */ - "abs", MONAMIC, /* absolute value of a number */ - "sin", DYNAMIC, /* find the index of one string in another */ - "env", MONAMIC, /* retrieve a system environment var */ - "bin", MONAMIC, /* loopup what function name is bound to a key */ - "exi", MONAMIC, /* check if a file exists */ - "fin", MONAMIC, /* look for a file on the path... */ - "ban", DYNAMIC, /* bitwise and 9-10-87 jwm */ - "bor", DYNAMIC, /* bitwise or 9-10-87 jwm */ - "bxo", DYNAMIC, /* bitwise xor 9-10-87 jwm */ - "bno", MONAMIC, /* bitwise not */ - "xla", TRINAMIC, /* XLATE character string translation */ + { "add", DYNAMIC }, /* add two numbers together */ + { "sub", DYNAMIC }, /* subtraction */ + { "tim", DYNAMIC }, /* multiplication */ + { "div", DYNAMIC }, /* division */ + { "mod", DYNAMIC }, /* mod */ + { "neg", MONAMIC }, /* negate */ + { "cat", DYNAMIC }, /* concatinate string */ + { "lef", DYNAMIC }, /* left string(string, len) */ + { "rig", DYNAMIC }, /* right string(string, pos) */ + { "mid", TRINAMIC }, /* mid string(string, pos, len) */ + { "not", MONAMIC }, /* logical not */ + { "equ", DYNAMIC }, /* logical equality check */ + { "les", DYNAMIC }, /* logical less than */ + { "gre", DYNAMIC }, /* logical greater than */ + { "seq", DYNAMIC }, /* string logical equality check */ + { "sle", DYNAMIC }, /* string logical less than */ + { "sgr", DYNAMIC }, /* string logical greater than */ + { "ind", MONAMIC }, /* evaluate indirect value */ + { "and", DYNAMIC }, /* logical and */ + { "or", DYNAMIC }, /* logical or */ + { "len", MONAMIC }, /* string length */ + { "upp", MONAMIC }, /* uppercase string */ + { "low", MONAMIC }, /* lower case string */ + { "tru", MONAMIC }, /* Truth of the universe logical test */ + { "asc", MONAMIC }, /* char to integer conversion */ + { "chr", MONAMIC }, /* integer to char conversion */ + { "gtk", NILNAMIC }, /* get 1 charater */ + { "rnd", MONAMIC }, /* get a random number */ + { "abs", MONAMIC }, /* absolute value of a number */ + { "sin", DYNAMIC }, /* find the index of one string in another */ + { "env", MONAMIC }, /* retrieve a system environment var */ + { "bin", MONAMIC }, /* loopup what function name is bound to a key */ + { "exi", MONAMIC }, /* check if a file exists */ + { "fin", MONAMIC }, /* look for a file on the path... */ + { "ban", DYNAMIC }, /* bitwise and 9-10-87 jwm */ + { "bor", DYNAMIC }, /* bitwise or 9-10-87 jwm */ + { "bxo", DYNAMIC }, /* bitwise xor 9-10-87 jwm */ + { "bno", MONAMIC }, /* bitwise not */ + { "xla", TRINAMIC }, /* XLATE character string translation */ }; #define NFUNCS sizeof(funcs) / sizeof(UFUNC) diff --git a/exec.c b/exec.c index 1f8bef6..6200725 100644 --- a/exec.c +++ b/exec.c @@ -836,7 +836,7 @@ int dobuf(BUFFER *bp) * * WHBLOCK *wp; head of structure to free */ -int freewhile(WHBLOCK *wp) +void freewhile(WHBLOCK *wp) { if (wp == NULL) return; diff --git a/ibmpc.c b/ibmpc.c index c183e56..f184abc 100644 --- a/ibmpc.c +++ b/ibmpc.c @@ -502,7 +502,7 @@ int f, n; /* default flag, numeric argument [unused] */ } #endif #else -ibmhello() +static void ibmhello(void) { } #endif diff --git a/isearch.c b/isearch.c index c37abc7..cf6b9f1 100644 --- a/isearch.c +++ b/isearch.c @@ -75,6 +75,7 @@ int risearch(int f, int n) #if PKCODE matchlen = strlen(pat); #endif + return (TRUE); } /* @@ -106,6 +107,7 @@ int fisearch(int f, int n) #if PKCODE matchlen = strlen(pat); #endif + return (TRUE); } /* @@ -284,25 +286,25 @@ int checknext(char chr, char *patrn, int dir) /* Check next character in search /* setup the local scan pointer to current "." */ - curline = curwp->w_dotp; /* Get the current line structure */ - curoff = curwp->w_doto; /* Get the offset within that line */ + curline = curwp->w_dotp; /* Get the current line structure */ + curoff = curwp->w_doto; /* Get the offset within that line */ - if (dir > 0) { /* If searching forward */ - if (curoff == llength(curline)) { /* If at end of line */ - curline = lforw(curline); /* Skip to the next line */ + if (dir > 0) { /* If searching forward */ + if (curoff == llength(curline)) { /* If at end of line */ + curline = lforw(curline); /* Skip to the next line */ if (curline == curbp->b_linep) - return (FALSE); /* Abort if at end of buffer */ - curoff = 0; /* Start at the beginning of the line */ - buffchar = '\n'; /* And say the next char is NL */ + return (FALSE); /* Abort if at end of buffer */ + curoff = 0; /* Start at the beginning of the line */ + buffchar = '\n'; /* And say the next char is NL */ } else buffchar = lgetc(curline, curoff++); /* Get the next char */ - if (status = eq(buffchar, chr)) { /* Is it what we're looking for? */ - curwp->w_dotp = curline; /* Yes, set the buffer's point */ - curwp->w_doto = curoff; /* to the matched character */ - curwp->w_flag |= WFMOVE; /* Say that we've moved */ + if ((status = eq(buffchar, chr)) != 0) { /* Is it what we're looking for? */ + curwp->w_dotp = curline; /* Yes, set the buffer's point */ + curwp->w_doto = curoff; /* to the matched character */ + curwp->w_flag |= WFMOVE; /* Say that we've moved */ } - return (status); /* And return the status */ - } else /* Else, if reverse search: */ + return (status); /* And return the status */ + } else /* Else, if reverse search: */ return (match_pat(patrn)); /* See if we're in the right place */ } @@ -487,7 +489,7 @@ int uneat(void) return (c); /* and return the last char */ } -int reeat(int c) +void reeat(int c) { if (eaten_char != -1) /* If we've already been here */ return /*(NULL) */ ; /* Don't do it again */ diff --git a/pklock.c b/pklock.c index 50a77a7..2801228 100644 --- a/pklock.c +++ b/pklock.c @@ -4,6 +4,8 @@ */ #include "estruct.h" +#include "edef.h" +#include "efunc.h" #if (FILOCK && BSD) || SVR4 #include diff --git a/search.c b/search.c index 23e0144..3c5e55b 100644 --- a/search.c +++ b/search.c @@ -494,10 +494,10 @@ static int amatch(MC *mcptr, int direct, LINE **pcwline, int *pcwoff) * int direct; which way to go. * int beg_or_end; put point at beginning or end of pattern. */ -int scanner(unsigned char *patrn, int direct, int beg_or_end) +int scanner(const char *patrn, int direct, int beg_or_end) { register int c; /* character at current position */ - register unsigned char *patptr; /* pointer into pattern */ + const char *patptr; /* pointer into pattern */ LINE *curline; /* current line during scan */ int curoff; /* position within current line */ LINE *scanline; /* current line during scanning */ diff --git a/tcap.c b/tcap.c index f58e2cb..1345147 100644 --- a/tcap.c +++ b/tcap.c @@ -327,7 +327,7 @@ static void tcapscrollregion(int top, int bot) #endif -void spal(int dummy) +void spal(char *dummy) { /* change palette string */ /* Does nothing here */ }