[ https://issues.apache.org/jira/browse/MAPREDUCE-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12790615#action_12790615 ]
Eli Collins commented on MAPREDUCE-1166: ---------------------------------------- Hey Allen, Does this code not compile on solaris? Perhaps the build is just not passing -xc99. >From quickly looking at the code it looks like len will never be greater than >8 in which case an appropriate assert/check could be added and the allocation >could read: {code} uint8_t barr[sizeof(int64_t)]; {code} The disadvantages of alloca (http://www.gnu.org/s/libc/manual/html_node/Disadvantages-of-Alloca.html) don't apply here but it doesn't seem necessary either. Thanks, Eli > SerialUtils.cc: dynamic allocation of arrays based on runtime variable is not > portable > -------------------------------------------------------------------------------------- > > Key: MAPREDUCE-1166 > URL: https://issues.apache.org/jira/browse/MAPREDUCE-1166 > Project: Hadoop Map/Reduce > Issue Type: Bug > Reporter: Allen Wittenauer > Assignee: Allen Wittenauer > Attachments: MAPREREDUCE-1166.patch > > > In SerialUtils.cc, the following code appears: > int len; > if (b < -120) { > negative = true; > len = -120 - b; > } else { > negative = false; > len = -112 - b; > } > uint8_t barr[len]; > as far as I'm aware, this is not legal in ANSI C and will be rejected by ANSI > compliant compilers. Instead, this should be malloc()'d based upon the size > of len and free()'d later. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.