473,414 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

invalid pointer initialization

Hello all,

I'm facing some problems to compile a new module for Linux Ubuntu 8.04, kernel version 2.6. Above are two pieces of code related to the problem.

linux/netfilter.h
Expand|Select|Wrap|Line Numbers
  1. //begin netfilter
  2. ...
  3. typedef unsigned int nf_hookfn(unsigned int hooknum, struct sk_buff *skb, const struct net_devide *in, const struct net_device *out, int (*okfn)(struct sk_buff *));
  4. ...
  5. struct nf_hook_ops {
  6. struct list_head list;
  7. nf_hookfn *hook;
  8. struct module *owner;
  9. int pf;
  10. int hooknum;
  11. int priority;
  12. };
  13. ...
  14. // end netfilter 
  15.  
myfile.h
Expand|Select|Wrap|Line Numbers
  1. // begin myfile
  2. ...
  3. #include <netfilter.h>
  4. ...
  5. unsigned int my_nf_hook(unsigned int hook, struct sk_buff **skb, const struct net_device *indev, const struct net_device *outdev, int (*okfn)(struct sk_buff *)); // It is a function that is further implemented
  6. ...
  7. static struct nf_hook_ops nfh_pre = {
  8. {NULL, NULL},
  9. my_nf_hook,
  10. THIS_MODULE,
  11. PF_INET,
  12. NF_IP_PRE_ROUTING,
  13. NF_IP_PRI_FILTER+1
  14. };
  15. ...
  16. // end myfile 
  17.  
When I execute the 'make myfile.ko' to compile the module, it gives me the following warning:

... warning: initialization from incompatible pointer type

This warning is pointing the line '9. my_nf_hook' inside the struct nfh_pre initialization.

Well, after compiling, the ko file is generated. However, when I execute the command 'insmod myfile.ko' to load the module, it results in kernel panic. I believe that the warning is directed related to the problem.

Finally, my question: does anybody know where is the problem in the code above? What could be missing?

Thanks a lot in advance for repliers.
Mar 17 '09 #1
3 3580
newb16
687 512MB
Is it struct sk_buff **skb or struct sk_buff *skb in function args ? ( number of *'s )
Mar 17 '09 #2
That's right... it is **
Mar 17 '09 #3
Indeed, the pointer to pointer was the problem.
However, who is implementing with netfilter.h needs to be careful about that. From kernel 2.6.20 (I guess) it is a pointer only to skb sk_buff structure. But, from 2.6.19 version and lesser ones it is a double pointer (**skb).
Mar 17 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: DaKoadMunky | last post by:
I was recently looking at some assembly code generated by my compiler. When examining the assembly code associated with constructors I noticed that the dynamic-dispatch mechanism was enabled...
4
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC...
3
by: sathyashrayan | last post by:
The standard confirms that the following initialization of a struct struct node { --- --- } struct node var = {NULL};
35
by: tuko | last post by:
Hello kind people. Can someone explain please the following code? /* Create Storage Space For The Texture */ AUX_RGBImageRec *TextureImage; /* Line 1*/ /* Set The Pointer To NULL...
9
by: CQ | last post by:
Hi everyone, I get the following error when compiling my code: error: invalid initialization of non-const reference of type 'Vertex&' from a temporary of type 'int' The implementation of...
21
by: Roman Werpachowski | last post by:
I can't understand this: double * x = new double; const double * p = x; delete p; works. Why am I allowed to delete a const pointer? On the same note: why am I allowed to do this: class...
1
by: ank | last post by:
Hi, all. I've come to think of the idea of automatic initialization/deinitialization of non-local reference count pointer. I've made an assumption that the user of the pointer only read...
17
by: anyone.anon | last post by:
Let p=malloc(N) for some N>0. As far as I understand it, free(p+k) for 0<k<N causes undefined behavior, since only a pointer returned by (m| re|c)alloc() can validly be passed to free(). This...
68
by: DaveJ | last post by:
Recently I was working on a project where I came across an issue where the program cored and reported "free(): invalid pointer". I found a resolution for this, but don't fully understand why the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.