Skip to contentSkip to conversation

locks: don't allocate a lock context for an F_UNLCK request

DISCUSSION Dan Carpenter 2 participants 2 messages Mar 10, 2015 VFS

lore
Share & tools
lore
#0 lore raw

Hello Jeff Layton,

The patch 7af81f664280: "locks: don't allocate a lock context for an F_UNLCK request" from Feb 26, 2015, leads to the following static checker warning:

	fs/locks.c:1613 generic_add_lease()
	warn: comparison is always 'false'

fs/locks.c

  1597  static int
  1598  generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **priv)
  1599  {
  1600          struct file_lock *fl, *my_fl = NULL, *lease;
  1601          struct dentry *dentry = filp->f_path.dentry;
  1602          struct inode *inode = dentry->d_inode;
  1603          struct file_lock_context *ctx;
  1604          bool is_deleg = (*flp)->fl_flags & FL_DELEG;
  1605          int error;
  1606          LIST_HEAD(dispose);
  1607  
  1608          lease = *flp;
  1609          trace_generic_add_lease(inode, lease);
  1610  
  1611          ctx = locks_get_lock_context(inode, arg);
  1612          if (!ctx)
  1613                  return (arg == F_UNLCK) ? 0 : -ENOMEM;
                                ^^^^^^^^^^^^^^

This will never be true. It's harmless, but I'm not sure it is intentional.

1614

regards,
dan carpenter

#1 lore raw
Quoted 28 lines · On Tue, 10 Mar 2015 23:10:50 +0300 Dan Carpenter <[email protected]>…

Hello Jeff Layton,

The patch 7af81f664280: "locks: don't allocate a lock context for an F_UNLCK request" from Feb 26, 2015, leads to the following static checker warning:

	fs/locks.c:1613 generic_add_lease()
	warn: comparison is always 'false'

fs/locks.c

  1597  static int
  1598  generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **priv)
  1599  {
  1600          struct file_lock *fl, *my_fl = NULL, *lease;
  1601          struct dentry *dentry = filp->f_path.dentry;
  1602          struct inode *inode = dentry->d_inode;
  1603          struct file_lock_context *ctx;
  1604          bool is_deleg = (*flp)->fl_flags & FL_DELEG;
  1605          int error;
  1606          LIST_HEAD(dispose);
  1607  
  1608          lease = *flp;
  1609          trace_generic_add_lease(inode, lease);
  1610  
  1611          ctx = locks_get_lock_context(inode, arg);
  1612          if (!ctx)
  1613                  return (arg == F_UNLCK) ? 0 : -ENOMEM;
                                ^^^^^^^^^^^^^^
Quoted 3 lines

This will never be true. It's harmless, but I'm not sure it is intentional.

Doh -- that's quite right. I'll take that bit out.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>