You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/11/20 13:56:50 UTC

[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a diff in pull request #1432: netutils/iperf: add support of multi-instance

pkarashchenko commented on code in PR #1432:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1432#discussion_r1027294689


##########
netutils/iperf/iperf.c:
##########
@@ -740,54 +744,58 @@ static uint32_t iperf_get_buffer_len(void)
  *
  ****************************************************************************/
 
-int iperf_start(struct iperf_cfg_t *cfg)
+int iperf_start(FAR struct iperf_cfg_t *cfg)
 {
-  int ret;
-  void *retval;
+  struct iperf_ctrl_t ctrl;
   struct sched_param param;
-  pthread_t thread;
   pthread_attr_t attr;
+  pthread_t thread;
+  FAR void *retval;
+  int ret;
 
   if (!cfg)
     {
       return -1;
     }
 
-  if (s_iperf_is_running)
-    {
-      printf("iperf is running\n");
-      return -1;
-    }
-
-  memset(&s_iperf_ctrl, 0, sizeof(s_iperf_ctrl));
-  memcpy(&s_iperf_ctrl.cfg, cfg, sizeof(*cfg));
-  s_iperf_is_running = true;
-  s_iperf_ctrl.finish = false;
-  s_iperf_ctrl.buffer_len = iperf_get_buffer_len();
-  s_iperf_ctrl.buffer = (uint8_t *)malloc(s_iperf_ctrl.buffer_len);
-  if (!s_iperf_ctrl.buffer)
+  memset(&ctrl, 0, sizeof(ctrl));
+  memcpy(&ctrl.cfg, cfg, sizeof(*cfg));
+  ctrl.is_running = true;
+  ctrl.finish = false;
+  ctrl.buffer_len = iperf_get_buffer_len(&ctrl);
+  ctrl.buffer = (FAR uint8_t *)malloc(ctrl.buffer_len);
+  if (!ctrl.buffer)

Review Comment:
   ```suggestion
     if (ctrl.buffer == NULL)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org