Skip to content

Commit

Permalink
shmem: restore_shmem_content -- Use close_safe
Browse files Browse the repository at this point in the history
Don't call close() with degative fd. For consistency
simply use close_safe here. All fds touched are initialized
either to valid fd or to value < 0 which pretty good handled
by close_safe helper.

CID 996212 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
10. negative_returns: "fd" is passed to a parameter that cannot be negative.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
  • Loading branch information
Cyrill Gorcunov authored and xemul committed Apr 12, 2013
1 parent ab0eb45 commit 67e91d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)

}

close(fd_pg);
close(fd);
close_safe(&fd_pg);
close_safe(&fd);
return ret;

out_close:
close(fd);
close_safe(&fd);
err_unmap:
munmap(addr, si->size);
return -1;
Expand Down

0 comments on commit 67e91d6

Please sign in to comment.