diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-09-22 12:46:02 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-09-22 12:46:02 -0400 |
commit | be6bf3ca538405037fb04ee2584ea57435c9770b (patch) | |
tree | d8ebe4b0741250e8c6e8725cc7030ca73df075a0 | |
parent | e9c900fae35e4e4730469e189ff17bf30518346a (diff) |
zero out rt_task parameters before setting them
This avoids passing random stack contents to the kernel
if the structure gained some fields due to plugin development.
(Also, fix up some white space issues while we are at it.)
-rw-r--r-- | src/litmus.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/litmus.c b/src/litmus.c index f71f337..d3cc6bb 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -10,14 +10,14 @@ | |||
10 | #include "litmus.h" | 10 | #include "litmus.h" |
11 | #include "internal.h" | 11 | #include "internal.h" |
12 | 12 | ||
13 | void show_rt_param(struct rt_task* tp) | 13 | void show_rt_param(struct rt_task* tp) |
14 | { | 14 | { |
15 | printf("rt params:\n\t" | 15 | printf("rt params:\n\t" |
16 | "exec_cost:\t%llu\n\tperiod:\t\t%llu\n\tcpu:\t%d\n", | 16 | "exec_cost:\t%llu\n\tperiod:\t\t%llu\n\tcpu:\t%d\n", |
17 | tp->exec_cost, tp->period, tp->cpu); | 17 | tp->exec_cost, tp->period, tp->cpu); |
18 | } | 18 | } |
19 | 19 | ||
20 | task_class_t str2class(const char* str) | 20 | task_class_t str2class(const char* str) |
21 | { | 21 | { |
22 | if (!strcmp(str, "hrt")) | 22 | if (!strcmp(str, "hrt")) |
23 | return RT_CLASS_HARD; | 23 | return RT_CLASS_HARD; |
@@ -55,6 +55,12 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | |||
55 | { | 55 | { |
56 | struct rt_task param; | 56 | struct rt_task param; |
57 | int ret; | 57 | int ret; |
58 | |||
59 | /* Zero out first --- this is helpful when we add plugin-specific | ||
60 | * parameters during development. | ||
61 | */ | ||
62 | memset(¶m, 0, sizeof(param)); | ||
63 | |||
58 | param.exec_cost = e; | 64 | param.exec_cost = e; |
59 | param.period = p; | 65 | param.period = p; |
60 | param.cpu = cpu; | 66 | param.cpu = cpu; |
@@ -62,7 +68,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | |||
62 | param.phase = phase; | 68 | param.phase = phase; |
63 | param.budget_policy = budget_policy; | 69 | param.budget_policy = budget_policy; |
64 | 70 | ||
65 | if (set_cpu_set) { | 71 | if (set_cpu_set) { |
66 | ret = be_migrate_to(cpu); | 72 | ret = be_migrate_to(cpu); |
67 | check("migrate to cpu"); | 73 | check("migrate to cpu"); |
68 | } | 74 | } |