Skip to contentSkip to conversation

media: pxa_camera: Fix check for pdev->dev.of_node

PATCH In review Nathan Chancellor 2 participants 2 messages Sep 21, 2018 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: pxa_camera: Fix check for pdev->dev.of_node

Clang warns that the address of a pointer will always evaluated as true in a boolean context.

drivers/media/platform/pxa_camera.c:2400:17: warning: address of 'pdev->dev.of_node' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (&pdev->dev.of_node && !pcdev->pdata) {
             ~~~~~~~~~~^~~~~~~ ~~

1 warning generated.

Judging from the rest of the kernel, it seems like this was an error and just the value of of_node should be checked rather than the address.

---
 drivers/media/platform/pxa_camera.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/pxa_camera.c +1 -1
index 3288d22de2a0..6717834e8041 100644
@@ -2397,7 +2397,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
 	pcdev->res = res;
 
 	pcdev->pdata = pdev->dev.platform_data;
-	if (&pdev->dev.of_node && !pcdev->pdata) {
+	if (pdev->dev.of_node && !pcdev->pdata) {
 		err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev, &pcdev->asd);
 	} else {
 		pcdev->platform_flags = pcdev->pdata->flags;
Signature · 1 line
2.19.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Nathan Chancellor

Clang warns that the address of a pointer will always evaluated as true in a boolean context.

drivers/media/platform/pxa_camera.c:2400:17: warning: address of 'pdev->dev.of_node' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (&pdev->dev.of_node && !pcdev->pdata) {
             ~~~~~~~~~~^~~~~~~ ~~

1 warning generated.

Judging from the rest of the kernel, it seems like this was an error and just the value of of_node should be checked rather than the address.

---
 drivers/media/platform/pxa_camera.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/pxa_camera.c +0 -0
index 3288d22de2a0..6717834e8041 100644

drivers/media/platform/pxa_camera.c static int pxa_camera_probe(struct platform_device *pdev) · line 2400

Quoted 5 lines
drivers/media/platform/pxa_camera.c +1 -1
@@ -2397,7 +2397,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
        pcdev->res = res;
 
        pcdev->pdata = pdev->dev.platform_data;
-       if (&pdev->dev.of_node && !pcdev->pdata) {
+       if (pdev->dev.of_node && !pcdev->pdata) {

pdev->dev.of_node is a struct device_node *, so this is the correct way to check that it's not NULL. It's use in pxa_camera_pdata_from_dt() is necessitated on the caller checking that it's not NULL.

Quoted 6 lines
drivers/media/platform/pxa_camera.c +0 -1
                err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev, &pcdev->asd);
        } else {
                pcdev->platform_flags = pcdev->pdata->flags;
--

2.19.0

Signature · 2 lines
Thanks,
~Nick Desaulniers