Skip to content

Commit 1b9e345

Browse files
committed
wip ~ fix cl warnings
1 parent 6a7390e commit 1b9e345

20 files changed

Lines changed: 137 additions & 124 deletions

command.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,9 @@ public void commands(void)
12201220
IFILE new_ifile;
12211221
char *tagfile;
12221222

1223+
c = 0;
1224+
extra = 0;
1225+
12231226
search_type = SRCH_FORW;
12241227
wscroll = (sc_height + 1) / 2;
12251228
newaction = A_NOACTION;
@@ -1322,7 +1325,7 @@ public void commands(void)
13221325
* want erase_char/kill_char to be treated
13231326
* as line editing characters.
13241327
*/
1325-
tbuf[0] = c;
1328+
tbuf[0] = (char)c;
13261329
tbuf[1] = '\0';
13271330
cbuf = tbuf;
13281331
}
@@ -2004,7 +2007,7 @@ public void commands(void)
20042007
c = '.';
20052008
if (badmark(c))
20062009
break;
2007-
pipec = c;
2010+
pipec = (char)c;
20082011
start_mca(A_PIPE, "!", ml_shell, 0);
20092012
c = getcc();
20102013
goto again;

cvt.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ extern int utf_mode;
1919
/*
2020
* Get the length of a buffer needed to convert a string.
2121
*/
22-
public size_t
23-
cvt_length(len, ops)
24-
size_t len;
25-
int ops;
22+
public size_t cvt_length(size_t len, int ops)
2623
{
24+
(void)ops;
2725
if (utf_mode)
2826
/*
2927
* Just copying a string in UTF-8 mode can cause it to grow
@@ -37,9 +35,7 @@ cvt_length(len, ops)
3735
/*
3836
* Allocate a chpos array for use by cvt_text.
3937
*/
40-
public int *
41-
cvt_alloc_chpos(len)
42-
size_t len;
38+
public int *cvt_alloc_chpos(size_t len)
4339
{
4440
size_t i;
4541
int *chpos = (int *) ecalloc(sizeof(int), len);

decode.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ static int mouse_wheel_up(void)
444444
*/
445445
static int mouse_button_rel(int x, int y)
446446
{
447+
(void)x; // avoid `unreferenced formal parameter` warning
448+
447449
/*
448450
* {{ It would be better to return an action and then do this
449451
* in commands() but it's nontrivial to pass y to it. }}
@@ -465,7 +467,7 @@ static int getcc_int(char *pterm)
465467
int digits = 0;
466468
for (;;)
467469
{
468-
char ch = getcc();
470+
char ch = (char)getcc();
469471
if (ch < '0' || ch > '9')
470472
{
471473
if (pterm != NULL) *pterm = ch;
@@ -875,6 +877,8 @@ public int add_hometable(int (*call_lesskey)(char *, int), char *envname, char *
875877
char *filename;
876878
int r;
877879

880+
filename = NULL; // avoid `potentially uninitialized local variable` warning
881+
878882
if (envname != NULL && (filename = lgetenv(envname)) != NULL)
879883
filename = save(filename);
880884
else if (sysvar) /* def_filename is full path */
@@ -941,7 +945,7 @@ public int editchar(int c, int flags)
941945
do {
942946
if (nch > 0)
943947
c = getcc();
944-
usercmd[nch] = c;
948+
usercmd[nch] = (char)c;
945949
usercmd[nch+1] = '\0';
946950
nch++;
947951
action = ecmd_decode(usercmd, &s);

edit.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ static void modeline_options(char *str, char end_char)
218218
*/
219219
static void check_modeline(char *line)
220220
{
221+
(void)line; // avoid `unused parameter` warning
222+
221223
#if HAVE_STRSTR
222224
static char *pgms[] = { "less:", "vim:", "vi:", "ex:", NULL };
223225
char **pgm;
@@ -448,6 +450,8 @@ public int edit_ifile(IFILE ifile)
448450
IFILE was_curr_ifile;
449451
PARG parg;
450452

453+
f = 0; // avoid `potentially uninitialized local variable` warning
454+
451455
if (ifile == curr_ifile)
452456
{
453457
/*
@@ -601,9 +605,9 @@ public int edit_ifile(IFILE ifile)
601605
}
602606
if (!force_open && f >= 0 && isatty(f))
603607
{
604-
PARG parg;
605-
parg.p_string = filename;
606-
error("%s is a terminal (use -f to open it)", &parg);
608+
PARG arg;
609+
arg.p_string = filename;
610+
error("%s is a terminal (use -f to open it)", &arg);
607611
return edit_error(filename, alt_filename, altpipe, ifile, was_curr_ifile);
608612
}
609613

filename.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ static POSITION seek_filesize(int f)
505505
static char * readfd(FILE *fd)
506506
{
507507
int len;
508-
int ch;
508+
int c;
509+
char ch;
509510
char *buf;
510511
char *p;
511512

@@ -517,8 +518,9 @@ static char * readfd(FILE *fd)
517518
buf = (char *) ecalloc(len, sizeof(char));
518519
for (p = buf; ; p++)
519520
{
520-
if ((ch = getc(fd)) == '\n' || ch == EOF)
521+
if ((c = getc(fd)) == '\n' || c == EOF)
521522
break;
523+
ch = (char)c;
522524
if (p - buf >= len-1)
523525
{
524526
/*

lesskey_parse.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ static struct lesskey_cmdname editnames[] =
123123
static void parse_error(char *fmt, char *arg1)
124124
{
125125
char buf[2048];
126+
127+
(void)fmt; // avoid `unreferenced formal parameter` warning
128+
(void)arg1; // avoid `unreferenced formal parameter` warning
129+
126130
++errors;
127131
lesskey_parse_error(buf);
128132
}
@@ -153,7 +157,7 @@ static char * char_string(char *buf, int ch, int lit)
153157
{
154158
if (lit || (ch >= 0x20 && ch < 0x7f))
155159
{
156-
buf[0] = ch;
160+
buf[0] = (char)ch;
157161
buf[1] = '\0';
158162
} else
159163
{
@@ -294,9 +298,7 @@ static int issp(char ch)
294298
/*
295299
* Skip leading spaces in a string.
296300
*/
297-
char *
298-
skipsp(s)
299-
char *s;
301+
char * skipsp(char *s)
300302
{
301303
while (issp(*s))
302304
s++;
@@ -381,6 +383,8 @@ static char * version_line(char *s, struct lesskey_tables *tables)
381383
char *e;
382384
char buf[CHAR_STRING_LEN];
383385

386+
(void)tables; // avoid `unreferenced formal parameter` warning
387+
384388
s += strlen("#version");
385389
s = skipsp(s);
386390
op = *s++;

line.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ static int store_char(LWCHAR ch, int a, char *rep, POSITION pos)
789789
if (linebuf.end > linebuf.print)
790790
{
791791
/* Shift left enough to put last byte of this char at print-1. */
792-
int i;
793792
for (i = 0; i < linebuf.print; i++)
794793
{
795794
linebuf.buf[i] = linebuf.buf[i+replen];
@@ -929,7 +928,7 @@ public int pappend(int c, POSITION pos)
929928
{
930929
retry:
931930
mbc_buf_index = 1;
932-
*mbc_buf = c;
931+
*mbc_buf = (char)c;
933932
if (IS_ASCII_OCTET(c))
934933
r = do_append(c, NULL, pos);
935934
else if (IS_UTF8_LEAD(c))
@@ -942,7 +941,7 @@ public int pappend(int c, POSITION pos)
942941
r = flush_mbc_buf(pos);
943942
} else if (IS_UTF8_TRAIL(c))
944943
{
945-
mbc_buf[mbc_buf_index++] = c;
944+
mbc_buf[mbc_buf_index++] = (char)c;
946945
if (mbc_buf_index < mbc_buf_len)
947946
return (0);
948947
if (is_utf8_well_formed(mbc_buf, mbc_buf_index))
@@ -1360,7 +1359,7 @@ public POSITION forw_raw_line(POSITION curr_pos, char **linep, int *line_lenp)
13601359
break;
13611360
}
13621361
}
1363-
linebuf.buf[n++] = c;
1362+
linebuf.buf[n++] = (char)c;
13641363
c = ch_forw_get();
13651364
}
13661365
linebuf.buf[n] = '\0';
@@ -1432,7 +1431,7 @@ public POSITION back_raw_line(POSITION curr_pos, char **linep, int *line_lenp)
14321431
*to = *fm;
14331432
n = size_linebuf - old_size_linebuf;
14341433
}
1435-
linebuf.buf[--n] = c;
1434+
linebuf.buf[--n] = (char)c;
14361435
}
14371436
if (linep != NULL)
14381437
*linep = &linebuf.buf[n];

main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,11 @@ int main(int argc, char *argv[])
302302
init();
303303
commands();
304304
quit(QUIT_OK);
305+
306+
#ifndef _MSC_VER
305307
/*NOTREACHED*/
306308
return (0);
309+
#endif
307310
}
308311

309312
/*

mark.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void init_mark(void)
7373
switch (i) {
7474
case MOUSEMARK: letter = '#'; break;
7575
case LASTMARK: letter = '\''; break;
76-
default: letter = (i < 26) ? 'a'+i : 'A'+i-26; break;
76+
default: letter = (i < 26) ? 'a'+(char)i : 'A'+(char)i-26; break;
7777
}
7878
marks[i].m_letter = letter;
7979
cmark(&marks[i], NULL_IFILE, NULL_POSITION, -1);
@@ -318,8 +318,8 @@ public char posmark(POSITION pos)
318318
{
319319
if (marks[i].m_ifile == curr_ifile && marks[i].m_scrpos.pos == pos)
320320
{
321-
if (i < 26) return 'a' + i;
322-
if (i < 26*2) return 'A' + (i - 26);
321+
if (i < 26) return 'a' + (char)i;
322+
if (i < 26*2) return 'A' + ((char)i - 26);
323323
return '#';
324324
}
325325
}

optfunc.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ public void opt__P(int type, char *s)
454454
/*ARGSUSED*/
455455
public void opt_b(int type, char *s)
456456
{
457+
(void)s; // avoid `unreferenced formal parameter` warning
458+
457459
switch (type)
458460
{
459461
case INIT:
@@ -474,6 +476,8 @@ public void opt_b(int type, char *s)
474476
/*ARGSUSED*/
475477
public void opt_i(int type, char *s)
476478
{
479+
(void)s; // avoid `unreferenced formal parameter` warning
480+
477481
switch (type)
478482
{
479483
case TOGGLE:
@@ -491,6 +495,8 @@ public void opt_i(int type, char *s)
491495
/*ARGSUSED*/
492496
public void opt__V(int type, char *s)
493497
{
498+
(void)s; // avoid `unreferenced formal parameter` warning
499+
494500
switch (type)
495501
{
496502
case TOGGLE:
@@ -815,6 +821,8 @@ public void opt_rscroll(int type, char *s)
815821
/*ARGSUSED*/
816822
public void opt_query(int type, char *s)
817823
{
824+
(void)s; // avoid `unreferenced formal parameter` warning
825+
818826
switch (type)
819827
{
820828
case QUERY:
@@ -832,6 +840,8 @@ public void opt_query(int type, char *s)
832840
/*ARGSUSED*/
833841
public void opt_mousecap(int type, char *s)
834842
{
843+
(void)s; // avoid `unreferenced formal parameter` warning
844+
835845
switch (type)
836846
{
837847
case TOGGLE:
@@ -852,6 +862,8 @@ public void opt_mousecap(int type, char *s)
852862
/*ARGSUSED*/
853863
public void opt_wheel_lines(int type, char *s)
854864
{
865+
(void)s; // avoid `unreferenced formal parameter` warning
866+
855867
switch (type)
856868
{
857869
case INIT:
@@ -872,6 +884,8 @@ public void opt_linenum_width(int type, char *s)
872884
{
873885
PARG parg;
874886

887+
(void)s; // avoid `unreferenced formal parameter` warning
888+
875889
switch (type)
876890
{
877891
case INIT:
@@ -896,6 +910,8 @@ public void opt_status_col_width(int type, char *s)
896910
{
897911
PARG parg;
898912

913+
(void)s; // avoid `unreferenced formal parameter` warning
914+
899915
switch (type)
900916
{
901917
case INIT:
@@ -918,6 +934,8 @@ public void opt_status_col_width(int type, char *s)
918934
/*ARGSUSED*/
919935
public void opt_filesize(int type, char *s)
920936
{
937+
(void)s; // avoid `unreferenced formal parameter` warning
938+
921939
switch (type)
922940
{
923941
case INIT:
@@ -1052,7 +1070,7 @@ public void opt_search_type(int type, char *s)
10521070
if (def_search_type & SRCH_WRAP) *bp++ = 'W';
10531071
for (i = 1; i <= NUM_SEARCH_COLORS; i++)
10541072
if (def_search_type & SRCH_SUBSEARCH(i))
1055-
*bp++ = '0'+i;
1073+
*bp++ = '0'+(char)i;
10561074
if (bp == buf)
10571075
*bp++ = '-';
10581076
*bp = '\0';

0 commit comments

Comments
 (0)