mirror of https://github.com/vitalif/e2fsprogs
libext2fs: check return values
Fix up a few places where we ignore return values. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>debian-1.42.9
parent
b2778bcb8c
commit
8d74ab767d
|
@ -70,7 +70,7 @@ errcode_t ext2fs_sync_device(int fd, int flushb)
|
||||||
#warning BLKFLSBUF not defined
|
#warning BLKFLSBUF not defined
|
||||||
#endif
|
#endif
|
||||||
#ifdef FDFLUSH
|
#ifdef FDFLUSH
|
||||||
ioctl (fd, FDFLUSH, 0); /* In case this is a floppy */
|
return ioctl(fd, FDFLUSH, 0); /* In case this is a floppy */
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#warning FDFLUSH not defined
|
#warning FDFLUSH not defined
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -193,6 +193,8 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
|
||||||
uuid_unparse(fs->super->s_uuid, uuid);
|
uuid_unparse(fs->super->s_uuid, uuid);
|
||||||
sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
|
sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
|
||||||
fd = mkstemp(fn);
|
fd = mkstemp(fn);
|
||||||
|
if (fd < 0)
|
||||||
|
return fd;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is an overestimate of the size that we will need; the
|
* This is an overestimate of the size that we will need; the
|
||||||
|
|
|
@ -66,6 +66,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
|
||||||
blk64_t blk;
|
blk64_t blk;
|
||||||
ssize_t actual;
|
ssize_t actual;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
off_t r;
|
||||||
|
|
||||||
buf = malloc(fs->blocksize * BUF_BLOCKS);
|
buf = malloc(fs->blocksize * BUF_BLOCKS);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
@ -97,7 +98,11 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
|
||||||
blk++;
|
blk++;
|
||||||
left--;
|
left--;
|
||||||
cp += fs->blocksize;
|
cp += fs->blocksize;
|
||||||
lseek(fd, fs->blocksize, SEEK_CUR);
|
r = lseek(fd, fs->blocksize, SEEK_CUR);
|
||||||
|
if (r < 0) {
|
||||||
|
retval = errno;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Find non-zero blocks */
|
/* Find non-zero blocks */
|
||||||
|
|
|
@ -520,8 +520,10 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
|
||||||
#if HAVE_EXT2_IOCTLS
|
#if HAVE_EXT2_IOCTLS
|
||||||
fd = open(jfile, O_RDONLY);
|
fd = open(jfile, O_RDONLY);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
ioctl(fd, EXT2_IOC_SETFLAGS, &f);
|
retval = ioctl(fd, EXT2_IOC_SETFLAGS, &f);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
if (retval)
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -192,6 +192,13 @@ static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
|
||||||
retval = ext2fs_extent_open2(fs, ino, inode, &handle);
|
retval = ext2fs_extent_open2(fs, ino, inode, &handle);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
/*
|
||||||
|
* Find the extent closest to the start of the punch range. We don't
|
||||||
|
* check the return value because _goto() sets the current node to the
|
||||||
|
* next-lowest extent if 'start' is in a hole, and doesn't set a
|
||||||
|
* current node if there was a real error reading the extent tree.
|
||||||
|
* In that case, _get() will error out.
|
||||||
|
*/
|
||||||
ext2fs_extent_goto(handle, start);
|
ext2fs_extent_goto(handle, start);
|
||||||
retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
|
retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
|
Loading…
Reference in New Issue