comparison ios/dw.m @ 2855:86286f528adf

Fix new safety warnings reported by the new GCC on Linux. The semaphore code is used on other platforms... make sure all platforms using this code are the same.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 15 Nov 2022 03:50:00 +0000
parents 2934b2fdcd8e
children ec0d34798706
comparison
equal deleted inserted replaced
2854:8a5131cbbe93 2855:86286f528adf
11241 *eve = NULL; 11241 *eve = NULL;
11242 11242
11243 return DW_ERROR_NONE; 11243 return DW_ERROR_NONE;
11244 } 11244 }
11245 11245
11246 struct _seminfo { 11246 struct _dw_seminfo {
11247 int fd; 11247 int fd;
11248 int waiting; 11248 int waiting;
11249 }; 11249 };
11250 11250
11251 static void _dw_handle_sem(int *tmpsock) 11251 static void _dw_handle_sem(int *tmpsock)
11252 { 11252 {
11253 fd_set rd; 11253 fd_set rd;
11254 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo)); 11254 struct _dw_seminfo *array = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo));
11255 int listenfd = tmpsock[0]; 11255 int listenfd = tmpsock[0];
11256 int bytesread, connectcount = 1, maxfd, z, posted = 0; 11256 int bytesread, connectcount = 1, maxfd, z, posted = 0;
11257 char command; 11257 char command;
11258 sigset_t mask; 11258 sigset_t mask;
11259 11259
11295 return; 11295 return;
11296 } 11296 }
11297 11297
11298 if(FD_ISSET(listenfd, &rd)) 11298 if(FD_ISSET(listenfd, &rd))
11299 { 11299 {
11300 struct _seminfo *newarray; 11300 struct _dw_seminfo *newarray;
11301 int newfd = accept(listenfd, 0, 0); 11301 int newfd = accept(listenfd, 0, 0);
11302 11302
11303 if(newfd > -1) 11303 if(newfd > -1)
11304 { 11304 {
11305 /* Add new connections to the set */ 11305 /* Add new connections to the set */
11306 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1)); 11306 newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount+1));
11307 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount)); 11307 memcpy(newarray, array, sizeof(struct _dw_seminfo)*(connectcount));
11308 11308
11309 newarray[connectcount].fd = newfd; 11309 newarray[connectcount].fd = newfd;
11310 newarray[connectcount].waiting = 0; 11310 newarray[connectcount].waiting = 0;
11311 11311
11312 connectcount++; 11312 connectcount++;
11322 { 11322 {
11323 if(FD_ISSET(array[z].fd, &rd)) 11323 if(FD_ISSET(array[z].fd, &rd))
11324 { 11324 {
11325 if((bytesread = (int)read(array[z].fd, &command, 1)) < 1) 11325 if((bytesread = (int)read(array[z].fd, &command, 1)) < 1)
11326 { 11326 {
11327 struct _seminfo *newarray = NULL; 11327 struct _dw_seminfo *newarray = NULL;
11328 11328
11329 /* Remove this connection from the set */ 11329 /* Remove this connection from the set */
11330 if(connectcount > 1) 11330 if(connectcount > 1)
11331 { 11331 {
11332 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1)); 11332 newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount-1));
11333 if(!z) 11333 if(!z)
11334 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1)); 11334 memcpy(newarray, &array[1], sizeof(struct _dw_seminfo)*(connectcount-1));
11335 else 11335 else
11336 { 11336 {
11337 memcpy(newarray, array, sizeof(struct _seminfo)*z); 11337 memcpy(newarray, array, sizeof(struct _dw_seminfo)*z);
11338 if(z!=(connectcount-1)) 11338 if(z!=(connectcount-1))
11339 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1)); 11339 memcpy(&newarray[z], &array[z+1], sizeof(struct _dw_seminfo)*(connectcount-(z+1)));
11340 } 11340 }
11341 } 11341 }
11342 connectcount--; 11342 connectcount--;
11343 11343
11344 /* Replace old array with new one */ 11344 /* Replace old array with new one */