Commit 052f4f61 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

staging: lustre: remove the CFS_HOP() macro

CFS_HOP() is a terrible macro.  It chops the struct member name in half
so that it's not possible to use tools like grep or to search for how
a function pointer is used.

I removed a couple calls to:

	LASSERT(CFS_HOP(hs, put_locked) != NULL);

because they isn't a need for them.  Anyway dereferencing a NULL pointer
generates a pretty good stack trace already without adding extra debug
code.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f8bd34d2
...@@ -454,25 +454,23 @@ cfs_hash_bkt_size(struct cfs_hash *hs) ...@@ -454,25 +454,23 @@ cfs_hash_bkt_size(struct cfs_hash *hs)
hs->hs_extra_bytes; hs->hs_extra_bytes;
} }
#define CFS_HOP(hs, op) (hs)->hs_ops->hs_ ## op
static inline unsigned static inline unsigned
cfs_hash_id(struct cfs_hash *hs, const void *key, unsigned mask) cfs_hash_id(struct cfs_hash *hs, const void *key, unsigned mask)
{ {
return CFS_HOP(hs, hash)(hs, key, mask); return hs->hs_ops->hs_hash(hs, key, mask);
} }
static inline void * static inline void *
cfs_hash_key(struct cfs_hash *hs, struct hlist_node *hnode) cfs_hash_key(struct cfs_hash *hs, struct hlist_node *hnode)
{ {
return CFS_HOP(hs, key)(hnode); return hs->hs_ops->hs_key(hnode);
} }
static inline void static inline void
cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node *hnode, void *key) cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node *hnode, void *key)
{ {
if (CFS_HOP(hs, keycpy) != NULL) if (hs->hs_ops->hs_keycpy)
CFS_HOP(hs, keycpy)(hnode, key); hs->hs_ops->hs_keycpy(hnode, key);
} }
/** /**
...@@ -481,42 +479,38 @@ cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node *hnode, void *key) ...@@ -481,42 +479,38 @@ cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node *hnode, void *key)
static inline int static inline int
cfs_hash_keycmp(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) cfs_hash_keycmp(struct cfs_hash *hs, const void *key, struct hlist_node *hnode)
{ {
return CFS_HOP(hs, keycmp)(key, hnode); return hs->hs_ops->hs_keycmp(key, hnode);
} }
static inline void * static inline void *
cfs_hash_object(struct cfs_hash *hs, struct hlist_node *hnode) cfs_hash_object(struct cfs_hash *hs, struct hlist_node *hnode)
{ {
return CFS_HOP(hs, object)(hnode); return hs->hs_ops->hs_object(hnode);
} }
static inline void static inline void
cfs_hash_get(struct cfs_hash *hs, struct hlist_node *hnode) cfs_hash_get(struct cfs_hash *hs, struct hlist_node *hnode)
{ {
return CFS_HOP(hs, get)(hs, hnode); return hs->hs_ops->hs_get(hs, hnode);
} }
static inline void static inline void
cfs_hash_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) cfs_hash_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
{ {
LASSERT(CFS_HOP(hs, put_locked) != NULL); return hs->hs_ops->hs_put_locked(hs, hnode);
return CFS_HOP(hs, put_locked)(hs, hnode);
} }
static inline void static inline void
cfs_hash_put(struct cfs_hash *hs, struct hlist_node *hnode) cfs_hash_put(struct cfs_hash *hs, struct hlist_node *hnode)
{ {
LASSERT(CFS_HOP(hs, put) != NULL); return hs->hs_ops->hs_put(hs, hnode);
return CFS_HOP(hs, put)(hs, hnode);
} }
static inline void static inline void
cfs_hash_exit(struct cfs_hash *hs, struct hlist_node *hnode) cfs_hash_exit(struct cfs_hash *hs, struct hlist_node *hnode)
{ {
if (CFS_HOP(hs, exit)) if (hs->hs_ops->hs_exit)
CFS_HOP(hs, exit)(hs, hnode); hs->hs_ops->hs_exit(hs, hnode);
} }
static inline void cfs_hash_lock(struct cfs_hash *hs, int excl) static inline void cfs_hash_lock(struct cfs_hash *hs, int excl)
......
...@@ -1584,7 +1584,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, ...@@ -1584,7 +1584,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
stop_on_change = cfs_hash_with_rehash_key(hs) || stop_on_change = cfs_hash_with_rehash_key(hs) ||
!cfs_hash_with_no_itemref(hs) || !cfs_hash_with_no_itemref(hs) ||
CFS_HOP(hs, put_locked) == NULL; hs->hs_ops->hs_put_locked == NULL;
cfs_hash_lock(hs, 0); cfs_hash_lock(hs, 0);
LASSERT(!cfs_hash_is_rehashing(hs)); LASSERT(!cfs_hash_is_rehashing(hs));
...@@ -1639,9 +1639,9 @@ cfs_hash_for_each_nolock(struct cfs_hash *hs, ...@@ -1639,9 +1639,9 @@ cfs_hash_for_each_nolock(struct cfs_hash *hs,
!cfs_hash_with_no_itemref(hs)) !cfs_hash_with_no_itemref(hs))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (CFS_HOP(hs, get) == NULL || if (hs->hs_ops->hs_get == NULL ||
(CFS_HOP(hs, put) == NULL && (hs->hs_ops->hs_put == NULL &&
CFS_HOP(hs, put_locked) == NULL)) hs->hs_ops->hs_put_locked == NULL))
return -EOPNOTSUPP; return -EOPNOTSUPP;
cfs_hash_for_each_enter(hs); cfs_hash_for_each_enter(hs);
...@@ -1671,9 +1671,9 @@ cfs_hash_for_each_empty(struct cfs_hash *hs, ...@@ -1671,9 +1671,9 @@ cfs_hash_for_each_empty(struct cfs_hash *hs,
if (cfs_hash_with_no_lock(hs)) if (cfs_hash_with_no_lock(hs))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (CFS_HOP(hs, get) == NULL || if (hs->hs_ops->hs_get == NULL ||
(CFS_HOP(hs, put) == NULL && (hs->hs_ops->hs_put == NULL &&
CFS_HOP(hs, put_locked) == NULL)) hs->hs_ops->hs_put_locked == NULL))
return -EOPNOTSUPP; return -EOPNOTSUPP;
cfs_hash_for_each_enter(hs); cfs_hash_for_each_enter(hs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment