Obsolete
/
libipc-old
Archived
3
0
Fork 0

corrections mémoire

more_to_read
Philippe PITTOLI 2016-12-19 22:49:26 +01:00
parent af3c9395ff
commit b8c367d6c4
9 changed files with 34 additions and 12 deletions

View File

@ -16,7 +16,7 @@ $(EXEC): $(OBJECTS) $(CFILES)
$(CC) -c $(CFLAGS) $< -o $@
$(TESTS):
valgrind --show-leak-kinds=all --leak-check=full -v --track-origins=yes ./$(basename $@)
valgrind --show-leak-kinds=all --leak-check=full -v --track-origins=yes ./$(basename $@).bin
clean:
@-rm $(OBJECTS)

View File

@ -13,11 +13,10 @@
int main (int argc, char * argv[])
{
argc = argc;
argv = argv;
int fd;
int fd = 0;
size_t msize = BUFSIZ;
char *buf = NULL;
@ -55,5 +54,8 @@ int main (int argc, char * argv[])
return EXIT_FAILURE;
}
if (buf != NULL)
free (buf);
return EXIT_SUCCESS;
}

View File

@ -12,12 +12,11 @@
int main (int argc, char * argv[])
{
argc = argc;
argv = argv;
int fd;
int pfd;
int fd = 0;
int pfd = 0;
size_t msize = BUFSIZ;
char *buf = NULL;
@ -63,5 +62,8 @@ int main (int argc, char * argv[])
return EXIT_FAILURE;
}
if (buf != NULL)
free (buf);
return EXIT_SUCCESS;
}

View File

@ -53,5 +53,8 @@ int main (int argc, char *argv[], char *env[])
return EXIT_FAILURE;
}
if (buf != NULL)
free (buf);
return EXIT_SUCCESS;
}

View File

@ -30,6 +30,7 @@ int main (int argc, char *argv[], char *env[])
srv.version = 0;
struct process p;
memset (&p, 0, sizeof (struct process));
// init service
if (srv_init (argc, argv, env, &srv, SERVICE_NAME) < 0) {
@ -64,5 +65,8 @@ int main (int argc, char *argv[], char *env[])
return EXIT_FAILURE;
}
if (buf != NULL)
free (buf);
return EXIT_SUCCESS;
}

View File

@ -16,7 +16,7 @@ int main (int argc, char * argv[])
argc = argc;
argv = argv;
int fd;
int fd = 0;
size_t msize = BUFSIZ;
char *buf = NULL;
@ -48,5 +48,8 @@ int main (int argc, char * argv[])
return EXIT_FAILURE;
}
if (buf != NULL)
free (buf);
return EXIT_SUCCESS;
}

View File

@ -16,8 +16,8 @@ int main (int argc, char * argv[])
argc = argc;
argv = argv;
int fd;
int pfd;
int fd = 0;
int pfd = 0;
size_t msize = BUFSIZ;
char *buf = NULL;
@ -67,5 +67,8 @@ int main (int argc, char * argv[])
return EXIT_FAILURE;
}
if (buf != NULL)
free (buf);
return EXIT_SUCCESS;
}

View File

@ -47,7 +47,7 @@ int srv_init (int argc, char **argv, char **env
int srv_accept (struct service *srv, struct process *p)
{
usock_accept (srv->service_fd, &p->proc_fd);
char *buf;
char *buf = NULL;
size_t msgsize = BUFSIZ;
srv_read (p, &buf, &msgsize);
@ -57,6 +57,8 @@ int srv_accept (struct service *srv, struct process *p)
srv_write (p, buf, msgsize);
free (buf);
return 0;
}
@ -104,13 +106,14 @@ int app_connection (int argc, char **argv, char **env
// TODO: connection algorithm
// send connection string and receive acknowledgement
char send_buffer [BUFSIZ];
memset (send_buffer, 0, BUFSIZ);
if (msg_format_con (send_buffer, connectionstr, &msize) < 0) {
handle_err ("app_connection", "msg_format_con");
return -1;
}
app_write (srv, send_buffer, msize);
char *buffer;
char *buffer = NULL;
size_t read_msg_size = BUFSIZ;
app_read (srv, &buffer, &read_msg_size);
@ -118,6 +121,8 @@ int app_connection (int argc, char **argv, char **env
assert (buffer[0] == MSG_TYPE_ACK);
assert (read_msg_size == 3);
free (buffer);
return 0;
}

View File

@ -164,7 +164,7 @@ int usock_accept (int fd, int *pfd)
struct sockaddr_un peer_addr;
memset (&peer_addr, 0, sizeof (struct sockaddr_un));
socklen_t peer_addr_size;
socklen_t peer_addr_size = 0;
*pfd = accept (fd, (struct sockaddr *) &peer_addr, &peer_addr_size);
if (*pfd < 0) {