mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Måns Rullgård" <mans@mansr.com>
To: "Geyslan Gregório Bem" <geyslan@gmail.com>
Cc: a.p.zijlstra@chello.nl, paulus@samba.org,
	Ingo Molnar <mingo@redhat.com>,
	acme@ghostprotocols.net, kernel-br <kernel-br@googlegroups.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Coverity 1128445 - Reliance on integer endianness
Date: Tue, 12 Nov 2013 14:36:24 +0000	[thread overview]
Message-ID: <yw1xd2m5vg9j.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <CAGG-pUQrN6D_iSsWVptjQSA4B_oGn5NhbhBp+aLT0GJCFSmYRA@mail.gmail.com> ("Geyslan =?iso-8859-1?Q?Greg=F3rio?= Bem"'s message of "Tue, 12 Nov 2013 12:19:13 -0200")

Geyslan Gregório Bem <geyslan@gmail.com> writes:

> Hi,
>
> Coverity detected in 'arch/x86/kernel/cpu/perf_event_intel_uncore.c' a
> possible reliance on integer endianness. Is that a positive one?

No, x86 is always little endian.

> static u64 ivt_uncore_irp_read_counter(struct intel_uncore_box *box,
> struct perf_event *event)
> 1369{
> 1370        struct pci_dev *pdev = box->pci_dev;
> 1371        struct hw_perf_event *hwc = &event->hw;
> 1372        u64 count = 0;
> 1373
>
> CID 1128445 (#1 of 1): Reliance on integer endianness
> (INCOMPATIBLE_CAST)incompatible_cast: Pointer "&count" points to an
> object whose effective type is "unsigned long long" (64 bits,
> unsigned) but is dereferenced as a narrower "unsigned int" (32 bits,
> unsigned). This may lead to unexpected results depending on machine
> endianness.[show details]
>
> 1374        pci_read_config_dword(pdev, ivt_uncore_irp_ctrs[hwc->idx],
> (u32 *)&count);
> 1375        pci_read_config_dword(pdev, ivt_uncore_irp_ctrs[hwc->idx]
> + 4, (u32 *)&count + 1);
> 1376
> 1377        return count;
> 1378}

This looks intentional and correct apart from possible strict aliasing
issues.

-- 
Måns Rullgård
mans@mansr.com

  parent reply	other threads:[~2013-11-12 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 14:19 Geyslan Gregório Bem
2013-11-12 14:30 ` Peter Zijlstra
2013-11-12 14:33 ` Peter Zijlstra
2013-11-12 14:39   ` Geyslan Gregório Bem
2013-11-12 14:36 ` Måns Rullgård [this message]
2013-11-12 14:38   ` Geyslan Gregório Bem

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yw1xd2m5vg9j.fsf@unicorn.mansr.com \
    --to=mans@mansr.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=geyslan@gmail.com \
    --cc=kernel-br@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®