Multiple definitions. Code issue

Jouni Malinen j
Sat Apr 21 07:17:26 PDT 2007

On Thu, Apr 19, 2007 at 01:03:04PM +0200, ahuguet at wrote:

> What I did, before reading your mail, was another thing that, apparently,
> worked. I made a new header file, that contained solely this declaration:
> struct sk_buff *last_data_rx;
> Then, hostap_80211_rx.c is the only one to include said header. The
> multiple definition issue seems to be gone this way.

Declaring variables in header files is usually not a very good idea. If
you really need a file-global variable, I would recommend moving this
into the .c file that is using the variable and furthermore, changing
this to be static (static struct sk_buff *last_data_rx) to avoid name
conflicts with other files. Anyway, it would be much better to store
this in a per-interface data structure like Pavel already mentioned.

> I don't understand what you mean here, and it's something I'd like to. The
> modifications I'm trying to do are for lab testing purposes, but, anyhow,
> I don't see why declaring a global variable would make it card dependent.

Because the global variable would be shared by all instances of the
driver (i.e., one per wlan card).

> Also, while thinking about what I wanted to code, I've thought that maybe
> it was not a good idea to have a global pointer. I'd say that what I need
> is a global sk_buff structure, not a pointer to it.

Are you sure you need a _global_ sk_buff structure? I would assume you
need per-interface data, not global..

> So maybe it would be better if I had declared a struct sk_buff last_data_rx;
> on the header, rather than the pointer, and then at the code,
> do the struct sk_buff *pointer_to_skb=skb_copy(skb,GFP_KERNEL);
> and then:
> memcpy(&last_data_rx,pointer_to_skb,sizeof(*skb));
> Would this be correct?

I'm not sure what you are trying to do with this, but this looks very
odd. There is not much point doing something like this and you would
like end up in major problems with functions that try to free the skbs.

> If I added that sk_buff structure to the local_info one, as you suggest in
> order to avoid declaration of global variables, would that structure
> remain unchanged, from one void hostap_80211_rx execution until the other,
> and so on, until I decided to explicitly modify its value?

Yes and since local_info_t is already used in hostap_80211_rx(), this
would be very easy thing to do and should resolve all the issues with
use of global variables.

Jouni Malinen                                            PGP id EFC895FA

More information about the Hostap mailing list