diff options
author | Jesper Louis Andersen <[email protected]> | 2015-05-12 12:44:14 +0200 |
---|---|---|
committer | Jesper Louis Andersen <[email protected]> | 2015-05-12 23:28:07 +0200 |
commit | cce681109c05ffa8cb88e83eb70ccf73c13d0c75 (patch) | |
tree | 77ed0ce40d43b9498b2038bbabec7ec4a4cb5339 /erts | |
parent | ce96ab6d64768cd6536011ccdecc08191c238220 (diff) | |
download | otp-cce681109c05ffa8cb88e83eb70ccf73c13d0c75.tar.gz otp-cce681109c05ffa8cb88e83eb70ccf73c13d0c75.tar.bz2 otp-cce681109c05ffa8cb88e83eb70ccf73c13d0c75.zip |
Correct usage of sizeof() for pointer types
Given some pointer *x, calling sizeof(x) will give us
the size of the pointer (4/8 bytes) not the size fo the
underlying dereferenced structure. Use coccinelle to
search for these occurrences in the source code, and
correct them one by one. In the case of
erl_node_tables.c, the erts_snprintf() calls used a
much too small buffer.
- run_erl.c: Use the size of the signal type, not
its pointer.
- erl_node_tables.c: Use the size of the _BUFFER in
erts_snprintf() to make sure we can use the full space.
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/erl_node_tables.c | 4 | ||||
-rw-r--r-- | erts/etc/ose/run_erl.c | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/erts/emulator/beam/erl_node_tables.c b/erts/emulator/beam/erl_node_tables.c index c6d136f951..bc775cd663 100644 --- a/erts/emulator/beam/erl_node_tables.c +++ b/erts/emulator/beam/erl_node_tables.c @@ -705,7 +705,7 @@ erts_set_this_node(Eterm sysname, Uint creation) erts_this_node->sysname = sysname; erts_this_node->creation = creation; erts_this_node_sysname = erts_this_node_sysname_BUFFER; - erts_snprintf(erts_this_node_sysname, sizeof(erts_this_node_sysname), + erts_snprintf(erts_this_node_sysname, sizeof(erts_this_node_sysname_BUFFER), "%T", sysname); (void) hash_put(&erts_node_table, (void *) erts_this_node); @@ -794,7 +794,7 @@ void erts_init_node_tables(void) erts_this_node->creation = 0; erts_this_node->dist_entry = erts_this_dist_entry; erts_this_node_sysname = erts_this_node_sysname_BUFFER; - erts_snprintf(erts_this_node_sysname, sizeof(erts_this_node_sysname), + erts_snprintf(erts_this_node_sysname, sizeof(erts_this_node_sysname_BUFFER), "%T", erts_this_node->sysname); (void) hash_put(&erts_node_table, (void *) erts_this_node); diff --git a/erts/etc/ose/run_erl.c b/erts/etc/ose/run_erl.c index 8bc49a485e..a6499f2bf3 100644 --- a/erts/etc/ose/run_erl.c +++ b/erts/etc/ose/run_erl.c @@ -615,7 +615,7 @@ int run_erl(int argc,char **argv) { returns */ PROCESS main_pid; hunt_in_block("run_erl","main",&main_pid); - sig = alloc(sizeof(sig),ERTS_SIGNAL_RUN_ERL_DAEMON); + sig = alloc(sizeof(*sig),ERTS_SIGNAL_RUN_ERL_DAEMON); send(&sig,main_pid); sig = receive(sigsel); pid = sender(&sig); |