Skip to contentSkip to conversation

tracetool: cast const types to avoid compile time warnings

Qemu-devel Lee Essen 2 participants 3 messages Mar 21, 2012 – Mar 22, 2012

lore
Share & tools
lore

Lee Essen

author
#0 lore raw

On Solaris/Illumos dtrace will remove the "const" qualifier from any arguments when producing the header file, this results in hundreds of compile-time warnings.

I have put together a patch to tracetool to cast any const argument appropriately to remove the warnings, but I don't know how it behaves on any other dtrace platform. If the "const" isn't removed then this patch will actually create warnings.

Do you see these warnings on any other dtrace platform? If not, then I'll need to make sure the patch is solaris-specific.

Thanks,

Lee.

#1 lore raw
Quoted 3 lines · Lee Essen

On Solaris/Illumos dtrace will remove the "const" qualifier from any arguments when producing the header file, this results in hundreds of compile-time warnings.

I wonder why DTrace does this, it seems wrong. If anything it should be the other way around with all DTrace arguments becoming const :). Will you submit a patch to preserve const in upstream DTrace?

Quoted 4 lines

I have put together a patch to tracetool to cast any const argument appropriately to remove the warnings, but I don't know how it behaves on any other dtrace platform. If the "const" isn't removed then this patch will actually create warnings.

Why would it introduce warnings, maybe I'm misunderstanding?

The following generated .h code should work without warnings whether the DTRACE_FOO() is const char* or char*:

void trace_foo(const char *s)

{
    DTRACE_FOO((char *)s);
}
Quoted 2 lines

Do you see these warnings on any other dtrace platform? If not, then I'll need to make sure the patch is solaris-specific.

I haven't seen this issue on SystemTap.

Stefan

author
#2 lore raw
Quoted 8 lines · Stefan Hajnoczi
Quoted 3 lines · Lee Essen

On Solaris/Illumos dtrace will remove the "const" qualifier from any arguments when producing the header file, this results in hundreds of compile-time warnings.

I wonder why DTrace does this, it seems wrong. If anything it should be the other way around with all DTrace arguments becoming const :). Will you submit a patch to preserve const in upstream DTrace?

I have asked the Illumos dev-list what the reasoning is. If it turns out to be a bug then I'll see what I can do about a fix, although it will be an illumos fix rather than a Solaris fix - so we'll still need a solution for generic Solaris.

Quoted 8 lines
Quoted 5 lines

I have put together a patch to tracetool to cast any const argument appropriately to remove the warnings, but I don't know how it behaves on any other dtrace platform. If the "const" isn't removed then this patch will actually create warnings.

Why would it introduce warnings, maybe I'm misunderstanding?

Quoted 7 lines

The following generated .h code should work without warnings whether the DTRACE_FOO() is const char* or char*:

void trace_foo(const char *s)

{
     DTRACE_FOO((char *)s);
}

Hmmm ... yes, you're right, I wasn't thinking straight. This is good since it means we can use the same approach without breaking anything.

I'll let you know what the illumos-dev response is.

Cheers,

Lee.