[Dnsmasq-discuss] Problem with index in cache.c on OpenBSD 3.4

Ross Williams rosswilliams@fastmail.fm
Sun, 14 Nov 2004 17:34:09 -0500


--Apple-Mail-4--242118813
Content-Type: multipart/mixed; boundary=Apple-Mail-3--242118831


--Apple-Mail-3--242118831
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Hi, in OpenBSD 3.4, there seems to be namespace conflict between 
/usr/include/string.h and cache.c in dnsmasq. DNSmasq declares index as 
a static integer, but it is already declared as a extern struct in 
string.h. The error follows:

$ make CC=gcc
gcc -O2    -Wall -W -c cache.c
cache.c:20: `index' redeclared as different kind of symbol
/usr/include/string.h:97: previous declaration of `index'
cache.c:20: warning: `index' was declared `extern' and later `static'
*** Error code 1

I suggest a simple fix of renaming the variable in cache.c to 
_dnsmasq_index to preserve namespace integrity. A patch file is 
attached that accomplishes this.

--Apple-Mail-3--242118831
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="cache_index-to-dnsmasq_index.patch"
Content-Disposition: attachment;
	filename=cache_index-to-dnsmasq_index.patch

20c20
< static int _dnsmasq_index;
---
> static int index;
25c25
< static char *record_source(struct hostsfile *add_hosts, int _dnsmasq_index);
---
> static char *record_source(struct hostsfile *add_hosts, int index);
39c39
<   _dnsmasq_index = 0;
---
>   index = 0;
51c51
< 	  crecp->uid = _dnsmasq_index++;
---
> 	  crecp->uid = index++;
88c88
<   crecp->uid = _dnsmasq_index++; /* invalidate CNAMES pointing to this. */
---
>   crecp->uid = index++; /* invalidate CNAMES pointing to this. */
503c503
< 			    unsigned short flags, int _dnsmasq_index)
---
> 			    unsigned short flags, int index)
517c517
<       cache->uid = _dnsmasq_index;
---
>       cache->uid = index;
523c523
< static void read_hostsfile(char *filename, int opts, char *buff, char *domain_suffix, int _dnsmasq_index)
---
> static void read_hostsfile(char *filename, int opts, char *buff, char *domain_suffix, int index)
582c582
< 		 add_hosts_entry(cache, &addr, addrlen, flags, _dnsmasq_index);
---
> 		 add_hosts_entry(cache, &addr, addrlen, flags, index);
587c587
< 		 add_hosts_entry(cache, &addr, addrlen, flags, _dnsmasq_index);
---
> 		 add_hosts_entry(cache, &addr, addrlen, flags, index);
786c786
< static char *record_source(struct hostsfile *addn_hosts, int _dnsmasq_index)
---
> static char *record_source(struct hostsfile *addn_hosts, int index)
791c791
<       if (addn_hosts->index == _dnsmasq_index)
---
>       if (addn_hosts->index == index)
803c803
< 	       unsigned short type, struct hostsfile *addn_hosts, int _dnsmasq_index)
---
> 	       unsigned short type, struct hostsfile *addn_hosts, int index)
848c848
<     source = record_source(addn_hosts, _dnsmasq_index);
---
>     source = record_source(addn_hosts, index);

--Apple-Mail-3--242118831--

--Apple-Mail-4--242118813
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iEYEARECAAYFAkGX3WUACgkQPz7cBDDXnlhe3QCffuOk2Xd0cOpdJYtIGRC+VWDd
4UEAni6f/0rHbLrnqenlHdw7ahv+dbfj
=MsZ7
-----END PGP SIGNATURE-----

--Apple-Mail-4--242118813--