Commit 6e129d00689c4d75253d1d428e82047b0aef5891
1 parent
7ca76311fe
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
locks: flock_make_lock should return a struct file_lock (or PTR_ERR)
Eliminate the need for a return pointer. Signed-off-by: Jeff Layton <jlayton@primarydata.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Showing 1 changed file with 11 additions and 8 deletions Side-by-side Diff
fs/locks.c
... | ... | @@ -326,17 +326,18 @@ |
326 | 326 | } |
327 | 327 | |
328 | 328 | /* Fill in a file_lock structure with an appropriate FLOCK lock. */ |
329 | -static int flock_make_lock(struct file *filp, struct file_lock **lock, | |
330 | - unsigned int cmd) | |
329 | +static struct file_lock * | |
330 | +flock_make_lock(struct file *filp, unsigned int cmd) | |
331 | 331 | { |
332 | 332 | struct file_lock *fl; |
333 | 333 | int type = flock_translate_cmd(cmd); |
334 | + | |
334 | 335 | if (type < 0) |
335 | - return type; | |
336 | + return ERR_PTR(type); | |
336 | 337 | |
337 | 338 | fl = locks_alloc_lock(); |
338 | 339 | if (fl == NULL) |
339 | - return -ENOMEM; | |
340 | + return ERR_PTR(-ENOMEM); | |
340 | 341 | |
341 | 342 | fl->fl_file = filp; |
342 | 343 | fl->fl_owner = filp; |
... | ... | @@ -345,8 +346,7 @@ |
345 | 346 | fl->fl_type = type; |
346 | 347 | fl->fl_end = OFFSET_MAX; |
347 | 348 | |
348 | - *lock = fl; | |
349 | - return 0; | |
349 | + return fl; | |
350 | 350 | } |
351 | 351 | |
352 | 352 | static int assign_type(struct file_lock *fl, long type) |
353 | 353 | |
... | ... | @@ -1885,9 +1885,12 @@ |
1885 | 1885 | !(f.file->f_mode & (FMODE_READ|FMODE_WRITE))) |
1886 | 1886 | goto out_putf; |
1887 | 1887 | |
1888 | - error = flock_make_lock(f.file, &lock, cmd); | |
1889 | - if (error) | |
1888 | + lock = flock_make_lock(f.file, cmd); | |
1889 | + if (IS_ERR(lock)) { | |
1890 | + error = PTR_ERR(lock); | |
1890 | 1891 | goto out_putf; |
1892 | + } | |
1893 | + | |
1891 | 1894 | if (can_sleep) |
1892 | 1895 | lock->fl_flags |= FL_SLEEP; |
1893 | 1896 |