mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-26 19:51:32 +00:00
tools/f2fs_io: Fix the type of 'ret'
commit 28de4d1334d4519c1a64659245dfd84cc2ddfa6c category: bugfix issue: #I6VAS0 CVE: NA Signed-off-by: DongSenhao <dongsenhao2@huawei.com> --------------------------------------- Make it possible to check whether the return value of ioctl() is negative. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
parent
ff7c97ddbc
commit
1fa72eed97
@ -513,7 +513,7 @@ static void do_erase(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
|
||||
static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
{
|
||||
u64 buf_size = 0, inc_num = 0, ret = 0, written = 0;
|
||||
u64 buf_size = 0, inc_num = 0, written = 0;
|
||||
u64 offset;
|
||||
char *buf = NULL;
|
||||
unsigned bs, count, i;
|
||||
@ -561,6 +561,8 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
fd = xopen(argv[6], O_CREAT | O_WRONLY | flags, 0755);
|
||||
|
||||
if (atomic_commit || atomic_abort) {
|
||||
int ret;
|
||||
|
||||
if (argc == 8)
|
||||
useconds = atoi(argv[7]) * 1000;
|
||||
|
||||
@ -573,6 +575,8 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
|
||||
total_time = get_current_us();
|
||||
for (i = 0; i < count; i++) {
|
||||
uint64_t ret;
|
||||
|
||||
if (!strcmp(argv[4], "inc_num"))
|
||||
*(int *)buf = inc_num++;
|
||||
else if (!strcmp(argv[4], "rand"))
|
||||
@ -593,12 +597,16 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
usleep(useconds);
|
||||
|
||||
if (atomic_commit) {
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_COMMIT_ATOMIC_WRITE);
|
||||
if (ret < 0) {
|
||||
fputs("committing atomic write failed\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
} else if (atomic_abort) {
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_ABORT_VOLATILE_WRITE);
|
||||
if (ret < 0) {
|
||||
fputs("aborting atomic write failed\n", stderr);
|
||||
|
Loading…
Reference in New Issue
Block a user