Re: [PATCH] HID: roccat: Drop cast

2014-06-30 Thread Geert Uytterhoeven
On Sun, Jun 29, 2014 at 8:25 PM, Joe Perches wrote: > I think I've seen code in the kernel like > char *p2 = (void *)p; > where p is const and p2 is dereferenced and set. I can imagine there's code like that. Still hoping for gcc to gain an option to warn about all casts, except in heade

Re: [PATCH] HID: roccat: Drop cast

2014-06-29 Thread Joe Perches
On Sun, 2014-06-29 at 18:34 +0200, Julia Lawall wrote: > On Thu, 26 Jun 2014, Joe Perches wrote: > > void func(const void * const p) > > { > > char *p2 = p; > > > > p2[0] = 1; > > } > > Is this a real example? No, it's not. I think I've seen code in the kernel like char *p2 = (v

Re: [PATCH] HID: roccat: Drop cast

2014-06-29 Thread Julia Lawall
On Thu, 26 Jun 2014, Joe Perches wrote: > On Fri, 2014-06-27 at 07:29 +0200, Julia Lawall wrote: > > On Thu, 26 Jun 2014, Joe Perches wrote: > > > The cast of a const void * to a void * was odd. > > > > > > Maybe a mechanism to verify appropriateness of > > > loss of constness for any pointer m

Re: [PATCH] HID: roccat: Drop cast

2014-06-27 Thread Julia Lawall
On Thu, 26 Jun 2014, Joe Perches wrote: > On Fri, 2014-06-27 at 07:29 +0200, Julia Lawall wrote: > > On Thu, 26 Jun 2014, Joe Perches wrote: > > > The cast of a const void * to a void * was odd. > > > > > > Maybe a mechanism to verify appropriateness of > > > loss of constness for any pointer mi

Re: [PATCH] HID: roccat: Drop cast

2014-06-26 Thread Joe Perches
On Fri, 2014-06-27 at 07:29 +0200, Julia Lawall wrote: > On Thu, 26 Jun 2014, Joe Perches wrote: > > The cast of a const void * to a void * was odd. > > > > Maybe a mechanism to verify appropriateness of > > loss of constness for any pointer might be useful. > > I tried the following, but didn't

Re: [PATCH] HID: roccat: Drop cast

2014-06-26 Thread Julia Lawall
On Thu, 26 Jun 2014, Joe Perches wrote: > On Thu, 2014-06-26 at 22:58 +0530, Himangi Saraogi wrote: > > This patch removes the cast on data of type void* as it is not needed. > > Hi Himangi > > The cast of a const void * to a void * was odd. > > Maybe a mechanism to verify appropriateness of

Re: [PATCH] HID: roccat: Drop cast

2014-06-26 Thread Jiri Kosina
On Thu, 26 Jun 2014, Himangi Saraogi wrote: > This patch removes the cast on data of type void* as it is not needed. > The following Coccinelle semantic patch was used for making the change: > > @r@ > expression x; > void* e; > type T; > identifier f; > @@ > > ( > *((T *)e) > | > ((T *)x)[..

Re: [PATCH] HID: roccat: Drop cast

2014-06-26 Thread Joe Perches
On Thu, 2014-06-26 at 22:58 +0530, Himangi Saraogi wrote: > This patch removes the cast on data of type void* as it is not needed. Hi Himangi The cast of a const void * to a void * was odd. Maybe a mechanism to verify appropriateness of loss of constness for any pointer might be useful. -- To

[PATCH] HID: roccat: Drop cast

2014-06-26 Thread Himangi Saraogi
This patch removes the cast on data of type void* as it is not needed. The following Coccinelle semantic patch was used for making the change: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Signed-off-by: Himangi Saraogi Acked