add: if (init_shm_mallocs()==-1) goto error;  if (init_timer()<0){ LOG(L_CRIT, "could not initialize timer, exiting...\n"); goto error; }
context: int main(int argc, char** argv){	FILE* cfg_stream;	int c,r;	char *tmp;	char *options;	int ret;	unsigned int seed;	int rfd;	/*init*/	ret=-1;	my_argc=argc; my_argv=argv;		/*init pkg mallocs (before parsing cfg or cmd line !)*/	if (init_pkg_mallocs()==-1)		goto error;#ifdef DBG_MSG_QA	fprintf(stderr, "WARNING: ser startup: "		"DBG_MSG_QA enabled, ser may exit abruptly\n");#endif	/* process command line (get port no, cfg. file path etc) */	opterr=0;	options=#ifdef STATS	"s:"#endif	"f:cp:m:b:l:n:N:rRvdDETVhw:t:u:g:P:G:i:x:";		while((c=getopt(argc,argv,options))!=-1){		switch(c){			case 'f':					cfg_file=optarg;					break;			case 'c':					config_check=1;					log_stderr=1; /* force stderr logging */					break;			case 's':				#ifdef STATS					stat_file=optarg;				#endif					break;			case 'p':					port_no=strtol(optarg, &tmp, 10);					if (tmp &&(*tmp)){						fprintf(stderr, "bad port number: -p %s\n", optarg);						goto error;					}					break;			case 'm':					shm_mem_size=strtol(optarg, &tmp, 10) * 1024 * 1024;					if (tmp &&(*tmp)){						fprintf(stderr, "bad shmem size number: -m %s\n",										optarg);						goto error;					};					LOG(L_INFO, "ser: shared memory allocated: %d MByte\n",									shm_mem_size );					break;			case 'b':					maxbuffer=strtol(optarg, &tmp, 10);					if (tmp &&(*tmp)){						fprintf(stderr, "bad max buffer size number: -p %s\n",											optarg);						goto error;					}					break;			case 'l':					/* add a new addr. to our address list */					if (add_listen_iface(optarg, 0, 0, 0)!=0){						fprintf(stderr, "failed to add new listen address\n");						goto error;					}					break;			case 'n':					children_no=strtol(optarg, &tmp, 10);					if ((tmp==0) ||(*tmp)){						fprintf(stderr, "bad process number: -n %s\n",									optarg);						goto error;					}					break;			case 'v':					check_via=1;					break;			case 'r':					received_dns|=DO_DNS;					break;			case 'R':					received_dns|=DO_REV_DNS;			case 'd':					debug++;					break;			case 'D':					dont_fork=1;					break;			case 'E':					log_stderr=1;					break;			case 'T':#ifdef USE_TCP					tcp_disable=1;#else					fprintf(stderr,"WARNING: tcp support not compiled in\n");#endif					break;			case 'N':#ifdef USE_TCP					tcp_children_no=strtol(optarg, &tmp, 10);					if ((tmp==0) ||(*tmp)){						fprintf(stderr, "bad process number: -N %s\n",									optarg);						goto error;					}#else					fprintf(stderr,"WARNING: tcp support not compiled in\n");#endif					break;			case 'V':					printf("version: %s\n", version);					printf("flags: %s\n", flags );					print_ct_constants();					printf("%s\n",id);					printf("%s compiled on %s with %s\n", __FILE__,							compiled, COMPILER );										exit(0);					break;			case 'h':					printf("version: %s\n", version);					printf("%s",help_msg);					exit(0);					break;			case 'w':					working_dir=optarg;					break;			case 't':					chroot_dir=optarg;					break;			case 'u':					user=optarg;					break;			case 'g':					group=optarg;					break;			case 'P':					pid_file=optarg;					break;		        case 'G':				        pgid_file=optarg;				        break;			case 'i':					fifo=optarg;					break;			case 'x':					unixsock_name=optarg;					break;			case '?':					if (isprint(optopt))						fprintf(stderr, "Unknown option `-%c.\n", optopt);					else						fprintf(stderr, 								"Unknown option character `\\x%x.\n",								optopt);					goto error;			case ':':					fprintf(stderr, 								"Option `-%c requires an argument.\n",								optopt);					goto error;			default:					abort();		}	}		/* fill missing arguments with the default values*/	if (cfg_file==0) cfg_file=CFG_FILE;	/* load config file or die */	cfg_stream=fopen (cfg_file, "r");	if (cfg_stream==0){		fprintf(stderr, "ERROR: loading config file(%s): %s\n", cfg_file,				strerror(errno));		goto error;	}	/* seed the prng */	/* try to use /dev/urandom if possible */	seed=0;	if ((rfd=open("/dev/urandom", O_RDONLY))!=-1){try_again:		if (read(rfd, (void*)&seed, sizeof(seed))==-1){			if (errno==EINTR) goto try_again; /* interrupted by signal */			LOG(L_WARN, "WARNING: could not read from /dev/urandom (%d)\n",						errno);		}		DBG("read %u from /dev/urandom\n", seed);			close(rfd);	}else{		LOG(L_WARN, "WARNING: could not open /dev/urandom (%d)\n", errno);	}	seed+=getpid()+time(0);	DBG("seeding PRNG with %u\n", seed);	srand(seed);	DBG("test random number %u\n", rand());			/*init shm mallocs (before parsing cfg !)	 *  this must be here to allow setting shm mem size from the command line	 *  and it must also be before init_timer and init_tcp	 *  => if shm_mem should be settable from the cfg file move everything	 *  after --andrei */	if (init_shm_mallocs()==-1)		goto error;	/*init timer, before parsing the cfg!*/	if (init_timer()<0){		LOG(L_CRIT, "could not initialize timer, exiting...\n");		goto error;	}		/* register a diagnostic FIFO command  - moved to fifo server - bogdan	if (register_core_fifo()<0) {		LOG(L_CRIT, "unable to register core FIFO commands\n");		goto error;	}*/	/*register builtin  modules*/	register_builtin_modules();	yyin=cfg_stream;	if ((yyparse()!=0)||(cfg_errors)){		fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors);		goto error;	}				print_rl();		/* fix parameters */	if (port_no<=0) port_no=SIP_PORT;#ifdef USE_TLS	if (tls_port_no<=0) tls_port_no=SIPS_PORT;#endif			if (children_no<=0) children_no=CHILD_NO;#ifdef USE_TCP	if (!tcp_disable){		if (tcp_children_no<=0) tcp_children_no=children_no;	}#endif		if (working_dir==0) working_dir="/";		/* get uid/gid */	if (user){		if (user2uid(&uid, &gid, user)<0){			fprintf(stderr, "bad user name/uid number: -u %s\n", user);			goto error;		}	}	if (group){		if (group2gid(&gid, group)<0){				fprintf(stderr, "bad group name/gid number: -u %s\n", group);			goto error;		}	}	/* fix sock/fifo uid/gid */	if (sock_user){		if (user2uid(&sock_uid, 0, sock_user)<0){			fprintf(stderr, "bad socket user name/uid number %s\n", user);			goto error;		}	}	if (sock_group){		if (group2gid(&sock_gid, sock_group)<0){			fprintf(stderr, "bad group name/gid number: -u %s\n", group);			goto error;		}	}	if (fix_all_socket_lists()!=0){		fprintf(stderr,  "failed to initialize list addresses\n");		goto error;	}	/* print all the listen addresses */	printf("Listening on \n");	print_all_socket_lists();	printf("Aliases: \n");	/*print_aliases();*/	print_aliases();	printf("\n");		if (dont_fork){		fprintf(stderr, "WARNING: no fork mode %s\n", 				(udp_listen)?(				(udp_listen->next)?" and more than one listen address found"				"(will use only the the first one)":""				):"and no udp listen address found" );	}	if (config_check){		fprintf(stderr, "config file ok, exiting...\n");		goto error;	}	#ifdef USE_TCP	if (!tcp_disable){		/*init tcp*/		if (init_tcp()<0){			LOG(L_CRIT, "could not initialize tcp, exiting...\n");			goto error;		}	}#ifdef USE_TLS	if (!tls_disable){		/* init tls*/		if (init_tls()<0){			LOG(L_CRIT, "could not initialize tls, exiting...\n");			goto error;		}	}#endif /* USE_TLS */#endif /* USE_TCP */	/* init_daemon? */	if (!dont_fork){		if ( daemonize(argv[0]) <0 ) goto error;	}	if (install_sigs() != 0){		fprintf(stderr, "ERROR: could not install the signal handlers\n");		goto error;	}			/*alloc pids*/#ifdef SHM_MEM	pt=shm_malloc(sizeof(struct process_table)*process_count());#else	pt=pkg_malloc(sizeof(struct process_table)*process_count());#endif	if (pt==0){		fprintf(stderr, "ERROR: out  of memory\n");		goto error;	}	memset(pt, 0, sizeof(struct process_table)*process_count());	if (disable_core_dump) set_core_dump(0, 0);	else set_core_dump(1, shm_mem_size+PKG_MEM_POOL_SIZE+4*1024*1024);	if (open_files_limit>0){		if(increase_open_fds(open_files_limit)<0){ 			fprintf(stderr, "ERROR: error could not increase file limits\n");			goto error;		}	}		if (init_modules() != 0) {		fprintf(stderr, "ERROR: error while initializing modules\n");		goto error;	}	/* fix routing lists */	if ( (r=fix_rls())!=0){		fprintf(stderr, "ERROR: error %x while trying to fix configuration\n",						r);		goto error;	};#ifdef STATS	if (init_stats(  dont_fork ? 1 : children_no  )==-1) goto error;#endif		ret=main_loop();	/*kill everything*/	kill_all_children(SIGTERM);	/*clean-up*/	cleanup(0);	return ret;error:	/*kill everything*/	kill_all_children(SIGTERM);	/*clean-up*/	cleanup(0);	return -1;}