Skip to content

Commit 70900ef

Browse files
committed
Fixed poll.h *readerCount++ error reported by TankorSmash
1 parent 198b481 commit 70900ef

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

test/mman/mman_client.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,13 @@
1010
#include <unistd.h>
1111
#include <string.h>
1212
#include <assert.h>
13-
14-
#ifndef _WIN32
15-
#define shm_close close
16-
#define shm_flush(fd)
17-
18-
int shm_size(int fd)
19-
{ struct stat sb;
20-
fstat(fd, &sb);
21-
off_t length = sb.st_size;
22-
return int(length);
23-
}
24-
#endif
13+
#include <more/shm_more.h>
2514

2615
int main(int argc, char **argv)
2716
{ int oflags=O_RDWR;
28-
int i;
2917
char *name = "/mmanjunk";
3018
int fd = shm_open(name, oflags, 0644 );
31-
fprintf(stderr,"Shared Mem Descriptor: fd=%d\n", fd);
19+
printf("Shared Mem Descriptor: fd=%d\n", fd);
3220
assert (fd>0);
3321
size_t length = shm_size(fd);
3422
char* p = (char *) mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

test/mman/mman_server.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
#include <unistd.h>
1111
#include <string.h>
1212
#include <assert.h>
13-
14-
#ifndef _WIN32
15-
#define shm_close close
16-
#define shm_ftruncate ftruncate
17-
#endif
13+
#include <more/shm_more.h>
1814

1915
int main(int argc, char **argv)
2016
{ int oflags=O_RDWR;

unistd/more/shm_more.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// unistd/more/shm_more.h
2+
// 2018/10/28 [email protected]
3+
4+
#ifndef shm_more_h
5+
#define shm_more_h
6+
7+
#ifndef _WIN32
8+
9+
#include <sys/stat.h>
10+
#include <fcntl.h>
11+
12+
#define shm_close close
13+
#define shm_ftruncate ftruncate
14+
#define shm_flush(fd)
15+
16+
int shm_size(int fd)
17+
{ struct stat sb;
18+
fstat(fd, &sb);
19+
off_t length = sb.st_size;
20+
return int(length);
21+
}
22+
#endif
23+
24+
#endif

unistd/poll.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ int poll(struct pollfd *fds, nfds_t nfds, int mille_timeout)
2626
if(!fd)
2727
{ return -1;
2828
}
29-
u_int* readerCount=&fd[0].fd_count;
29+
u_int* const readerCount=&fd[0].fd_count;
3030
*readerCount=0;
3131
SOCKET* fdReader=fd[0].fd_array;
3232
int writer=nfds;
33-
u_int* writerCount=&fd[nfds].fd_count;
33+
u_int* const writerCount=&fd[nfds].fd_count;
3434
*writerCount=0;
3535
SOCKET* fdWriter=fd[nfds].fd_array;
3636
for(int i=0;i<nfds;i++)
3737
{ if(fds[i].events & POLLIN)
3838
{ fdReader[*readerCount]=fds[i].fd;
39-
*readerCount++;
39+
(*readerCount)++;
4040
}
4141
if(fds[i].events & POLLOUT)
4242
{ fdWriter[*writerCount]=fds[i].fd;
43-
*writerCount++;
43+
(*writerCount)++;
4444
} }
4545
fd_set fdExcept;
4646
fdExcept.fd_count=0;

0 commit comments

Comments
 (0)