linux-mips
[Top] [All Lists]

Re: gcc warning in my trace_benchmark() code

To: Steven Rostedt <rostedt@goodmis.org>, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: gcc warning in my trace_benchmark() code
From: David Daney <ddaney.cavm@gmail.com>
Date: Thu, 05 Jun 2014 10:12:16 -0700
Cc: linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=okWuRjB9FQx/Z6obFi7Wq0io4BTu16WKGLi0Qc1kJcs=; b=kjm4HeaC1oK3s1u/s4TTcPh0PhJMekpts9FXbWxLzCJ7v5G8Csva2teV4VL7Ul/6qC DzAPWXKTHUU2cmQkBtc41RO7G/o57HwhR79W5MjQYjXtWbvOw3TMDn+flJMm6BAtZ0iS oi0bK1AK1wIrqivPvvZdq6ll/TxFOvpLwljto7eNDHMunXBwM1scHyaPRI6PUDdtIj7P ESpi8OF0grfVOelfGV3PG7pSvuSLzkIfByUVZTuc4eZtdW3xvU/Ncooo80HfD4oynyN2 XpD/ZTRpCETlKou6oM2rKm3DTOZH4rkEFOHN60fBFiUp0uV/g5fycI6EOJAPbnz2XAR7 OJVg==
In-reply-to: <20140605121204.18ee5f2d@gandalf.local.home>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20140605121204.18ee5f2d@gandalf.local.home>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
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



<Prev in Thread] Current Thread [Next in Thread>