staging: media: atomisp: Remove useless cast.
Subsystems (4)
PATCH 1/2 staging: media: atomisp: Remove useless cast.
In reply to a message not in the archiveExplicit type casting of variable, with same type as that of variable, is not required. The following coccinelle script is used to remove it.
@@
type T;
T *ptr,p;
@@
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p)
+ p
)
--- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 2 +- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c | 2 +- drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +1 -1
@@ -1335,7 +1335,7 @@ static int pc_monitoring(void *data) {int i =0 ; - (void )data; + data;while (true) {if (sh_binary_running) {sh_css_metrics_sample_pcs ();
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c +1 -1
@@ -1155,7 +1155,7 @@ sp_init_stage(struct ia_css_pipeline_stage *stage, } err = sh_css_sp_init_stage(binary, - (const char *)binary_name, + binary_name, blob_info, args, pipe_num,
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +1 -1
@@ -553,7 +553,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) vptr =hmm_bo_vmap (bo, true);if (vptr) { vptr = vptr + (virt - bo->start); -memset ((void *)vptr, c, bytes); +memset (vptr, c, bytes);clflush_cache_range (vptr, bytes);hmm_bo_vunmap (bo);return 0 ;
Signature · 1 line
2.9.3
PATCH 2/2 staging: media: atomisp: Remove unnecessary identifier.
In reply to a message not in the archiveThis patch removes indentifier data, which is not required.
--- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +0 -1
@@ -1335,7 +1335,6 @@ static int pc_monitoring(void *data) {int i =0 ; - data;while (true) {if (sh_binary_running) {sh_css_metrics_sample_pcs ();
Signature · 1 line
2.9.3
y
Quoted 33 lines · Varsha Rao
Explicit type casting of variable, with same type as that of variable, is not required. The following coccinelle script is used to remove it.
@@
type T;
T *ptr,p;
@@
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p)
+ p
)Signed-off-by Varsha Rao <[email protected]>--- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 2 +- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c | 2 +- drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +0
-0
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c static int pc_monitoring(void *data) · line 1338
Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +1
-1@@ -1335,7 +1335,7 @@ static int pc_monitoring(void *data) {int i =0 ; - (void )data; + data;
Did Coccinelle really find this case for you? Because void and void * are not the same.
julia
Quoted 39 lines
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +0
-0while (true) {if (sh_binary_running) {sh_css_metrics_sample_pcs ();drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c +1
-1@@ -1155,7 +1155,7 @@ sp_init_stage(struct ia_css_pipeline_stage *stage, } err = sh_css_sp_init_stage(binary, - (const char *)binary_name, + binary_name, blob_info, args, pipe_num,drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +1
-2@@ -553,7 +553,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) vptr =hmm_bo_vmap (bo, true);if (vptr) { vptr = vptr + (virt - bo->start); -memset ((void *)vptr, c, bytes); +memset (vptr, c, bytes);clflush_cache_range (vptr, bytes);hmm_bo_vunmap (bo);return 0 ; --2.9.3
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/58bf8051.081a620a.e7433.8064%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.
Hello,
Did Coccinelle really find this case for you? Because void and void * are
Quoted 3 lines
not the same.
Yes, it was found using Coccinelle. I got the output as following.
diff -u -p a/media/atomisp/pci/atomisp2/css2400/sh_css.cb/media/atomisp/pci/atomisp2/css2400/sh_css.c
media/atomisp/pci/atomisp2/css2400/sh_css.c +1 -1
@@ -1335,7 +1335,7 @@ static int pc_monitoring(void *data) {int i =0 ; - (void )data; + data;while (true) {if (sh_binary_running) {sh_css_metrics_sample_pcs ();
@@
type T; //Here if we assume T to be type void
T *ptr,p; //ptr is pointer to void and p is of type void. @@
As you said void and void * are different.
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p) It is taking this case.
+ p
)
But p and ptr are also different, then why is it considering p? Is it giving false positive?
To check this, I just changed the declaration.
@@
type T;
T *ptr;
T p;
@@
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p)
+ p
)
However, here it does not match void and void * . Also gives no output for this particular file.
Why is it not recognizing the difference between ptr and p ? (with the earlier coccinelle script)
Thanks,
Varsha
Quoted 63 lines · Varsha Rao
Hello,
Did Coccinelle really find this case for you? Because void and void * are not the same.
Yes, it was found using Coccinelle. I got the output as following.
diff -u -p
a/media/atomisp/pci/atomisp2/css2400/sh_css.cb/media/atomisp/pci/atomisp2/css2400/sh_css.cmedia/atomisp/pci/atomisp2/css2400/sh_css.c +1
-1@@ -1335,7 +1335,7 @@ static int pc_monitoring(void *data) { int i = 0; - (void)data; + data; while (true) { if (sh_binary_running) { sh_css_metrics_sample_pcs();
@@
type T; //Here if we assume T to be type void T *ptr,p; //ptr is pointer to void and p is of type void. @@As you said void and void * are different.
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p) It is taking this case.
+ p
)But p and ptr are also different, then why is it considering p? Is it giving false positive? To check this, I just changed the declaration.
@@
type T;
T *ptr;
T p;
@@
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p)
+ p
)
Quoted 2 lines
However, here it does not match void and void * . Also gives no output for this particular file. Why is it not recognizing the difference between ptr and p ? (with the earlier coccinelle script)
Because there is a bug in the parsing of metavariable identifiers. I knew this, but haven't thought about it recently... I think that once it sees a *, it applies the * to everything that comes after. Or more likely, it is probably parsing the metavariables as T * being the type, and the list of names coming after.
I'll make a note to fix it.
thanks,
julia
Quoted 12 lines
Thanks,
Varsha--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/53167cf4-2fc5-4178-b963-c616822ae3b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello,
Quoted 5 lines
However, here it does not match void and void * . Also gives no output for this particular file.
Quoted 1 line
Why is it not recognizing the difference between ptr and p ? (with the
earlier coccinelle script)
Quoted 9 lines
Because there is a bug in the parsing of metavariable identifiers. I knew this, but haven't thought about it recently... I think that once it sees a *, it applies the * to everything that comes after. Or more likely, it is probably parsing the metavariables as T * being the type, and the list of names coming after.
I'll make a note to fix it.
Yes, it is indeed a bug and thanks for considering it. I hope the
following observation would be of help.
There was one more case, which I ignored as it gave false result. (using
the first script)
Such as it could not recognize difference between declaration unsigned
int __user *user_chanlist and cast (unsigned int __force *)user_chanlist .
Removed the later casting. The file is comedi/comedi_fops.c
- cmd.chanlist = (unsigned int __force *)user_chanlist;
+ cmd.chanlist = user_chanlist;
Thanks,
Varsha
Quoted 24 lines · Varsha Rao
Hello,
> However, here it does not match void and void * . Also gives no output for this particular file.
> Why is it not recognizing the difference between ptr and p ? (with the earlier coccinelle script)Because there is a bug in the parsing of metavariable identifiers. I knew
this, but haven't thought about it recently... I think that once it sees
a *, it applies the * to everything that comes after. Or more likely, it
is probably parsing the metavariables as T * being the type, and the list
of names coming after.I'll make a note to fix it.
Yes, it is indeed a bug and thanks for considering it. I hope the following observation would be of help.
Quoted 8 lines
There was one more case, which I ignored as it gave false result. (using the first script)
Such as it could not recognize difference between declaration unsigned int__user*user_chanlistand cast (unsigned int__force*)user_chanlist . Removed the later casting. The file iscomedi/comedi_fops.c- cmd.chanlist = (unsigned int
__force*)user_chanlist; + cmd.chanlist =user_chanlist;
Yeah, Coccinelle is also not good at annotations at the moment - work in progress... It was good thinking to ignore this case.
julia
Quoted 15 lines
Thanks,
Varsha--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/c301a39d-7f44-4c3e-8f6c- 2350b5938d1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.