On Fri, Jun 10, 2016 at 12:20:54PM +0200, Carlos Falgueras García wrote: > When you set an object attribute the memory is copied, sometimes an > allocations is needed and it must be checked. Before this patch all setters > method return void, so this patch makes all setters return int instead void > to communicate the error to user. > > Summary: > * All setters return int instead void > * All memory allocations inside setters are checked > * Unsetters are used if is possible in order to consolidate > > Signed-off-by: Carlos Falgueras García <carlosfg@xxxxxxxxxx> > --- > include/libnftnl/chain.h | 16 +++++++------- > include/libnftnl/expr.h | 12 +++++------ > include/libnftnl/gen.h | 8 +++---- > include/libnftnl/rule.h | 12 +++++------ > include/libnftnl/ruleset.h | 2 +- > include/libnftnl/set.h | 20 ++++++++--------- > include/libnftnl/table.h | 12 +++++------ > src/chain.c | 54 +++++++++++++++++++++++++--------------------- > src/expr.c | 36 ++++++++++++++++++------------- > src/expr/dynset.c | 5 ++++- > src/expr/immediate.c | 6 +++--- > src/expr/log.c | 7 ++++-- > src/expr/lookup.c | 5 ++++- > src/gen.c | 20 ++++++++++------- > src/rule.c | 46 ++++++++++++++++++++------------------- > src/ruleset.c | 19 ++++++++++------ > src/set.c | 40 ++++++++++++++++++---------------- > src/set_elem.c | 33 ++++++++++++++-------------- > src/table.c | 28 +++++++++++++----------- > 19 files changed, 210 insertions(+), 171 deletions(-) > > diff --git a/include/libnftnl/chain.h b/include/libnftnl/chain.h > index 954b39f..6419dee 100644 > --- a/include/libnftnl/chain.h > +++ b/include/libnftnl/chain.h > @@ -36,14 +36,14 @@ enum nftnl_chain_attr { > > bool nftnl_chain_is_set(const struct nftnl_chain *c, uint16_t attr); > void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr); > -void nftnl_chain_set(struct nftnl_chain *t, uint16_t attr, const void *data); > -void nftnl_chain_set_data(struct nftnl_chain *t, uint16_t attr, > - const void *data, uint32_t data_len); > -void nftnl_chain_set_u8(struct nftnl_chain *t, uint16_t attr, uint8_t data); > -void nftnl_chain_set_u32(struct nftnl_chain *t, uint16_t attr, uint32_t data); > -void nftnl_chain_set_s32(struct nftnl_chain *t, uint16_t attr, int32_t data); > -void nftnl_chain_set_u64(struct nftnl_chain *t, uint16_t attr, uint64_t data); > -void nftnl_chain_set_str(struct nftnl_chain *t, uint16_t attr, const char *str); > +int nftnl_chain_set(struct nftnl_chain *t, uint16_t attr, const void *data); > +int nftnl_chain_set_data(struct nftnl_chain *t, uint16_t attr, > + const void *data, uint32_t data_len); > +int nftnl_chain_set_u8(struct nftnl_chain *t, uint16_t attr, uint8_t data); > +int nftnl_chain_set_u32(struct nftnl_chain *t, uint16_t attr, uint32_t data); > +int nftnl_chain_set_s32(struct nftnl_chain *t, uint16_t attr, int32_t data); > +int nftnl_chain_set_u64(struct nftnl_chain *t, uint16_t attr, uint64_t data); _set_uXX never fail, so leave them using void as this just makes this more complicated. Please only update _set_data() and _set_str() as in my original patch that I handed over to you. Thanks. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html