Discussion:
[PATCH] iw: handle HAVE_LIBNL20 properly
Sergey Senozhatsky
2012-04-27 20:34:53 UTC
Permalink
iw: handle HAVE_LIBNL20 properly

Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.

Patch also change include of "nl80211.h" to <linux/nl80211.h>.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky-***@public.gmane.org>

---

src/tuning/iw.c | 4 ----
src/tuning/iw.h | 12 +++++++-----
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/tuning/iw.c b/src/tuning/iw.c
index 36abc00..aeba3fd 100644
--- a/src/tuning/iw.c
+++ b/src/tuning/iw.c
@@ -45,10 +45,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <netlink/msg.h>
#include <netlink/attr.h>

-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "nl80211.h"
#include <asm/errno.h>
#include <linux/genetlink.h>
#include "iw.h"
diff --git a/src/tuning/iw.h b/src/tuning/iw.h
index e0eef15..acf132d 100644
--- a/src/tuning/iw.h
+++ b/src/tuning/iw.h
@@ -32,19 +32,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

-
#include <stdbool.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>

-#include "nl80211.h"
+#include <linux/nl80211.h>

#define ETH_ALEN 6

-#ifndef CONFIG_LIBNL20
-# define nl_sock nl_handle
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef HAVE_LIBNL20
+#define nl_sock nl_handle
#endif

