[rtems-libbsd commit] wpa_supplicant: Move forking command into own file.
Sebastian Huber
sebh at rtems.org
Fri Nov 10 13:22:23 UTC 2017
Module: rtems-libbsd
Branch: master
Commit: ee0c369cdd434da18e30c486a586f14abf467b35
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=ee0c369cdd434da18e30c486a586f14abf467b35
Author: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
Date: Thu Nov 2 14:08:10 2017 +0100
wpa_supplicant: Move forking command into own file.
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 23092a6..40950d2 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 046b611..4af789c 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",
More information about the vc
mailing list