Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1431795 > unrolled thread
| Started by | David Binderman <linuxdev.baldrick@gmail.com> |
|---|---|
| First post | 2016-06-27 10:10 +0200 |
| Last post | 2016-06-28 12:00 +0200 |
| Articles | 6 — 4 participants |
Back to article view | Back to linux.kernel
arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? David Binderman <linuxdev.baldrick@gmail.com> - 2016-06-27 10:10 +0200
Re: arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? Michael Ellerman <mpe@ellerman.id.au> - 2016-06-28 06:10 +0200
Re: arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? David Binderman <linuxdev.baldrick@gmail.com> - 2016-06-28 09:10 +0200
Re: arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? Michael Ellerman <mpe@ellerman.id.au> - 2016-06-28 09:20 +0200
Re: arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? Segher Boessenkool <segher@kernel.crashing.org> - 2016-06-28 11:00 +0200
Re: arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2016-06-28 12:00 +0200
| From | David Binderman <linuxdev.baldrick@gmail.com> |
|---|---|
| Date | 2016-06-27 10:10 +0200 |
| Subject | arch/powerpc/xmon/dis-asm.h: 2 * wrong specifiers ? |
| Message-ID | <rOzMe-62T-23@gated-at.bofh.it> |
Hello there,
linux-4.7-rc5/arch/powerpc/xmon/dis-asm.h:20]: (warning) %x in format
string (no. 1) requires 'unsigned int' but the argument type is
'unsigned long'.
[linux-4.7-rc5/arch/powerpc/xmon/dis-asm.h:26]: (warning) %x in format
string (no. 1) requires 'unsigned int' but the argument type is
'unsigned long'.
Source code is
static inline int print_insn_powerpc(unsigned long insn, unsigned long memaddr)
{
printf("%.8x", insn);
return 0;
}
static inline int print_insn_spu(unsigned long insn, unsigned long memaddr)
{
printf("%.8x", insn);
return 0;
}
Regards
David Binderman
[toc] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-06-28 06:10 +0200 |
| Message-ID | <rOSvv-1Jz-1@gated-at.bofh.it> |
| In reply to | #1431795 |
On Mon, 2016-06-27 at 09:04 +0100, David Binderman wrote:
> Hello there,
>
> linux-4.7-rc5/arch/powerpc/xmon/dis-asm.h:20]: (warning) %x in format
> string (no. 1) requires 'unsigned int' but the argument type is
> 'unsigned long'.
> [linux-4.7-rc5/arch/powerpc/xmon/dis-asm.h:26]: (warning) %x in format
> string (no. 1) requires 'unsigned int' but the argument type is
> 'unsigned long'.
What config / toolchain are you using? I've never seen these.
Oh, I see, with CONFIG_XMON_DISASSEMBLY=n.
> static inline int print_insn_powerpc(unsigned long insn, unsigned long memaddr)
> {
> printf("%.8x", insn);
> return 0;
> }
Send me a patch to cast insn to unsigned int?
cheers
[toc] | [prev] | [next] | [standalone]
| From | David Binderman <linuxdev.baldrick@gmail.com> |
|---|---|
| Date | 2016-06-28 09:10 +0200 |
| Message-ID | <rOVjI-3E5-19@gated-at.bofh.it> |
| In reply to | #1432445 |
Hello there,
On Tue, Jun 28, 2016 at 5:08 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> What config / toolchain are you using? I've never seen these.
A static analyser for C & C++ called cppcheck. Available from sourceforge.
I think you can also get a similar warning if you tweek the gcc compiler warning
flags. -Wformat=2 maybe.
>> static inline int print_insn_powerpc(unsigned long insn, unsigned long memaddr)
>> {
>> printf("%.8x", insn);
>> return 0;
>> }
>
> Send me a patch to cast insn to unsigned int?
I don't know the code, but given that insn is unsigned long and so can go
past 32 bits, using a cast to unsigned int might throw away the
possibly important
upper bits.
Regards
David Binderman
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-06-28 09:20 +0200 |
| Message-ID | <rOVto-3I0-11@gated-at.bofh.it> |
| In reply to | #1432555 |
On Tue, 2016-06-28 at 08:06 +0100, David Binderman wrote:
> On Tue, Jun 28, 2016 at 5:08 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> > What config / toolchain are you using? I've never seen these.
>
> A static analyser for C & C++ called cppcheck. Available from sourceforge.
>
> I think you can also get a similar warning if you tweek the gcc compiler warning
> flags. -Wformat=2 maybe.
Ah OK. I've heard of it.
> > > static inline int print_insn_powerpc(unsigned long insn, unsigned long memaddr)
> > > {
> > > printf("%.8x", insn);
> > > return 0;
> > > }
> >
> > Send me a patch to cast insn to unsigned int?
>
> I don't know the code, but given that insn is unsigned long and so can go
> past 32 bits, using a cast to unsigned int might throw away the
> possibly important upper bits.
powerpc instructions are always 32-bit.
We could change the signature for the function to take u32. Except it's the
fallback implementation for the real version which comes from binutils and we'd
prefer to keep that code the same as the binutils version.
cheers
[toc] | [prev] | [next] | [standalone]
| From | Segher Boessenkool <segher@kernel.crashing.org> |
|---|---|
| Date | 2016-06-28 11:00 +0200 |
| Message-ID | <rOX29-4Ab-3@gated-at.bofh.it> |
| In reply to | #1432555 |
On Tue, Jun 28, 2016 at 08:06:56AM +0100, David Binderman wrote: > I think you can also get a similar warning if you tweek the gcc compiler warning > flags. -Wformat=2 maybe. -Wformat=1 (which is enabled by -Wall) already warns for this. warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Wformat=] Segher
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2016-06-28 12:00 +0200 |
| Message-ID | <rOXYd-5cW-3@gated-at.bofh.it> |
| In reply to | #1432555 |
On Tue, 2016-06-28 at 08:06 +0100, David Binderman wrote: > > I don't know the code, but given that insn is unsigned long and so > can go > past 32 bits, using a cast to unsigned int might throw away the > possibly important > upper bits. our instructions are only ever 32-bits. That xmon code is ancient and originated from 32-bits stuff. In fact some of Paulus earliest xmons might even have run on platforms where int is 16 bits :-) Cheers, Ben.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web