Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix warnings about clobbered variables in gras/rpc example.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 3 Nov 2011 15:29:49 +0000 (16:29 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 3 Nov 2011 15:59:10 +0000 (16:59 +0100)
examples/gras/rpc/rpc.c

index fe0c62b..10e84e0 100644 (file)
@@ -60,6 +60,20 @@ static void exception_catching(void)
  * Client code
  * **********************************************************************/
 
  * Client code
  * **********************************************************************/
 
+static void client_create_sockets(gras_socket_t *toserver,
+                                  gras_socket_t *toforwarder,
+                                  const char *srv_host, int srv_port,
+                                  const char *fwd_host, int fwd_port)
+{
+  TRY {
+    exception_catching();
+    *toserver = gras_socket_client(srv_host, srv_port);
+    *toforwarder = gras_socket_client(fwd_host, fwd_port);
+  }
+  CATCH_ANONYMOUS {
+    RETHROWF("Unable to connect to the server: %s");
+  }
+}
 
 int client(int argc, char *argv[])
 {
 
 int client(int argc, char *argv[])
 {
@@ -92,14 +106,8 @@ int client(int argc, char *argv[])
   gras_os_sleep(2);
 
   /* 4. Create a socket to speak to the server */
   gras_os_sleep(2);
 
   /* 4. Create a socket to speak to the server */
-  TRY {
-    exception_catching();
-    toserver = gras_socket_client(host, port);
-    toforwarder = gras_socket_client(argv[3], atoi(argv[4]));
-  }
-  CATCH_ANONYMOUS {
-    RETHROWF("Unable to connect to the server: %s");
-  }
+  client_create_sockets(&toserver, &toforwarder,
+                        host, port, argv[3], atoi(argv[4]));
   XBT_INFO("Connected to %s:%d.", host, port);
 
 
   XBT_INFO("Connected to %s:%d.", host, port);