Constant replaced with macro MODES_NET_SERVICES_NUM.

This commit is contained in:
antirez 2013-12-14 22:38:39 +01:00
parent 38ed7698b3
commit eec5a6989f

View File

@ -1894,12 +1894,13 @@ void snipMode(int level) {
*/ */
/* Networking "stack" initialization. */ /* Networking "stack" initialization. */
#define MODES_NET_SERVICES_NUM 4
void modesInitNet(void) { void modesInitNet(void) {
struct { struct {
char *descr; char *descr;
int *socket; int *socket;
int port; int port;
} services[4] = { } services[MODES_NET_SERVICES_NUM] = {
{"Raw TCP output", &Modes.ros, Modes.net_output_raw_port}, {"Raw TCP output", &Modes.ros, Modes.net_output_raw_port},
{"Raw TCP input", &Modes.ris, Modes.net_input_raw_port}, {"Raw TCP input", &Modes.ris, Modes.net_input_raw_port},
{"HTTP server", &Modes.https, Modes.net_http_port}, {"HTTP server", &Modes.https, Modes.net_http_port},
@ -1910,7 +1911,7 @@ void modesInitNet(void) {
memset(Modes.clients,0,sizeof(Modes.clients)); memset(Modes.clients,0,sizeof(Modes.clients));
Modes.maxfd = -1; Modes.maxfd = -1;
for (j = 0; j < 4; j++) { for (j = 0; j < MODES_NET_SERVICES_NUM; j++) {
int s = anetTcpServer(Modes.aneterr, services[j].port, NULL); int s = anetTcpServer(Modes.aneterr, services[j].port, NULL);
if (s == -1) { if (s == -1) {
fprintf(stderr, "Error opening the listening port %d (%s): %s\n", fprintf(stderr, "Error opening the listening port %d (%s): %s\n",