summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/lib/ctors.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-06-24 17:10:46 +0200
committerHarald Welte <laforge@gnumonks.org>2010-06-24 17:10:46 +0200
commit8c1f25e6276058b4ae96b37138b2ad1f91c1bb7e (patch)
treebd1a74b540e0c5494036319c01c11f3d7aeec0dc /src/target/firmware/lib/ctors.c
parent806da1525b17070ad1f4a10bdfdee4e4c041f21c (diff)
[firmware] fix code that iterates over constructors
the first element after __CTORS_LIST__ contains the number of constructor callbacks in the following array, so we have to skip it.
Diffstat (limited to 'src/target/firmware/lib/ctors.c')
-rw-r--r--src/target/firmware/lib/ctors.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/target/firmware/lib/ctors.c b/src/target/firmware/lib/ctors.c
index 6136a884..982169df 100644
--- a/src/target/firmware/lib/ctors.c
+++ b/src/target/firmware/lib/ctors.c
@@ -1,11 +1,15 @@
/* iterate over list of constructor functions and call each element */
-void do_global_ctors(const char *ctors_start, const char *ctors_end)
+void do_global_ctors(const char *_ctors_start, const char *ctors_end)
{
typedef void (*func_ptr)(void);
- func_ptr *func;
+ func_ptr *func, *ctors_start = (func_ptr *) _ctors_start;
- for (func = (func_ptr *) ctors_start;
+ /* skip the first entry, as it contains the number of
+ * constructors which we don't use */
+ ctors_start++;
+
+ for (func = ctors_start;
*func && (func != (func_ptr *) ctors_end); func++)
(*func)();
}