https://savannah.nongnu.org/bugs/?23465 has Peter Maydell pointing out
the assymetric open and close of a FILE pointer. He's right on that
AFAICS so change the test to be for a non-NULL pointer rather than the
more wordy and prone to error flag-testing.
* copying routine uses the descriptor, not the pointer.
*/
* copying routine uses the descriptor, not the pointer.
*/
- if (append || delete >= -1) {
- if (lseek(fd, (off_t)ftell(fp), SEEK_SET) == (off_t)-1)
- adios(NULL, "can't seek.");
- }
+ if (fp && lseek(fd, (off_t)ftell(fp), SEEK_SET) == (off_t)-1)
+ adios(NULL, "can't seek.");
cpydata (fd, fileno (tmp), file, tmpfil);
fclose (tmp);
cpydata (fd, fileno (tmp), file, tmpfil);
fclose (tmp);
* lkclose() fail, but that failure is ignored so it's not a problem.
*/
* lkclose() fail, but that failure is ignored so it's not a problem.
*/
(void)fclose(fp);
return 0;
(void)fclose(fp);
return 0;