Skip to content

Commit 7c5dee1

Browse files
committed
Further fixes for cppcheck nits (and some arguably significant issues) in the PDCursesMod core library.
1 parent 592d540 commit 7c5dee1

9 files changed

Lines changed: 19 additions & 18 deletions

File tree

pdcurses/getstr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int wgetnstr(WINDOW *win, char *str, int n)
8989

9090
return (int)PDC_wcstombs(str, wstr, n);
9191
#else
92-
int ch, i, num, x, chars;
92+
int i, num, x, chars;
9393
char *p;
9494
bool stop, oldecho, oldcbreak;
9595
int old_delayms;
@@ -120,7 +120,7 @@ int wgetnstr(WINDOW *win, char *str, int n)
120120

121121
while (!stop)
122122
{
123-
ch = wgetch(win);
123+
int ch = wgetch(win);
124124

125125
switch (ch)
126126
{

pdcurses/inchstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ inchstr
6262

6363
int winchnstr(WINDOW *win, chtype *ch, int n)
6464
{
65-
chtype *src;
65+
const chtype *src;
6666
int i;
6767

6868
PDC_LOG(("winchnstr() - called\n"));

pdcurses/initscr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ void delscreen(SCREEN *sp)
409409

410410
int resize_term(int nlines, int ncols)
411411
{
412-
PANEL *panel_ptr = NULL;
412+
const PANEL *panel_ptr = NULL;
413413

414414
PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
415415

pdcurses/overlay.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
5555
int src_tc, int src_br, int src_bc, int dst_tr,
5656
int dst_tc, bool _overlay)
5757
{
58-
int col, line, y1, fc;
59-
chtype *w1ptr, *w2ptr;
58+
int col, line, y1;
6059

6160
int lc = 0;
6261
int xdiff = src_bc - src_tc;
@@ -75,10 +74,10 @@ static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
7574

7675
for (line = 0; line < ydiff; line++)
7776
{
78-
w1ptr = src_w->_y[line + src_tr] + src_tc;
79-
w2ptr = dst_w->_y[line + dst_tr] + dst_tc;
77+
int fc = _NO_CHANGE;
78+
const chtype *w1ptr = src_w->_y[line + src_tr] + src_tc;
79+
chtype *w2ptr = dst_w->_y[line + dst_tr] + dst_tc;
8080

81-
fc = _NO_CHANGE;
8281

8382
for (col = 0; col < xdiff; col++)
8483
{

pdcurses/refresh.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ int wnoutrefresh(WINDOW *win)
9393
{
9494
if (win->_firstch[i] != _NO_CHANGE && j >= 0)
9595
{
96-
chtype *src = win->_y[i];
96+
const chtype *src = win->_y[i];
9797
chtype *dest = curscr->_y[j] + begx;
9898

9999
int first = win->_firstch[i]; /* first changed */
@@ -248,7 +248,7 @@ int doupdate(void)
248248
{
249249
int first, last;
250250

251-
chtype *src = curscr->_y[y];
251+
const chtype *src = curscr->_y[y];
252252
chtype *dest = SP->lastscr->_y[y];
253253

254254
if (clearall)

pdcurses/scroll.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ scroll
4444
int PDC_wscrl(WINDOW *win, const int top, const int bottom, int n)
4545
{
4646
int start, end, n_lines;
47-
chtype blank, *tptr, *endptr;
47+
chtype blank, *tptr;
48+
const chtype *endptr;
4849

4950
/* Check if window scrolls. Valid for window AND pad */
5051

pdcurses/slk.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ static void _drawone(int num)
217217

218218
static void _redraw(void)
219219
{
220-
int i;
221-
222220
if( !hidden)
223221
{
222+
int i;
223+
224224
for (i = 0; i < labels; ++i)
225225
_drawone(i);
226226
if (label_fmt < 0)
@@ -279,7 +279,7 @@ int slk_set(int labnum, const char *label, int justify)
279279

280280
/* Copy it */
281281

282-
for (i = 0; label[i] && i < MAX_LABEL_LENGTH - 1; i++)
282+
for (i = 0; i < MAX_LABEL_LENGTH && label[i]; i++)
283283
slk[labnum].label[i] = label[i];
284284

285285
/* Drop trailing spaces */

pdcurses/touch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,17 @@ bool is_linetouched(WINDOW *win, int line)
208208

209209
bool is_wintouched(WINDOW *win)
210210
{
211-
int i;
212-
213211
PDC_LOG(("is_wintouched() - called: win=%p\n", win));
214212

215213
assert( win);
216214
if (win)
215+
{
216+
int i;
217+
217218
for (i = 0; i < win->_maxy; i++)
218219
if (win->_firstch[i] != _NO_CHANGE)
219220
return TRUE;
221+
}
220222

221223
return FALSE;
222224
}

pdcurses/window.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ WINDOW *dupwin(WINDOW *win)
527527
new_win->_pary = win->_pary;
528528
new_win->_parent = win->_parent;
529529
new_win->_bkgd = win->_bkgd;
530-
new_win->_flags = win->_flags;
531530
PDC_add_window_to_list( new_win);
532531

533532
return new_win;

0 commit comments

Comments
 (0)