From ce7351458b8220a90f399e9feeb60b0fda072e3a Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Tue, 9 Oct 2018 13:16:40 +0200
Subject: [PATCH] useless argc and argv references removed
---
core/communication.c | 16 +++++++++-------
core/communication.h | 4 ++--
pong/app/pong.c | 19 +++++++++++--------
pong/app/pongd.c | 5 ++++-
4 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/core/communication.c b/core/communication.c
index 20ed953..ed0cd01 100644
--- a/core/communication.c
+++ b/core/communication.c
@@ -14,20 +14,18 @@ void service_path (char *path, const char *sname, int index, int version)
snprintf (path, PATH_MAX, "%s/%s-%d-%d", TMPDIR, sname, index, version);
}
-int ipc_server_init (int argc, char **argv, char **env
+int ipc_server_init (char **env
, struct ipc_service *srv, const char *sname)
{
if (srv == NULL)
return IPC_ERROR_WRONG_PARAMETERS;
// TODO
- // use the argc, argv and env parameters
+ // use env parameters
// it will be useful to change some parameters transparently
// ex: to get resources from other machines, choosing the
// remote with environment variables
- argc = argc;
- argv = argv;
env = env;
// gets the service path
@@ -80,11 +78,15 @@ int ipc_server_write (const struct ipc_client *p, const struct ipc_message *m)
return ipc_message_write (p->proc_fd, m);
}
-int ipc_application_connection (int argc, char **argv, char **env
+int ipc_application_connection (char **env
, struct ipc_service *srv, const char *sname)
{
- argc = argc;
- argv = argv;
+ // TODO
+ // use env parameters
+ // it will be useful to change some parameters transparently
+ // ex: to get resources from other machines, choosing the
+ // remote with environment variables
+
env = env;
assert (srv != NULL);
diff --git a/core/communication.h b/core/communication.h
index 77447a2..ee09d8f 100644
--- a/core/communication.h
+++ b/core/communication.h
@@ -19,7 +19,7 @@
// srv->version and srv->index must be already set
// init unix socket + fill srv->spath
-int ipc_server_init (int argc, char **argv, char **env
+int ipc_server_init (char **env
, struct ipc_service *srv, const char *sname);
int ipc_server_close (struct ipc_service *srv);
int ipc_server_close_client (struct ipc_client *p);
@@ -37,7 +37,7 @@ int ipc_server_select (struct ipc_clients * clients, struct ipc_service *srv
// Initialize connection with unix socket
// send the connection string to $TMP/
// fill srv->spath && srv->service_fd
-int ipc_application_connection (int argc, char **argv, char **env
+int ipc_application_connection (char **env
, struct ipc_service *, const char *);
int ipc_application_close (struct ipc_service *);
diff --git a/pong/app/pong.c b/pong/app/pong.c
index 3ec134c..d782551 100644
--- a/pong/app/pong.c
+++ b/pong/app/pong.c
@@ -10,7 +10,7 @@
#define MSG "coucou"
#define SERVICE_NAME "pongd"
-void non_interactive (int argc, char *argv[], char *env[])
+void non_interactive (char *env[])
{
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
@@ -22,8 +22,8 @@ void non_interactive (int argc, char *argv[], char *env[])
srv.version = 0;
// init service
- if (ipc_application_connection (argc, argv, env, &srv, SERVICE_NAME) < 0) {
- handle_err("main", "server_init < 0");
+ if (ipc_application_connection (env, &srv, SERVICE_NAME) < 0) {
+ handle_err("main", "ipc_application_connection < 0");
exit (EXIT_FAILURE);
}
@@ -51,7 +51,7 @@ void non_interactive (int argc, char *argv[], char *env[])
}
}
-void interactive (int argc, char *argv[], char *env[])
+void interactive (char *env[])
{
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
@@ -69,8 +69,8 @@ void interactive (int argc, char *argv[], char *env[])
srv.version = 0;
// init service
- if (ipc_application_connection (argc, argv, env, &srv, SERVICE_NAME) < 0) {
- handle_err ("main", "server_init < 0");
+ if (ipc_application_connection (env, &srv, SERVICE_NAME) < 0) {
+ handle_err ("main", "ipc_application_connection < 0");
exit (EXIT_FAILURE);
}
@@ -123,10 +123,13 @@ void interactive (int argc, char *argv[], char *env[])
int main (int argc, char *argv[], char *env[])
{
+ argc = argc; // warnings
+ argv = argv; // warnings
+
if (argc == 1)
- non_interactive (argc, argv, env);
+ non_interactive (env);
else
- interactive (argc, argv, env);
+ interactive (env);
return EXIT_SUCCESS;
}
diff --git a/pong/app/pongd.c b/pong/app/pongd.c
index 9262800..613ea99 100644
--- a/pong/app/pongd.c
+++ b/pong/app/pongd.c
@@ -151,6 +151,9 @@ void main_loop ()
int main(int argc, char * argv[], char **env)
{
+ argc = argc; // warnings
+ argv = argv; // warnings
+
srv = malloc (sizeof (struct ipc_service));
if (srv == NULL) {
exit (1);
@@ -161,7 +164,7 @@ int main(int argc, char * argv[], char **env)
// unlink("/tmp/ipc/pongd-0-0");
- if (ipc_server_init (argc, argv, env, srv, PONGD_SERVICE_NAME) < 0) {
+ if (ipc_server_init (env, srv, PONGD_SERVICE_NAME) < 0) {
handle_error("server_init < 0");
return EXIT_FAILURE;
}