lkml.org 
[lkml]   [2011]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] perf tool: fix endianness handling of u32 data in samples
Em Fri, Sep 02, 2011 at 10:03:46AM -0600, David Ahern escreveu:
> if (type & PERF_SAMPLE_RAW) {
> - u32 *p = (u32 *)array;
> + u.val64 = *array;
> + if (swapped) {
> + static bool show_warn = true;
> +
> + /* 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]);
> +
> + if (show_warn) {
> + pr_warning("Endianness of raw data not corrected!\n");
> + show_warn = false;
> + }
> + }

Can you use WARN_ONCE? Would become:

if (WARN_ONCE(swapped, "Endianness of raw data not corrected!\n")) {
/* 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]);
}

We have that and its the usual idiom in the kernel proper :-)

See tools/perf/util/include/asm/bug.h and net/can/af_can.c can_rcv for
an example.

Thanks,

- Arnaldo


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