netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libmnl] callback: mark cb_ctl_array 'const' in mnl_cb_run2()
@ 2016-08-03 10:52 Guillaume Nault
  2016-08-08 11:15 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Nault @ 2016-08-03 10:52 UTC (permalink / raw)
  To: netfilter-devel

Users of mnl_cb_run2() would typically pass a 'static const' array as
cb_ctl_array parameter. Unfortunately this triggers a compiler warning
because the prototype doesn't declare cb_ctl_array with the 'const'
qualifier.

Since mnl_cb_run2() and __mnl_cb_run() don't modify cb_ctl_array (and
don't have any reason to do so in the future), we can mark this
parameter as 'const'.

There should be no impact on existing users beyond removing the
compiler warning when using a constant array.

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
---
 include/libmnl/libmnl.h | 3 ++-
 src/callback.c          | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 5adb13c..0331da7 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -179,7 +179,8 @@ extern int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq,
 
 extern int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
 		       unsigned int portid, mnl_cb_t cb_data, void *data,
-		       mnl_cb_t *cb_ctl_array, unsigned int cb_ctl_array_len);
+		       const mnl_cb_t *cb_ctl_array,
+		       unsigned int cb_ctl_array_len);
 
 /*
  * other declarations
diff --git a/src/callback.c b/src/callback.c
index 00ffcf4..01181e6 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -48,7 +48,7 @@ static const mnl_cb_t default_cb_array[NLMSG_MIN_TYPE] = {
 static inline int __mnl_cb_run(const void *buf, size_t numbytes,
 			       unsigned int seq, unsigned int portid,
 			       mnl_cb_t cb_data, void *data,
-			       mnl_cb_t *cb_ctl_array,
+			       const mnl_cb_t *cb_ctl_array,
 			       unsigned int cb_ctl_array_len)
 {
 	int ret = MNL_CB_OK, len = numbytes;
@@ -130,7 +130,7 @@ out:
 EXPORT_SYMBOL(mnl_cb_run2);
 int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
 		unsigned int portid, mnl_cb_t cb_data, void *data,
-		mnl_cb_t *cb_ctl_array, unsigned int cb_ctl_array_len)
+		const mnl_cb_t *cb_ctl_array, unsigned int cb_ctl_array_len)
 {
 	return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data,
 			    cb_ctl_array, cb_ctl_array_len);
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH libmnl] callback: mark cb_ctl_array 'const' in mnl_cb_run2()
  2016-08-03 10:52 [PATCH libmnl] callback: mark cb_ctl_array 'const' in mnl_cb_run2() Guillaume Nault
@ 2016-08-08 11:15 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-08 11:15 UTC (permalink / raw)
  To: Guillaume Nault; +Cc: netfilter-devel

On Wed, Aug 03, 2016 at 12:52:34PM +0200, Guillaume Nault wrote:
> Users of mnl_cb_run2() would typically pass a 'static const' array as
> cb_ctl_array parameter. Unfortunately this triggers a compiler warning
> because the prototype doesn't declare cb_ctl_array with the 'const'
> qualifier.
> 
> Since mnl_cb_run2() and __mnl_cb_run() don't modify cb_ctl_array (and
> don't have any reason to do so in the future), we can mark this
> parameter as 'const'.
> 
> There should be no impact on existing users beyond removing the
> compiler warning when using a constant array.

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-08 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03 10:52 [PATCH libmnl] callback: mark cb_ctl_array 'const' in mnl_cb_run2() Guillaume Nault
2016-08-08 11:15 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).