[PATCH 05/10] wpa_supplicant: Move forking command into own file.

Christian Mauderer christian.mauderer at embedded-brains.de
Wed Nov 8 12:33:04 UTC 2017


From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>

The malloc wrapper must not be disabled. Therefore the command that uses
malloc without a wrapper has to live in another file.
---
 freebsd/contrib/wpa/wpa_supplicant/main.c          | 65 ----------------------
 .../rtems/rtems-bsd-shell-wpa_supplicant_fork.c    | 64 +++++++++++++++++++++
 2 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 23092a63e94..40950d2c769 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -22,8 +22,6 @@
 #ifdef __rtems__
 #include <assert.h>
 #include <sys/mutex.h>
-#define RTEMS_BSD_PROGRAM_NO_MALLOC_WRAP
-#define RTEMS_BSD_PROGRAM_NO_STRDUP_WRAP
 #include <machine/rtems-bsd-program.h>
 #endif /* __rtems__ */
 
@@ -176,69 +174,6 @@ int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
 
 	return exit_code;
 }
-
-struct myparams {
-	int argc;
-	char ** argv;
-};
-
-static void
-new_wpa_supplicant_task(rtems_task_argument arg)
-{
-	int argc;
-	char ** argv;
-	int i;
-
-	struct myparams *params = (struct myparams *)arg;
-	argc = params->argc;
-	argv = params->argv;
-
-	rtems_bsd_command_wpa_supplicant(argc, argv);
-
-	for (i = 0; i < params->argc; i++) {
-		free(params->argv[i]);
-	}
-	free(params->argv);
-	free(params);
-
-	rtems_task_delete( RTEMS_SELF );
-}
-
-int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
-{
-	rtems_status_code sc;
-	rtems_id id;
-	int i;
-
-	struct myparams *params = malloc(sizeof(struct myparams));
-	if (params == NULL)
-		return NULL;
-
-	params->argc = argc;
-	params->argv = malloc((argc + 1) * sizeof(argv[0]));
-	if (params->argv == NULL)
-		return NULL;
-
-	for (i = 0; i < argc; i++) {
-		params->argv[i] = strdup(argv[i]);
-		if (params->argv[i] == NULL)
-			return NULL;
-	}
-	params->argv[argc] = NULL;
-
-	sc = rtems_task_create(
-		rtems_build_name('W', 'P', 'A', 'S'),
-		RTEMS_MAXIMUM_PRIORITY - 1,
-		8 * RTEMS_MINIMUM_STACK_SIZE,
-		RTEMS_DEFAULT_MODES,
-		RTEMS_FLOATING_POINT,
-		&id
-	);
-	assert(sc == RTEMS_SUCCESSFUL);
-
-	sc = rtems_task_start(id, new_wpa_supplicant_task, params);
-	assert(sc == RTEMS_SUCCESSFUL);
-}
 #endif /* __rtems__ */
 
 int main(int argc, char *argv[])
diff --git a/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c b/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c
index 046b6112e46..4af789cc3e6 100644
--- a/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c
+++ b/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c
@@ -27,6 +27,70 @@
 
 #include <rtems/netcmds-config.h>
 #include <machine/rtems-bsd-commands.h>
+#include <assert.h>
+
+struct myparams {
+	int argc;
+	char ** argv;
+};
+
+static void
+new_wpa_supplicant_task(rtems_task_argument arg)
+{
+	int argc;
+	char ** argv;
+	int i;
+
+	struct myparams *params = (struct myparams *)arg;
+	argc = params->argc;
+	argv = params->argv;
+
+	rtems_bsd_command_wpa_supplicant(argc, argv);
+
+	for (i = 0; i < params->argc; i++) {
+		free(params->argv[i]);
+	}
+	free(params->argv);
+	free(params);
+
+	rtems_task_delete( RTEMS_SELF );
+}
+
+int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
+{
+	rtems_status_code sc;
+	rtems_id id;
+	int i;
+
+	struct myparams *params = malloc(sizeof(struct myparams));
+	if (params == NULL)
+		return NULL;
+
+	params->argc = argc;
+	params->argv = malloc((argc + 1) * sizeof(argv[0]));
+	if (params->argv == NULL)
+		return NULL;
+
+	for (i = 0; i < argc; i++) {
+		params->argv[i] = strdup(argv[i]);
+		if (params->argv[i] == NULL)
+			return NULL;
+	}
+	params->argv[argc] = NULL;
+
+	sc = rtems_task_create(
+		rtems_build_name('W', 'P', 'A', 'S'),
+		RTEMS_MAXIMUM_PRIORITY - 1,
+		8 * RTEMS_MINIMUM_STACK_SIZE,
+		RTEMS_DEFAULT_MODES,
+		RTEMS_FLOATING_POINT,
+		&id
+	);
+	assert(sc == RTEMS_SUCCESSFUL);
+
+	sc = rtems_task_start(id, new_wpa_supplicant_task, params);
+	assert(sc == RTEMS_SUCCESSFUL);
+}
 
 rtems_shell_cmd_t rtems_shell_WPA_SUPPLICANT_FORK_Command = {
   .name = "wpa_supplicant_fork",
-- 
2.12.3




More information about the devel mailing list