libpayload/.../PDCurses: avoid reading orig before NULL checking it
Coverity complains and that (unfortunately) means that some compiler might take advantage of the same fact. Change-Id: I59aff77820c524fa5a0fcb251c1268da475101fb Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Found-by: Coverity Scan #1261105 Reviewed-on: https://review.coreboot.org/17835 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
cf3b306caf
commit
83f75bfeb9
|
@ -294,9 +294,7 @@ int mvwin(WINDOW *win, int y, int x)
|
||||||
WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
|
WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
|
||||||
{
|
{
|
||||||
WINDOW *win;
|
WINDOW *win;
|
||||||
int i;
|
int i, j, k;
|
||||||
int j = begy - orig->_begy;
|
|
||||||
int k = begx - orig->_begx;
|
|
||||||
|
|
||||||
PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
|
PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
|
||||||
nlines, ncols, begy, begx));
|
nlines, ncols, begy, begx));
|
||||||
|
@ -308,6 +306,9 @@ WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
|
||||||
(begx + ncols) > (orig->_begx + orig->_maxx))
|
(begx + ncols) > (orig->_begx + orig->_maxx))
|
||||||
return (WINDOW *)NULL;
|
return (WINDOW *)NULL;
|
||||||
|
|
||||||
|
j = begy - orig->_begy;
|
||||||
|
k = begx - orig->_begx;
|
||||||
|
|
||||||
if (!nlines)
|
if (!nlines)
|
||||||
nlines = orig->_maxy - 1 - j;
|
nlines = orig->_maxy - 1 - j;
|
||||||
if (!ncols)
|
if (!ncols)
|
||||||
|
|
Loading…
Reference in New Issue