|Main Archive Page > Month Archives > wireshark-dev archives|
On Oct 3, 2010, at 5:16 AM, Sake Blok wrote:
> The OSX-PPC buildbot is complaining:
> capture_dlg.c:266: warning: passing argument 4 of 'pcap_compile_nopcap' discards qualifiers from pointer target type
> Indeed the pointer given to pcap_compile_nopcap is declared as a "const gchar *" and the 4th argument of pcap_compile_nopcap is declared as a "char *".
> How can this be fixed?
> Do I have to copy the string first before giving it to pcap_compile_nopcap?
pcap_compile_nopcap() doesn't modify the string, so the only reason to copy the string would be to squelch the warning. In libpcap 1.0.x (which is the version in Snow Leopard), the declaration of pcap_compile_nopcap() was fixed to make that argument a "const char *".
Unfortunately, using pcap_open_dead() and pcap_compile() won't help on really old versions of libpcap, as pcap_compile()'s declaration wasn't changed to make the filter string argument a "const char *" until libpcap 0.9.x.
> Or can I just use a "(char *)" cast? That however would still defeat the purpose of the "const" declaration in the first place would it not?
Yes, but, in this particular case, you can, as indicated, trust pcap_compile()/pcap_compile_nopcap() not to try to modify the string. You should probably put a comment in about that.
Sent via: Wireshark-dev mailing list <email@example.com>