<br><br><div class="gmail_quote">On Tue, Jan 3, 2012 at 11:37 AM, Peter Hutterer <span dir="ltr"><<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Mon, Jan 02, 2012 at 07:08:09PM -0800, Chase Douglas wrote:<br>
> On 01/02/2012 05:19 PM, Peter Hutterer wrote:<br>
> > synaptics.c: In function 'SynapticsPreInit':<br>
> > synaptics.c:731:18: warning: assignment discards 'const' qualifier from<br>
> > pointer target type [enabled by default]<br>
> ><br>
> > Signed-off-by: Peter Hutterer <<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>><br>
> > ---<br>
> > src/properties.c | 2 +-<br>
> > src/synapticsstr.h | 2 +-<br>
> > 2 files changed, 2 insertions(+), 2 deletions(-)<br>
> ><br>
> > diff --git a/src/properties.c b/src/properties.c<br>
> > index f15a6fb..2affc17 100644<br>
> > --- a/src/properties.c<br>
> > +++ b/src/properties.c<br>
> > @@ -315,7 +315,7 @@ InitDeviceProperties(InputInfoPtr pInfo)<br>
> > prop_device_node = MakeAtom(XI_PROP_DEVICE_NODE, strlen(XI_PROP_DEVICE_NODE), TRUE);<br>
> > XIChangeDeviceProperty(pInfo->dev, prop_device_node, XA_STRING, 8,<br>
> > PropModeReplace, strlen(priv->device),<br>
> > - priv->device, FALSE);<br>
> > + (const pointer)priv->device, FALSE);<br>
><br>
> This seems like a recipe for trouble. We're relying on an assumption of<br>
> how XIChangeDeviceProperty works. Either we should change the signature<br>
> of the library call, or we should use strcpy().<br>
><br>
> Even if we are 100% sure that XIChangeDeviceProperty will never modify<br>
> the string, it's just bad programming.<br>
<br>
</div></div>XIChangeDeviceProperty takes a const pointer argument, this should work<br>
without the cast, except gcc did not like it.<br>
<br>
properties.c:318:32: warning: passing argument 7 of 'XIChangeDeviceProperty'<br>
<div class="im">discards 'const' qualifier from pointer target type [enabled by default]<br>
</div>/opt/xorg/include/xorg/exevents.h:88:51: note: expected 'pointer' but<br>
argument is of type 'const char *'<br>
<br>
if you knock up a 5-line test program, it appears that gcc has issues with<br>
the typedef. the code below emits a warning, but the warning goes away when<br>
bar changes to void bar(const void* a).<br>
<br>
typedef void* pointer;<br>
<br>
void bar(const pointer a)<br>
{<br>
printf("%lx\n", a);<br>
}<br>
<br>
int main (int argc, char **argv)<br>
{<br>
const char *foo;<br>
bar(foo);<br>
return 0;<br>
}<br>
<br>
not sure why gcc complains here.<br></blockquote><div><br></div><div>I believe this is the classic: "pointer to const void", versus "const pointer to void".</div><div><br></div><div>* The typedef creates a "pointer to void", which you then constify in the arg list ("const pointer to void").</div>
<div>* The non-typedef version is a "pointer to const void".</div><div><br></div><div>The 'typedef' creates an atomic type - it is not a macro that you can prepend "const" to later to constify the type being pointed to.</div>
<div><br></div><div>You would need a new typedef, like this:</div><div>typedef const void * cpointer;</div><div><br></div><div>Happy New Year,</div><div>-Dan</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Peter<br>
<div class="HOEnZb"><div class="h5">><br>
> > XISetDevicePropertyDeletable(pInfo->dev, prop_device_node, FALSE);<br>
> > }<br>
> ><br>
> > diff --git a/src/synapticsstr.h b/src/synapticsstr.h<br>
> > index 1ec8246..d74ebcd 100644<br>
> > --- a/src/synapticsstr.h<br>
> > +++ b/src/synapticsstr.h<br>
> > @@ -185,7 +185,7 @@ typedef struct _SynapticsPrivateRec<br>
> ><br>
> > struct SynapticsHwState hwState;<br>
> ><br>
> > - char *device; /* device node */<br>
> > + const char *device; /* device node */<br>
><br>
> This looks good either way though.<br>
><br>
> -- Chase<br>
_______________________________________________<br>
<a href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>: X.Org development<br>
Archives: <a href="http://lists.x.org/archives/xorg-devel" target="_blank">http://lists.x.org/archives/xorg-devel</a><br>
Info: <a href="http://lists.x.org/mailman/listinfo/xorg-devel" target="_blank">http://lists.x.org/mailman/listinfo/xorg-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><span style="font-family:'Times New Roman';font-size:medium"><div style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(213,15,37);border-right-color:rgb(213,15,37);border-bottom-color:rgb(213,15,37);border-left-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Daniel Kurtz |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(51,105,232);border-right-color:rgb(51,105,232);border-bottom-color:rgb(51,105,232);border-left-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Software Engineer |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(0,153,57);border-right-color:rgb(0,153,57);border-bottom-color:rgb(0,153,57);border-left-color:rgb(0,153,57);padding-top:2px;margin-top:2px"> <a href="mailto:djkurtz@google.com" target="_blank">djkurtz@google.com</a> |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(238,178,17);border-right-color:rgb(238,178,17);border-bottom-color:rgb(238,178,17);border-left-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> 650.204.0722</span></div>
</span><br>