All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <ddaney.cavm@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>, Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Subject: Re: gcc warning in my trace_benchmark() code
Date: Thu, 05 Jun 2014 10:12:16 -0700	[thread overview]
Message-ID: <5390A4F0.3000601@gmail.com> (raw)
In-Reply-To: <20140605121204.18ee5f2d@gandalf.local.home>

On 06/05/2014 09:12 AM, Steven Rostedt wrote:
> I'm going through some of the warnings that Fengguang Wu's test bot has
> discovered, and one of them is from a MIPS allmodconfig build.
>
> https://lists.01.org/pipermail/kbuild-all/2014-May/004751.html
>
>     kernel/trace/trace_benchmark.c: In function 'trace_do_benchmark':
>>> kernel/trace/trace_benchmark.c:84:3: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>>> kernel/trace/trace_benchmark.c:85:3: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>     kernel/trace/trace_benchmark.c:38:6: warning: unused variable 'seedsq' [-Wunused-variable]
>
> vim +84 kernel/trace/trace_benchmark.c
>
>      78		if (bm_cnt > 1) {
>      79			/*
>      80			 * Apply Welford's method to calculate standard deviation:
>      81			 * s^2 = 1 / (n * (n-1)) * (n * \Sum (x_i)^2 - (\Sum x_i)^2)
>      82			 */
>      83			stddev = (u64)bm_cnt * bm_totalsq - bm_total * bm_total;
>    > 84			do_div(stddev, bm_cnt);
>    > 85			do_div(stddev, bm_cnt - 1);
>      86		} else
>      87			stddev = 0;
>      88	
>
>
>
> Is there something special with do_div in mips that I should be aware
> of?

Yes.  MIPS is using the implementation in asm-generic/div64.h,  which 
per the comments in that file has a useless pointer compare to find just 
this type of issue.


Ralf:  As a side note, while looking at arch/mips/include/asm/div64.h, I 
saw that the implementation of __div64_32 in that file will be unused, 
and is also completely broken due to the first parameter never being used.

David Daney

  reply	other threads:[~2014-06-05 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 16:12 gcc warning in my trace_benchmark() code Steven Rostedt
2014-06-05 17:12 ` David Daney [this message]
2014-06-05 17:35   ` Steven Rostedt
2014-06-05 18:44     ` David Daney
2014-06-05 18:53       ` Steven Rostedt
2014-06-05 21:56         ` David Daney
2014-06-05 22:17           ` Steven Rostedt
2014-06-06  7:16           ` Geert Uytterhoeven
2014-06-05 21:07   ` Ralf Baechle
2014-06-05 21:38     ` Maciej W. Rozycki

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=5390A4F0.3000601@gmail.com \
    --to=ddaney.cavm@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.