Re: [PATCH 1/2] iproute2: add libgenl files
From: Stephen Hemminger <hidden>
Date: 2012-09-10 22:43:22
On Tue, 11 Sep 2012 00:54:00 +0300 (EEST) Julian Anastasov [off-list ref] wrote:
quoted
Why not an inline function, macro code is error prone.The problem is that we define every request with its own structure in GENL_DEFINE_REQUEST. We can use init func instead of macro only if we define some base structure, for example: struct genl_header_base { struct nlmsghdr n; struct genlmsghdr g; };
Ok, that makes sense. I prefer C99 style initializers
in general. Maybe:
#define GENL_INIT_REQUEST(family, hdrsize, ver, cmd_, flags) { \
.req = { \
.n = { \
.nlmsg_type = (family), \
.nlmsg_flags = (flags), \
.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN + (hdrsize)), \
} \
.g = { \
.cmd = (cmd), \
.version = (ver), \
} \
}
Or merge GENL_DEFINE_REQUEST and GENL_INIT_REQUEST.
These are all nits, and not that important, just want to make it as simple
as possible. So if you like it okay as it was, we can just use that.