[llvm] r224114 - Silence gcc 4.9.1 warning 'xyz' is used uninitialized in this function.

David Blaikie dblaikie at gmail.com
Fri Dec 12 11:24:47 PST 2014


Honestly this isn't really my area - was just throwing the question out
there for you/others who might own/care about this code to see if this was
the right direction.

Not sure what these error paths actually represent (are these the failure
cases one would hit if one simply truncated a bitcode file? If so, we could
actually have test coverage for that easily enough)? Or are there other
checks that catch that earlier?

On Fri, Dec 12, 2014 at 11:15 AM, Yaron Keren <yaron.keren at gmail.com> wrote:
>
> I have propagated the error codes into ChildTarget.cpp.
> What do you think of the attached patch?
>
>
>
>
> 2014-12-12 19:56 GMT+02:00 David Blaikie <dblaikie at gmail.com>:
>>
>>
>>
>> On Fri, Dec 12, 2014 at 3:07 AM, Yaron Keren <yaron.keren at gmail.com>
>> wrote:
>>
>>> Author: yrnkrn
>>> Date: Fri Dec 12 05:07:51 2014
>>> New Revision: 224114
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=224114&view=rev
>>> Log:
>>> Silence gcc 4.9.1 warning 'xyz' is used uninitialized in this function.
>>>
>>> In release builds this is actually possible as without asserts there is
>>> no testing of the actual read bytes and the variables could be partially
>>> uninitialized.
>>>
>>
>> Should we instead be actually testing the number of bytes read in a
>> non-asserts build?
>>
>>
>>>
>>>
>>> Modified:
>>>     llvm/trunk/tools/lli/ChildTarget/ChildTarget.cpp
>>>
>>> Modified: llvm/trunk/tools/lli/ChildTarget/ChildTarget.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/ChildTarget/ChildTarget.cpp?rev=224114&r1=224113&r2=224114&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/tools/lli/ChildTarget/ChildTarget.cpp (original)
>>> +++ llvm/trunk/tools/lli/ChildTarget/ChildTarget.cpp Fri Dec 12 05:07:51
>>> 2014
>>> @@ -97,15 +97,15 @@ void LLIChildTarget::handleMessage(LLIMe
>>>  // Incoming message handlers
>>>  void LLIChildTarget::handleAllocateSpace() {
>>>    // Read and verify the message data size.
>>> -  uint32_t DataSize;
>>> +  uint32_t DataSize = 0;
>>>    int rc = ReadBytes(&DataSize, 4);
>>>    (void)rc;
>>>    assert(rc == 4);
>>>    assert(DataSize == 8);
>>>
>>>    // Read the message arguments.
>>> -  uint32_t Alignment;
>>> -  uint32_t AllocSize;
>>> +  uint32_t Alignment = 0;
>>> +  uint32_t AllocSize = 0;
>>>    rc = ReadBytes(&Alignment, 4);
>>>    assert(rc == 4);
>>>    rc = ReadBytes(&AllocSize, 4);
>>> @@ -121,13 +121,13 @@ void LLIChildTarget::handleAllocateSpace
>>>
>>>  void LLIChildTarget::handleLoadSection(bool IsCode) {
>>>    // Read the message data size.
>>> -  uint32_t DataSize;
>>> +  uint32_t DataSize = 0;
>>>    int rc = ReadBytes(&DataSize, 4);
>>>    (void)rc;
>>>    assert(rc == 4);
>>>
>>>    // Read the target load address.
>>> -  uint64_t Addr;
>>> +  uint64_t Addr = 0;
>>>    rc = ReadBytes(&Addr, 8);
>>>    assert(rc == 8);
>>>    size_t BufferSize = DataSize - 8;
>>> @@ -150,14 +150,14 @@ void LLIChildTarget::handleLoadSection(b
>>>
>>>  void LLIChildTarget::handleExecute() {
>>>    // Read the message data size.
>>> -  uint32_t DataSize;
>>> +  uint32_t DataSize = 0;
>>>    int rc = ReadBytes(&DataSize, 4);
>>>    (void)rc;
>>>    assert(rc == 4);
>>>    assert(DataSize == 8);
>>>
>>>    // Read the target address.
>>> -  uint64_t Addr;
>>> +  uint64_t Addr = 0;
>>>    rc = ReadBytes(&Addr, 8);
>>>    assert(rc == 8);
>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141212/1070b318/attachment.html>


More information about the llvm-commits mailing list