diff options
| author | Johannes Berg <johannes.berg@intel.com> | 2013-11-19 09:19:31 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-11-19 16:39:05 -0500 |
| commit | c53ed7423619b4e8108914a9f31b426dd58ad591 (patch) | |
| tree | 03a469a7f00d99ff73bf947b5306369bfaff18f5 /include | |
| parent | dbde497966804e63a38fdedc1e3815e77097efc2 (diff) | |
genetlink: only pass array to genl_register_family_with_ops()
As suggested by David Miller, make genl_register_family_with_ops()
a macro and pass only the array, evaluating ARRAY_SIZE() in the
macro, this is a little safer.
The openvswitch has some indirection, assing ops/n_ops directly in
that code. This might ultimately just assign the pointers in the
family initializations, saving the struct genl_family_and_ops and
code (once mcast groups are handled differently.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/genl_magic_func.h | 3 | ||||
| -rw-r--r-- | include/net/genetlink.h | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h index 023bc346b877..47086030ab31 100644 --- a/include/linux/genl_magic_func.h +++ b/include/linux/genl_magic_func.h | |||
| @@ -293,8 +293,7 @@ static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ | |||
| 293 | 293 | ||
| 294 | int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) | 294 | int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) |
| 295 | { | 295 | { |
| 296 | int err = genl_register_family_with_ops(&ZZZ_genl_family, | 296 | int err = genl_register_family_with_ops(&ZZZ_genl_family, ZZZ_genl_ops); |
| 297 | ZZZ_genl_ops, ARRAY_SIZE(ZZZ_genl_ops)); | ||
| 298 | if (err) | 297 | if (err) |
| 299 | return err; | 298 | return err; |
| 300 | #undef GENL_mc_group | 299 | #undef GENL_mc_group |
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index e96385d46b48..9bd52a4c5e17 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
| @@ -152,8 +152,9 @@ static inline int genl_register_family(struct genl_family *family) | |||
| 152 | * | 152 | * |
| 153 | * Return 0 on success or a negative error code. | 153 | * Return 0 on success or a negative error code. |
| 154 | */ | 154 | */ |
| 155 | static inline int genl_register_family_with_ops(struct genl_family *family, | 155 | static inline int _genl_register_family_with_ops(struct genl_family *family, |
| 156 | const struct genl_ops *ops, size_t n_ops) | 156 | const struct genl_ops *ops, |
| 157 | size_t n_ops) | ||
| 157 | { | 158 | { |
| 158 | family->module = THIS_MODULE; | 159 | family->module = THIS_MODULE; |
| 159 | family->ops = ops; | 160 | family->ops = ops; |
| @@ -161,6 +162,9 @@ static inline int genl_register_family_with_ops(struct genl_family *family, | |||
| 161 | return __genl_register_family(family); | 162 | return __genl_register_family(family); |
| 162 | } | 163 | } |
| 163 | 164 | ||
| 165 | #define genl_register_family_with_ops(family, ops) \ | ||
| 166 | _genl_register_family_with_ops((family), (ops), ARRAY_SIZE(ops)) | ||
| 167 | |||
| 164 | int genl_unregister_family(struct genl_family *family); | 168 | int genl_unregister_family(struct genl_family *family); |
| 165 | int genl_register_mc_group(struct genl_family *family, | 169 | int genl_register_mc_group(struct genl_family *family, |
| 166 | struct genl_multicast_group *grp); | 170 | struct genl_multicast_group *grp); |
