From eb7535ee4459b4422105ef65abef5bde1c83e472 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 3 Feb 2011 10:29:03 +0100 Subject: doc: don't show up EXPORT_SYMBOL in doxygen Patrick reports that the doxygen output shows up EXPORT_SYMBOL and tells how to fix this: > I just noticed the EXPORT_SYMBOLs in libmnl showing up in > the doxygen output. Just in case you want to avoid this, > what I'm doing in libdect is (besides the appopriate linker > flags): > > #define __visible __attribute__((visibility("default"))) > > #define EXPORT_SYMBOL(x) typeof(x) (x) __visible > > > This allows to use EXPORT_SYMBOL as in the kernel, IOW > after the function definition. This patch also removes -Wredundant-decls to avoid a warning in every single use of this new approach. Now, this looks more like the Linux kernel way of exporting symbols. Reported-by: Patrick McHardy Signed-off-by: Pablo Neira Ayuso --- src/nlmsg.c | 68 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'src/nlmsg.c') diff --git a/src/nlmsg.c b/src/nlmsg.c index b2e3853..b398474 100644 --- a/src/nlmsg.c +++ b/src/nlmsg.c @@ -51,10 +51,11 @@ * This function returns the size of a netlink message (header plus payload) * without alignment. */ -EXPORT_SYMBOL size_t mnl_nlmsg_size(size_t len) +size_t mnl_nlmsg_size(size_t len) { return len + MNL_NLMSG_HDRLEN; } +EXPORT_SYMBOL(mnl_nlmsg_size); /** * mnl_nlmsg_get_payload_len - get the length of the Netlink payload @@ -63,10 +64,11 @@ EXPORT_SYMBOL size_t mnl_nlmsg_size(size_t len) * This function returns the Length of the netlink payload, ie. the length * of the full message minus the size of the Netlink header. */ -EXPORT_SYMBOL size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh) +size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh) { return nlh->nlmsg_len - MNL_NLMSG_HDRLEN; } +EXPORT_SYMBOL(mnl_nlmsg_get_payload_len); /** * mnl_nlmsg_put_header - reserve and prepare room for Netlink header @@ -77,7 +79,7 @@ EXPORT_SYMBOL size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh) * initializes the nlmsg_len field to the size of the Netlink header. This * function returns a pointer to the Netlink header structure. */ -EXPORT_SYMBOL struct nlmsghdr *mnl_nlmsg_put_header(void *buf) +struct nlmsghdr *mnl_nlmsg_put_header(void *buf) { int len = MNL_ALIGN(sizeof(struct nlmsghdr)); struct nlmsghdr *nlh = buf; @@ -86,6 +88,7 @@ EXPORT_SYMBOL struct nlmsghdr *mnl_nlmsg_put_header(void *buf) nlh->nlmsg_len = len; return nlh; } +EXPORT_SYMBOL(mnl_nlmsg_put_header); /** * mnl_nlmsg_put_extra_header - reserve and prepare room for an extra header @@ -98,7 +101,7 @@ EXPORT_SYMBOL struct nlmsghdr *mnl_nlmsg_put_header(void *buf) * you call this function. This function returns a pointer to the extra * header. */ -EXPORT_SYMBOL void * +void * mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size) { char *ptr = (char *)nlh + nlh->nlmsg_len; @@ -106,6 +109,7 @@ mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size) memset(ptr, 0, size); return ptr; } +EXPORT_SYMBOL(mnl_nlmsg_put_extra_header); /** * mnl_nlmsg_get_payload - get a pointer to the payload of the netlink message @@ -113,10 +117,11 @@ mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size) * * This function returns a pointer to the payload of the netlink message. */ -EXPORT_SYMBOL void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh) +void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh) { return (void *)nlh + MNL_NLMSG_HDRLEN; } +EXPORT_SYMBOL(mnl_nlmsg_get_payload); /** * mnl_nlmsg_get_payload_offset - get a pointer to the payload of the message @@ -126,11 +131,12 @@ EXPORT_SYMBOL void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh) * This function returns a pointer to the payload of the netlink message plus * a given offset. */ -EXPORT_SYMBOL void * +void * mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset) { return (void *)nlh + MNL_NLMSG_HDRLEN + MNL_ALIGN(offset); } +EXPORT_SYMBOL(mnl_nlmsg_get_payload_offset); /** * mnl_nlmsg_ok - check a there is room for netlink message @@ -148,12 +154,13 @@ mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset) * The len parameter may become negative in malformed messages during message * iteration, that is why we use a signed integer. */ -EXPORT_SYMBOL bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len) +bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len) { return len >= (int)sizeof(struct nlmsghdr) && nlh->nlmsg_len >= sizeof(struct nlmsghdr) && (int)nlh->nlmsg_len <= len; } +EXPORT_SYMBOL(mnl_nlmsg_ok); /** * mnl_nlmsg_next - get the next netlink message in a multipart message @@ -168,12 +175,13 @@ EXPORT_SYMBOL bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len) * You have to use mnl_nlmsg_ok() to check if the next Netlink message is * valid. */ -EXPORT_SYMBOL struct nlmsghdr * +struct nlmsghdr * mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len) { *len -= MNL_ALIGN(nlh->nlmsg_len); return (struct nlmsghdr *)((void *)nlh + MNL_ALIGN(nlh->nlmsg_len)); } +EXPORT_SYMBOL(mnl_nlmsg_next); /** * mnl_nlmsg_get_payload_tail - get the ending of the netlink message @@ -183,10 +191,11 @@ mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len) * to build a message since we continue adding attributes at the end of the * message. */ -EXPORT_SYMBOL void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh) +void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh) { return (void *)nlh + MNL_ALIGN(nlh->nlmsg_len); } +EXPORT_SYMBOL(mnl_nlmsg_get_payload_tail); /** * mnl_nlmsg_seq_ok - perform sequence tracking @@ -202,11 +211,12 @@ EXPORT_SYMBOL void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh) * socket to send commands to kernel-space (that we want to track) and to * listen to events (that we do not track). */ -EXPORT_SYMBOL bool +bool mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq) { return nlh->nlmsg_seq && seq ? nlh->nlmsg_seq == seq : true; } +EXPORT_SYMBOL(mnl_nlmsg_seq_ok); /** * mnl_nlmsg_portid_ok - perform portID origin check @@ -222,11 +232,12 @@ mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq) * to kernel-space (that we want to track) and to listen to events (that we * do not track). */ -EXPORT_SYMBOL bool +bool mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, unsigned int portid) { return nlh->nlmsg_pid && portid ? nlh->nlmsg_pid == portid : true; } +EXPORT_SYMBOL(mnl_nlmsg_portid_ok); static void mnl_nlmsg_fprintf_header(FILE *fd, const struct nlmsghdr *nlh) { @@ -357,7 +368,7 @@ mnl_nlmsg_fprintf_payload(FILE *fd, const struct nlmsghdr *nlh, * - N, that indicates that NLA_F_NESTED is set. * - B, that indicates that NLA_F_NET_BYTEORDER is set. */ -EXPORT_SYMBOL void +void mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen, size_t extra_header_size) { @@ -370,6 +381,7 @@ mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen, nlh = mnl_nlmsg_next(nlh, &len); } } +EXPORT_SYMBOL(mnl_nlmsg_fprintf); /** * \defgroup batch Netlink message batch helpers @@ -427,8 +439,7 @@ struct mnl_nlmsg_batch { * the heap, no restrictions in this regard. This function returns NULL on * error. */ -EXPORT_SYMBOL struct mnl_nlmsg_batch * -mnl_nlmsg_batch_start(void *buf, size_t limit) +struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, size_t limit) { struct mnl_nlmsg_batch *b; @@ -444,6 +455,7 @@ mnl_nlmsg_batch_start(void *buf, size_t limit) return b; } +EXPORT_SYMBOL(mnl_nlmsg_batch_start); /** * mnl_nlmsg_batch_stop - release a batch @@ -451,11 +463,11 @@ mnl_nlmsg_batch_start(void *buf, size_t limit) * * This function returns the amount of data that is part of this batch. */ -EXPORT_SYMBOL void -mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b) +void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b) { free(b); } +EXPORT_SYMBOL(mnl_nlmsg_batch_stop); /** * mnl_nlmsg_batch_next - get room for the next message in the batch @@ -468,8 +480,7 @@ mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b) * You have to put at least one message in the batch before calling this * function, otherwise your application is likely to crash. */ -EXPORT_SYMBOL bool -mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b) +bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b) { struct nlmsghdr *nlh = b->cur; @@ -481,6 +492,7 @@ mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b) b->buflen += nlh->nlmsg_len; return true; } +EXPORT_SYMBOL(mnl_nlmsg_batch_next); /** * mnl_nlmsg_batch_reset - reset the batch @@ -490,8 +502,7 @@ mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b) * new one. This function moves the last message which does not fit the * batch to the head of the buffer, if any. */ -EXPORT_SYMBOL void -mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b) +void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b) { if (b->overflow) { struct nlmsghdr *nlh = b->cur; @@ -504,6 +515,7 @@ mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b) b->cur = b->buf; } } +EXPORT_SYMBOL(mnl_nlmsg_batch_reset); /** * mnl_nlmsg_batch_size - get current size of the batch @@ -511,11 +523,11 @@ mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b) * * This function returns the current size of the batch. */ -EXPORT_SYMBOL size_t -mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b) +size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b) { return b->buflen; } +EXPORT_SYMBOL(mnl_nlmsg_batch_size); /** * mnl_nlmsg_batch_head - get head of this batch @@ -524,11 +536,11 @@ mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b) * This function returns a pointer to the head of the batch, which is the * beginning of the buffer that is used. */ -EXPORT_SYMBOL void * -mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b) +void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b) { return b->buf; } +EXPORT_SYMBOL(mnl_nlmsg_batch_head); /** * mnl_nlmsg_batch_current - returns current position in the batch @@ -537,11 +549,11 @@ mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b) * This function returns a pointer to the current position in the buffer * that is used to store the batch. */ -EXPORT_SYMBOL void * -mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b) +void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b) { return b->cur; } +EXPORT_SYMBOL(mnl_nlmsg_batch_current); /** * mnl_nlmsg_batch_is_empty - check if there is any message in the batch @@ -549,11 +561,11 @@ mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b) * * This function returns true if the batch is empty. */ -EXPORT_SYMBOL bool -mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b) +bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b) { return b->buflen == 0; } +EXPORT_SYMBOL(mnl_nlmsg_batch_is_empty); /** * @} -- cgit v1.2.3