Skip to contentSkip to conversation

Staging: most: video: Changed the return value integer to NULL

PATCH In review Shivani Bhardwaj 3 participants 6 messages Oct 7, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: most: video: Changed the return value integer to NULL

Fixed the sparse warning : Using plain integer as NULL pointer, by changing the return value of function *get_aim_dev(struct, int) from 0 to NULL.

---
 drivers/staging/most/aim-v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/aim-v4l2/video.c +1 -1
index d968791..8333245 100644
@@ -430,7 +430,7 @@ static struct most_video_dev *get_aim_dev(
 		}
 	}
 	spin_unlock(&list_lock);
-	return 0;
+	return NULL;
 }
 
 static int aim_rx_data(struct mbo *mbo)
Signature · 1 line
2.1.0
#1 lore raw
Quoted 3 lines · Shivani Bhardwaj

Fixed the sparse warning : Using plain integer as NULL pointer, by changing the return value of function *get_aim_dev(struct, int) from 0 to NULL.

If you want, you could try doing this sort of thing with Coccinelle. An easy case is the assignment case. The following would find an assignment where the type is a pointer and the value is 0:

@@
type T;
T *x;
@@

x =
- 0
+ NULL

This makes a rule where T is an arbitrary type and x is an expression that has type pointer to type T. Then it searches for an assignment where there is this pointer typed expression on the left side and 0 on the right side, and then makes the change.

The function return case is a bit more complicated, because you have to find the function return type and the return statement, which are not right next to each other. But it can be done as well.

You can find out more at the Coccinelle web site: coccinelle.lip6.fr. There are some tutorials at the papers and slides link.

julia

Quoted 29 lines
---
 drivers/staging/most/aim-v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/aim-v4l2/video.c +1 -2
index d968791..8333245 100644
@@ -430,7 +430,7 @@ static struct most_video_dev *get_aim_dev(
 		}
 	}
 	spin_unlock(&list_lock);
-	return 0;
+	return NULL;
 }
 
 static int aim_rx_data(struct mbo *mbo)
--

2.1.0

--
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/20151007101433.GA50144%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 24 lines · Julia Lawall
Quoted 3 lines · Shivani Bhardwaj

Fixed the sparse warning : Using plain integer as NULL pointer, by changing the return value of function *get_aim_dev(struct, int) from 0 to NULL.

If you want, you could try doing this sort of thing with Coccinelle. An easy case is the assignment case. The following would find an assignment where the type is a pointer and the value is 0:

@@
type T;
T *x;
@@

x =
- 0
+ NULL

This makes a rule where T is an arbitrary type and x is an expression that has type pointer to type T. Then it searches for an assignment where there is this pointer typed expression on the left side and 0 on the right side, and then makes the change.

Quoted 9 lines

The function return case is a bit more complicated, because you have to find the function return type and the return statement, which are not right next to each other. But it can be done as well.

You can find out more at the Coccinelle web site: coccinelle.lip6.fr. There are some tutorials at the papers and slides link.

julia

Thanks, Julia! Is this patch not acceptable?

Quoted 29 lines
Quoted 29 lines
---
 drivers/staging/most/aim-v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/aim-v4l2/video.c +1 -2
index d968791..8333245 100644
@@ -430,7 +430,7 @@ static struct most_video_dev *get_aim_dev(
 		}
 	}
 	spin_unlock(&list_lock);
-	return 0;
+	return NULL;
 }
 
 static int aim_rx_data(struct mbo *mbo)
--

2.1.0

--
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/20151007101433.GA50144%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 29 lines · Shivani Bhardwaj
Quoted 28 lines · Julia Lawall
Quoted 3 lines · Shivani Bhardwaj

Fixed the sparse warning : Using plain integer as NULL pointer, by changing the return value of function *get_aim_dev(struct, int) from 0 to NULL.

If you want, you could try doing this sort of thing with Coccinelle. An easy case is the assignment case. The following would find an assignment where the type is a pointer and the value is 0:

@@
type T;
T *x;
@@

x =
- 0
+ NULL

This makes a rule where T is an arbitrary type and x is an expression that has type pointer to type T. Then it searches for an assignment where there is this pointer typed expression on the left side and 0 on the right side, and then makes the change.

The function return case is a bit more complicated, because you have to find the function return type and the return statement, which are not right next to each other. But it can be done as well.

Quoted 6 lines
Quoted 5 lines

You can find out more at the Coccinelle web site: coccinelle.lip6.fr. There are some tutorials at the papers and slides link.

julia

Thanks, Julia! Is this patch not acceptable?

The patch looks fine :) It was just something else to try.

julia

Quoted 37 lines
Quoted 22 lines
Quoted 22 lines
---
 drivers/staging/most/aim-v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/aim-v4l2/video.c +1 -2
index d968791..8333245 100644
@@ -430,7 +430,7 @@ static struct most_video_dev *get_aim_dev(
 		}
 	}
 	spin_unlock(&list_lock);
-	return 0;
+	return NULL;
 }
 
 static int aim_rx_data(struct mbo *mbo)
--

2.1.0

Quoted 7 lines
Quoted 7 lines

--
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/20151007101433.GA50144%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

--
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/20151007113026.GA51614%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
Quoted 36 lines · Julia Lawall
Quoted 32 lines · Shivani Bhardwaj
Quoted 31 lines · Julia Lawall
Quoted 3 lines · Shivani Bhardwaj

Fixed the sparse warning : Using plain integer as NULL pointer, by changing the return value of function *get_aim_dev(struct, int) from 0 to NULL.

If you want, you could try doing this sort of thing with Coccinelle. An easy case is the assignment case. The following would find an assignment where the type is a pointer and the value is 0:

@@
type T;
T *x;
@@

x =
- 0
+ NULL

This makes a rule where T is an arbitrary type and x is an expression that has type pointer to type T. Then it searches for an assignment where there is this pointer typed expression on the left side and 0 on the right side, and then makes the change.

The function return case is a bit more complicated, because you have to find the function return type and the return statement, which are not right next to each other. But it can be done as well.

You can find out more at the Coccinelle web site: coccinelle.lip6.fr. There are some tutorials at the papers and slides link.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

julia

Thanks, Julia! Is this patch not acceptable?

The patch looks fine :) It was just something else to try.

julia

OK. Thank you, Julia! :)

Quoted 37 lines
Quoted 37 lines
Quoted 22 lines
Quoted 22 lines
---
 drivers/staging/most/aim-v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/aim-v4l2/video.c +1 -2
index d968791..8333245 100644
@@ -430,7 +430,7 @@ static struct most_video_dev *get_aim_dev(
 		}
 	}
 	spin_unlock(&list_lock);
-	return 0;
+	return NULL;
 }
 
 static int aim_rx_data(struct mbo *mbo)
--

2.1.0

Quoted 7 lines
Quoted 7 lines

--
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/20151007101433.GA50144%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

--
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/20151007113026.GA51614%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

#5 lore raw
Quoted 8 lines · Shivani Bhardwaj
Quoted 7 lines · Julia Lawall
Quoted 3 lines · Shivani Bhardwaj
Quoted 2 lines · Julia Lawall

On Wed, 7 Oct 2015, Shivani Bhardwaj wrote:

<snip>

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Thanks, Julia! Is this patch not acceptable?

The patch looks fine :) It was just something else to try.

julia

OK. Thank you, Julia! :)

:(
This has also been done by 9b532df0fc1e ("staging: most: return NULL instead of integer") I think you are using Linus's tree and not Greg's staging tree.

regards
sudip