struct nl80211_state {
@@ -69,5 +72,4 @@ enum id_input {
int get_wifi_power_saving(const char *iface);
int set_wifi_power_saving(const char *iface, int state);

-
#endif /* __IW_H */
Mike Frysinger
2012-04-27 20:44:08 UTC
Permalink
Post by Sergey Senozhatsky
iw: handle HAVE_LIBNL20 properly
Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.
glancing through the libnl headers, it seems we don't even need to manage
HAVE_LIBNL20 in autoconf. we can include netlink/version.h and key off of
LIBNL_VER_MAJ.
-mike
Arjan van de Ven
2012-04-27 20:43:11 UTC
Permalink
Post by Mike Frysinger
Post by Sergey Senozhatsky
iw: handle HAVE_LIBNL20 properly
Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.
glancing through the libnl headers, it seems we don't even need to manage
HAVE_LIBNL20 in autoconf. we can include netlink/version.h and key off of
LIBNL_VER_MAJ.
-mike
one thing to note is that the iw.c code is borrowed from elsewhere...

the more we deviate, the harder it will be to follow the other code
(not that we needed to so far)
Mike Frysinger
2012-04-27 23:19:38 UTC
Permalink
Post by Arjan van de Ven
Post by Mike Frysinger
Post by Sergey Senozhatsky
iw: handle HAVE_LIBNL20 properly
Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.
glancing through the libnl headers, it seems we don't even need to manage
HAVE_LIBNL20 in autoconf. we can include netlink/version.h and key off
of LIBNL_VER_MAJ.
one thing to note is that the iw.c code is borrowed from elsewhere...
the more we deviate, the harder it will be to follow the other code
(not that we needed to so far)
hmm, no biggie. the file is small, and my suggestion isn't critical, so
keeping current stuff is ok.
-mike
Arjan van de Ven
2012-04-28 00:50:37 UTC
Permalink
Post by Mike Frysinger
Post by Arjan van de Ven
Post by Mike Frysinger
Post by Sergey Senozhatsky
iw: handle HAVE_LIBNL20 properly
Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.
glancing through the libnl headers, it seems we don't even need to manage
HAVE_LIBNL20 in autoconf. we can include netlink/version.h and key off
of LIBNL_VER_MAJ.
one thing to note is that the iw.c code is borrowed from elsewhere...
the more we deviate, the harder it will be to follow the other code
(not that we needed to so far)
hmm, no biggie. the file is small, and my suggestion isn't critical, so
keeping current stuff is ok.
if we're really improving it we should send the patches also to the
maintainer at least..
Sergey Senozhatsky
2012-05-04 10:58:26 UTC
Permalink
Post by Arjan van de Ven
Post by Mike Frysinger
Post by Arjan van de Ven
Post by Mike Frysinger
Post by Sergey Senozhatsky
iw: handle HAVE_LIBNL20 properly
Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.
glancing through the libnl headers, it seems we don't even need to manage
HAVE_LIBNL20 in autoconf. we can include netlink/version.h and key off
of LIBNL_VER_MAJ.
one thing to note is that the iw.c code is borrowed from elsewhere...
the more we deviate, the harder it will be to follow the other code
(not that we needed to so far)
hmm, no biggie. the file is small, and my suggestion isn't critical, so
keeping current stuff is ok.
if we're really improving it we should send the patches also to the
maintainer at least..
Hello,

We still need this patch to be applied (or workaround).

There is a

#ifndef CONFIG_LIBNL20
# define nl_sock nl_handle
#endif

in iw.h, which depends on LIBNL20 config option.


tuning/iw.c: In function ‘nl80211_init’:
tuning/iw.c:86:17: warning: assignment from incompatible pointer type [enabled by default]
tuning/iw.c:92:2: warning: passing argument 1 of ‘genl_connect’ from incompatible pointer type [enabled by default]
In file included from tuning/iw.c:42:0:
/usr/include/libnl3/netlink/genl/genl.h:23:13: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:98:2: warning: passing argument 1 of ‘genl_ctrl_alloc_cache’ from incompatible pointer type [enabled by default]
In file included from tuning/iw.c:44:0:
/usr/include/libnl3/netlink/genl/ctrl.h:25:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:115:2: warning: passing argument 1 of ‘nl_socket_free’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/netlink.h:33:0,
from /usr/include/libnl3/netlink/genl/genl.h:15,
from tuning/iw.c:42:
/usr/include/libnl3/netlink/socket.h:24:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c: In function ‘nl80211_cleanup’:
tuning/iw.c:123:2: warning: passing argument 1 of ‘nl_socket_free’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/netlink.h:33:0,
from /usr/include/libnl3/netlink/genl/genl.h:15,
from tuning/iw.c:42:
/usr/include/libnl3/netlink/socket.h:24:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c: In function ‘__handle_cmd’:
tuning/iw.c:246:2: warning: passing argument 1 of ‘nl_send_auto_complete’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/genl/genl.h:15:0,
from tuning/iw.c:42:
/usr/include/libnl3/netlink/netlink.h:62:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:257:3: warning: passing argument 1 of ‘nl_recvmsgs’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/genl/genl.h:15:0,
from tuning/iw.c:42:
/usr/include/libnl3/netlink/netlink.h:73:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’



-ss
Chris Ferron
2012-05-04 16:59:42 UTC
Permalink
Post by Sergey Senozhatsky
Post by Arjan van de Ven
Post by Mike Frysinger
Post by Arjan van de Ven
Post by Mike Frysinger
Post by Sergey Senozhatsky
iw: handle HAVE_LIBNL20 properly
Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.
glancing through the libnl headers, it seems we don't even need to manage
HAVE_LIBNL20 in autoconf. we can include netlink/version.h and key off
of LIBNL_VER_MAJ.
one thing to note is that the iw.c code is borrowed from elsewhere...
the more we deviate, the harder it will be to follow the other code
(not that we needed to so far)
hmm, no biggie. the file is small, and my suggestion isn't critical, so
keeping current stuff is ok.
if we're really improving it we should send the patches also to the
maintainer at least..
Hello,
We still need this patch to be applied (or workaround).
There is a
#ifndef CONFIG_LIBNL20
# define nl_sock nl_handle
#endif
in iw.h, which depends on LIBNL20 config option.
tuning/iw.c:86:17: warning: assignment from incompatible pointer type [enabled by default]
tuning/iw.c:92:2: warning: passing argument 1 of ‘genl_connect’ from incompatible pointer type [enabled by default]
/usr/include/libnl3/netlink/genl/genl.h:23:13: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:98:2: warning: passing argument 1 of ‘genl_ctrl_alloc_cache’ from incompatible pointer type [enabled by default]
/usr/include/libnl3/netlink/genl/ctrl.h:25:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:115:2: warning: passing argument 1 of ‘nl_socket_free’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/netlink.h:33:0,
from /usr/include/libnl3/netlink/genl/genl.h:15,
/usr/include/libnl3/netlink/socket.h:24:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:123:2: warning: passing argument 1 of ‘nl_socket_free’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/netlink.h:33:0,
from /usr/include/libnl3/netlink/genl/genl.h:15,
/usr/include/libnl3/netlink/socket.h:24:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:246:2: warning: passing argument 1 of ‘nl_send_auto_complete’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/genl/genl.h:15:0,
/usr/include/libnl3/netlink/netlink.h:62:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
tuning/iw.c:257:3: warning: passing argument 1 of ‘nl_recvmsgs’ from incompatible pointer type [enabled by default]
In file included from /usr/include/libnl3/netlink/genl/genl.h:15:0,
/usr/include/libnl3/netlink/netlink.h:73:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’
Sorry it was held up in some autoconf work.
its in now.
-Chris
Post by Sergey Senozhatsky
-ss
Sergey Senozhatsky
2012-05-04 18:03:50 UTC
Permalink
Post by Chris Ferron
Sorry it was held up in some autoconf work.
its in now.
-Chris
No problems at all.

Thank you!


-ss
Németh Márton
2012-05-18 08:22:01 UTC
Permalink
Hi,

starting with the commit b0d2854861de2f15671e633da11f42207d4357df
I get the following compile time error:

[...]
gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -g -O2 -MT tuning/powertop-iw.o -MD -MP -MF tuning/.deps/powertop-iw.Tpo -c -o tuning/powertop-iw.o
`test -f 'tuning/iw.c' || echo './'`tuning/iw.c
tuning/iw.c: In function ‘set_power_save’:
tuning/iw.c:129: error: storage size of ‘ps_state’ isn’t known
tuning/iw.c:131: error: ‘NL80211_PS_DISABLED’ undeclared (first use in this function)
tuning/iw.c:131: error: (Each undeclared identifier is reported only once
tuning/iw.c:131: error: for each function it appears in.)
tuning/iw.c:133: error: ‘NL80211_PS_ENABLED’ undeclared (first use in this function)
tuning/iw.c:135: error: ‘NL80211_ATTR_PS_STATE’ undeclared (first use in this function)
tuning/iw.c: In function ‘print_power_save_handler’:
tuning/iw.c:151: error: ‘NL80211_ATTR_PS_STATE’ undeclared (first use in this function)
tuning/iw.c:155: error: ‘NL80211_PS_ENABLED’ undeclared (first use in this function)
tuning/iw.c:158: error: ‘NL80211_PS_DISABLED’ undeclared (first use in this function)
tuning/iw.c: In function ‘__handle_cmd’:
tuning/iw.c:226: error: ‘NL80211_CMD_GET_POWER_SAVE’ undeclared (first use in this function)
tuning/iw.c:229: error: ‘NL80211_CMD_SET_POWER_SAVE’ undeclared (first use in this function)
make[3]: *** [tuning/powertop-iw.o] Error 1
make[3]: Leaving directory `/mnt/store/nmarci/src/powertop/powertop2/powertop/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/mnt/store/nmarci/src/powertop/powertop2/powertop/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/store/nmarci/src/powertop/powertop2/powertop'
make: *** [all] Error 2
$

This is the commit in question:

commit b0d2854861de2f15671e633da11f42207d4357df
Author: Sergey Senozhatsky <sergey.senozhatsky-***@public.gmane.org>
Date: Fri Apr 27 23:34:53 2012 +0300

iw: handle HAVE_LIBNL20 properly

iw: handle HAVE_LIBNL20 properly

Move HAVE_CONFIG_H and config.h inclusion to iw header file, which is
the right place for HAVE_LIBNL20 dependent `define nl_sock nl_handle'.

Patch also change include of "nl80211.h" to <linux/nl80211.h>.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky-***@public.gmane.org>

diff --git a/src/tuning/iw.c b/src/tuning/iw.c
index 36abc00..aeba3fd 100644
--- a/src/tuning/iw.c
+++ b/src/tuning/iw.c
@@ -45,10 +45,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <netlink/msg.h>
#include <netlink/attr.h>

-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "nl80211.h"
#include <asm/errno.h>
#include <linux/genetlink.h>
#include "iw.h"
diff --git a/src/tuning/iw.h b/src/tuning/iw.h
index e0eef15..acf132d 100644
--- a/src/tuning/iw.h
+++ b/src/tuning/iw.h
@@ -32,19 +32,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

-
#include <stdbool.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>

-#include "nl80211.h"
+#include <linux/nl80211.h>

#define ETH_ALEN 6

-#ifndef CONFIG_LIBNL20
-# define nl_sock nl_handle
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef HAVE_LIBNL20
+#define nl_sock nl_handle
#endif

struct nl80211_state {
@@ -69,5 +72,4 @@ enum id_input {
int get_wifi_power_saving(const char *iface);
int set_wifi_power_saving(const char *iface, int state);

-
#endif /* __IW_H */

Also note that if I revert only this commit on top of the
current master (ab9e20f46c1bc04de9e74a51a398258522329764)
then powertop compiles cleanly.

$ dpkg -S /usr/include/linux/nl80211.h
linux-libc-dev: /usr/include/linux/nl80211.h

$ dpkg -l linux-libc-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=============================-=============================-==========================================================================
ii linux-libc-dev 2.6.32-45 Linux support headers for userspace development
$ lsb_release -a
LSB Version:
core-2.0-ia32:core-2.0-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:cxx-3.0-ia32:cxx-3.0-noarch:cxx-3.1-ia32:cxx-3.1-noarch:cxx-3.2-ia32:cxx-3.2-noarch:desktop-3.1-ia32:desktop-3.1-noarch:desktop-3.2-ia32:desktop-3.2-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:graphics-3.1-ia32:graphics-3.1-noarch:graphics-3.2-ia32:graphics-3.2-noarch:qt4-3.1-ia32:qt4-3.1-noarch
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.5 (squeeze)
Release: 6.0.5
Codename: squeeze

Regards,

Márton Németh

Loading...