Skip to content

Commit e674f5a

Browse files
committed
drivers/dstate.c: fix style of CreateNamedPipe() etc. args for maintainability [#3302]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 46aa6cf commit e674f5a

1 file changed

Lines changed: 47 additions & 35 deletions

File tree

drivers/dstate.c

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,17 @@ static TYPE_FD sock_open(const char *fn)
195195
#else /* WIN32 */
196196

197197
fd = CreateNamedPipe(
198-
fn, /* pipe name */
199-
PIPE_ACCESS_DUPLEX | /* read/write access */
200-
FILE_FLAG_OVERLAPPED, /* async IO */
201-
PIPE_TYPE_BYTE |
202-
PIPE_READMODE_BYTE |
203-
PIPE_WAIT,
204-
PIPE_UNLIMITED_INSTANCES, /* max. instances */
205-
ST_SOCK_BUF_LEN, /* output buffer size */
206-
ST_SOCK_BUF_LEN, /* input buffer size */
207-
0, /* client time-out */
208-
NULL); /* FIXME: default security attribute */
198+
fn, /* pipe name */
199+
PIPE_ACCESS_DUPLEX /* read/write access */
200+
| FILE_FLAG_OVERLAPPED, /* async IO */
201+
PIPE_TYPE_BYTE
202+
| PIPE_READMODE_BYTE
203+
| PIPE_WAIT,
204+
PIPE_UNLIMITED_INSTANCES, /* max. instances */
205+
ST_SOCK_BUF_LEN, /* output buffer size */
206+
ST_SOCK_BUF_LEN, /* input buffer size */
207+
0, /* client time-out */
208+
NULL); /* FIXME: default security attribute */
209209

210210
if (INVALID_FD(fd)) {
211211
fatal_with_errno(EXIT_FAILURE,
@@ -214,10 +214,12 @@ static TYPE_FD sock_open(const char *fn)
214214

215215
/* Prepare an async wait on a connection on the pipe */
216216
memset(&connect_overlapped, 0, sizeof(connect_overlapped));
217-
connect_overlapped.hEvent = CreateEvent(NULL, /*Security*/
218-
FALSE, /* auto-reset*/
219-
FALSE, /* inital state = non signaled*/
220-
NULL /* no name*/);
217+
connect_overlapped.hEvent = CreateEvent(
218+
NULL, /* Security */
219+
FALSE, /* auto-reset */
220+
FALSE, /* initial state = non signaled */
221+
NULL /* no name */
222+
);
221223
if (connect_overlapped.hEvent == NULL) {
222224
fatal_with_errno(EXIT_FAILURE, "Can't create event");
223225
}
@@ -564,17 +566,17 @@ static void sock_connect(TYPE_FD sock)
564566

565567
/* sockfd is the handle of the connection pending pipe */
566568
sockfd = CreateNamedPipe(
567-
pipename, /* pipe name */
568-
PIPE_ACCESS_DUPLEX | /* read/write access */
569-
FILE_FLAG_OVERLAPPED, /* async IO */
570-
PIPE_TYPE_BYTE |
571-
PIPE_READMODE_BYTE |
572-
PIPE_WAIT,
573-
PIPE_UNLIMITED_INSTANCES, /* max. instances */
574-
ST_SOCK_BUF_LEN, /* output buffer size */
575-
ST_SOCK_BUF_LEN, /* input buffer size */
576-
0, /* client time-out */
577-
NULL); /* FIXME: default security attribute */
569+
pipename, /* pipe name */
570+
PIPE_ACCESS_DUPLEX /* read/write access */
571+
| FILE_FLAG_OVERLAPPED, /* async IO */
572+
PIPE_TYPE_BYTE
573+
| PIPE_READMODE_BYTE
574+
| PIPE_WAIT,
575+
PIPE_UNLIMITED_INSTANCES, /* max. instances */
576+
ST_SOCK_BUF_LEN, /* output buffer size */
577+
ST_SOCK_BUF_LEN, /* input buffer size */
578+
0, /* client time-out */
579+
NULL); /* FIXME: default security attribute */
578580

579581
if (INVALID_FD(sockfd)) {
580582
fatal_with_errno(EXIT_FAILURE,
@@ -584,10 +586,12 @@ static void sock_connect(TYPE_FD sock)
584586
/* Prepare a new async wait for a connection on the pipe */
585587
CloseHandle(connect_overlapped.hEvent);
586588
memset(&connect_overlapped,0,sizeof(connect_overlapped));
587-
connect_overlapped.hEvent = CreateEvent(NULL, /*Security*/
588-
FALSE, /* auto-reset*/
589-
FALSE, /* inital state = non signaled*/
590-
NULL /* no name*/);
589+
connect_overlapped.hEvent = CreateEvent(
590+
NULL, /* Security */
591+
FALSE, /* auto-reset */
592+
FALSE, /* initial state = non signaled */
593+
NULL /* no name */
594+
);
591595
if(connect_overlapped.hEvent == NULL ) {
592596
fatal_with_errno(EXIT_FAILURE, "Can't create event");
593597
}
@@ -599,10 +603,12 @@ static void sock_connect(TYPE_FD sock)
599603
/* Start a read operation on the newly connected pipe so we could wait on the event associated to this IO */
600604
memset(&conn->read_overlapped,0,sizeof(conn->read_overlapped));
601605
memset(conn->buf,0,sizeof(conn->buf));
602-
conn->read_overlapped.hEvent = CreateEvent(NULL, /*Security*/
603-
FALSE, /* auto-reset*/
604-
FALSE, /* inital state = non signaled*/
605-
NULL /* no name*/);
606+
conn->read_overlapped.hEvent = CreateEvent(
607+
NULL, /* Security */
608+
FALSE, /* auto-reset */
609+
FALSE, /* initial state = non signaled */
610+
NULL /* no name */
611+
);
606612
if(conn->read_overlapped.hEvent == NULL ) {
607613
fatal_with_errno(EXIT_FAILURE, "Can't create event");
608614
}
@@ -1088,7 +1094,13 @@ static void sock_read(conn_t *conn)
10881094
#ifdef WIN32
10891095
/* Restart async read */
10901096
memset(conn->buf,0,sizeof(conn->buf));
1091-
ReadFile(conn->fd,conn->buf,sizeof(conn->buf)-1,NULL,&(conn->read_overlapped)); /* -1 to be sure to have a trailling 0 */
1097+
ReadFile(
1098+
conn->fd,
1099+
conn->buf,
1100+
sizeof(conn->buf) - 1, /* -1 to be sure to have a trailing 0 */
1101+
NULL,
1102+
&(conn->read_overlapped)
1103+
);
10921104
#endif /* WIN32 */
10931105
}
10941106

0 commit comments

Comments
 (0)