lkml.org 
[lkml]   [2011]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tool: fix endianness handling of u32 data in samples


On 09/02/2011 02:02 PM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Sep 02, 2011 at 01:41:51PM -0600, David Ahern escreveu:
>> @@ -423,18 +449,25 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
>> }
>>
>> if (type & PERF_SAMPLE_RAW) {
>> - u32 *p = (u32 *)array;
>> + u.val64 = *array;
>> + if (swapped) {
>> + /* undo swap of u64, then swap on individual u32s */
>> + u.val64 = bswap_64(u.val64);
>> + u.val32[0] = bswap_32(u.val32[0]);
>> + u.val32[1] = bswap_32(u.val32[1]);
>> +
>> + WARN_ONCE(swapped, "Endianness of raw data not corrected!\n");
>> + }
>
> That works too, but then we'll be always testing swapped two times :-)
>
> - Arnaldo


I did not see a WARN_ONCE with no 'condition' variable, so I went with
the redundant test. I guess swapped really could be changed to '1' --
like an example I saw in the acpi code.

David


\
 
 \ /
  Last update: 2011-09-02 22:09    [W:2.272 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site