[erlang-patches] [PATCH 1/2] hipe_arm.c: fix compile warning
Mikael Pettersson
mikpe@REDACTED
Tue May 8 21:11:47 CEST 2012
When compiling otp_src_R15B01 on arm-linux-gnueabi with --enable-hipe
one gets:
hipe/hipe_arm.c: In function 'hipe_make_native_stub':
hipe/hipe_arm.c:273:19: warning: 'tramp_callemu' may be used uninitialized in this function
The local helper function alloc_stub() has both a normal return value
and output parameter (via a pointer). Due to a missing error check
on the return value, gcc sees a control flow path where the output
parameter may be used uninitialized. In this case gcc's analysis is
correct.
Fixed by adding the missing error check (an abort(), which looks
primitive but that's the de facto error handling in this area
across HiPE's targets; at some point we should fix that globally).
Tested with gcc-4.5.3 on armv5tel-linux-gnueabi.
Thanks to Kostis for notifiying me about this warning.
Signed-off-by: Mikael Pettersson <mikpe@REDACTED>
---
--- otp_src_R15B01/erts/emulator/hipe/hipe_arm.c.~1~ 2012-04-01 20:15:00.000000000 +0200
+++ otp_src_R15B01/erts/emulator/hipe/hipe_arm.c 2012-05-08 19:15:12.000000000 +0200
@@ -296,6 +296,8 @@ void *hipe_make_native_stub(void *beamAd
#if defined(__arm__)
code = alloc_stub(4, &tramp_callemu);
+ if (!code)
+ abort();
callemu_offset = ((int)&nbif_callemu - ((int)&code[2] + 8)) >> 2;
if (!(callemu_offset >= -0x00800000 && callemu_offset <= 0x007FFFFF)) {
callemu_offset = ((int)tramp_callemu - ((int)&code[2] + 8)) >> 2;
More information about the erlang-patches
mailing list