提交 6e129d00 编写于 作者: J Jeff Layton

locks: flock_make_lock should return a struct file_lock (or PTR_ERR)

Eliminate the need for a return pointer.
Signed-off-by: NJeff Layton <jlayton@primarydata.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
上级 7ca76311
...@@ -326,17 +326,18 @@ static inline int flock_translate_cmd(int cmd) { ...@@ -326,17 +326,18 @@ static inline int flock_translate_cmd(int cmd) {
} }
/* Fill in a file_lock structure with an appropriate FLOCK lock. */ /* Fill in a file_lock structure with an appropriate FLOCK lock. */
static int flock_make_lock(struct file *filp, struct file_lock **lock, static struct file_lock *
unsigned int cmd) flock_make_lock(struct file *filp, unsigned int cmd)
{ {
struct file_lock *fl; struct file_lock *fl;
int type = flock_translate_cmd(cmd); int type = flock_translate_cmd(cmd);
if (type < 0) if (type < 0)
return type; return ERR_PTR(type);
fl = locks_alloc_lock(); fl = locks_alloc_lock();
if (fl == NULL) if (fl == NULL)
return -ENOMEM; return ERR_PTR(-ENOMEM);
fl->fl_file = filp; fl->fl_file = filp;
fl->fl_owner = filp; fl->fl_owner = filp;
...@@ -345,8 +346,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock, ...@@ -345,8 +346,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,
fl->fl_type = type; fl->fl_type = type;
fl->fl_end = OFFSET_MAX; fl->fl_end = OFFSET_MAX;
*lock = fl; return fl;
return 0;
} }
static int assign_type(struct file_lock *fl, long type) static int assign_type(struct file_lock *fl, long type)
...@@ -1885,9 +1885,12 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) ...@@ -1885,9 +1885,12 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
!(f.file->f_mode & (FMODE_READ|FMODE_WRITE))) !(f.file->f_mode & (FMODE_READ|FMODE_WRITE)))
goto out_putf; goto out_putf;
error = flock_make_lock(f.file, &lock, cmd); lock = flock_make_lock(f.file, cmd);
if (error) if (IS_ERR(lock)) {
error = PTR_ERR(lock);
goto out_putf; goto out_putf;
}
if (can_sleep) if (can_sleep)
lock->fl_flags |= FL_SLEEP; lock->fl_flags |= FL_SLEEP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册