mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 08:48:16 +00:00
coverity/68215: removed failed variable + dead code from f_readfile #860
This commit is contained in:

committed by
Justin M. Keyes

parent
ec72b7adc7
commit
3141c02c02
@@ -11469,7 +11469,6 @@ static void f_range(typval_T *argvars, typval_T *rettv)
|
|||||||
static void f_readfile(typval_T *argvars, typval_T *rettv)
|
static void f_readfile(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
int binary = FALSE;
|
int binary = FALSE;
|
||||||
int failed = FALSE;
|
|
||||||
char_u *fname;
|
char_u *fname;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
char_u buf[(IOSIZE/256)*256]; /* rounded to avoid odd + 1 */
|
char_u buf[(IOSIZE/256)*256]; /* rounded to avoid odd + 1 */
|
||||||
@@ -11586,7 +11585,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
if (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0)
|
if ((cnt >= maxline && maxline >= 0) || readlen <= 0)
|
||||||
break;
|
break;
|
||||||
if (start < p) {
|
if (start < p) {
|
||||||
/* There's part of a line in buf, store it in "prev". */
|
/* There's part of a line in buf, store it in "prev". */
|
||||||
@@ -11615,18 +11614,12 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
|
|||||||
* For a negative line count use only the lines at the end of the file,
|
* For a negative line count use only the lines at the end of the file,
|
||||||
* free the rest.
|
* free the rest.
|
||||||
*/
|
*/
|
||||||
if (!failed && maxline < 0)
|
if (maxline < 0)
|
||||||
while (cnt > -maxline) {
|
while (cnt > -maxline) {
|
||||||
listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first);
|
listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first);
|
||||||
--cnt;
|
--cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failed) {
|
|
||||||
list_free(rettv->vval.v_list, TRUE);
|
|
||||||
/* readfile doc says an empty list is returned on error */
|
|
||||||
rettv->vval.v_list = list_alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
free(prev);
|
free(prev);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user