free(ch);
int main(int ac, char **av) { 	FILE *ifh; 	char *p;	int n;	int linenum; 	char *line = NULL;	size_t linel = 0;	for (;;) {		int c = getopt_long(ac,av,"c:s",lopt,NULL);		if (c == -1) break;		switch (c) { 		default:		case '?':			usage(); 		case 'c':			fname = optarg;			break;		case 's':			use_syslog = 1;			break;		}	}	if (use_syslog) 		openlog("nameif",0,LOG_LOCAL0);			while (optind < ac) { 		struct change *ch = xmalloc(sizeof(struct change)); 		char pos[30];		if ((ac-optind) & 1) 			usage();		if (strlen(av[optind])+1>IFNAMSIZ) 			complain(_("interface name `%s' too long"), av[optind]);		strcpy(ch->ifname, av[optind]); 		optind++; 		sprintf(pos,_("argument %d"),optind); 		addchange(av[optind], ch, pos); 		optind++; 	} 	if (!clist || fname != default_conf) 		readconf(); 	ifh = fopen("/proc/net/dev", "r"); 	if (!ifh)  complain(_("open of /proc/net/dev: %s"), strerror(errno)); 	linenum = 0;	while (getdelim(&line, &linel, '\n', ifh) > 0) {		struct change *ch; 		unsigned char mac[6];		if (linenum++ < 2) 			continue;					p = line; 		while (isspace(*p)) 			++p;		n = strcspn(p, ": \t");  		p[n] = 0; 				if (n > IFNAMSIZ-1) 			complain(_("interface name `%s' too long"), p); 					if (getmac(p, mac) < 0) 			continue;					ch = lookupmac(mac); 		if (!ch) 			continue;					*ch->pprev = ch->next;		if (strcmp(p, ch->ifname)) { 			if (setname(p, ch->ifname) < 0)  				complain(_("cannot change name of %s to %s: %s"),						p, ch->ifname, strerror(errno)); 		} 		free(ch);	} 	fclose(ifh); 		while (clist) { 		struct change *ch = clist;		clist = clist->next;		warning(_("interface '%s' not found"), ch->ifname); 		free(ch); 	}	if (use_syslog)		closelog();	return 0;} 