Skip to contentSkip to conversation

media: imx-media-internal-sd: Use memset to clear pdevinfo struct

PATCH In review Fabio Estevam 2 participants 3 messages Feb 9, 2018

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

PATCH 1/1 media: imx-media-internal-sd: Use memset to clear pdevinfo struct

When building with W=1 the following warning shows up:

drivers/staging/media/imx/imx-media-internal-sd.c:274:49: warning: Using plain integer as NULL pointer

Fix this problem by using memset() to clear the pdevinfo structure.

---
 drivers/staging/media/imx/imx-media-internal-sd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-internal-sd.c +2 -1
index 70833fe503b5..377c20863b76 100644
@@ -271,7 +271,7 @@ static int add_internal_subdev(struct imx_media_dev *imxmd,
 			       int ipu_id)
 {
 	struct imx_media_internal_sd_platformdata pdata;
-	struct platform_device_info pdevinfo = {0};
+	struct platform_device_info pdevinfo;
 	struct platform_device *pdev;
 
 	pdata.grp_id = isd->id->grp_id;
@@ -283,6 +283,7 @@ static int add_internal_subdev(struct imx_media_dev *imxmd,
 	imx_media_grp_id_to_sd_name(pdata.sd_name, sizeof(pdata.sd_name),
 				    pdata.grp_id, ipu_id);
 
+	memset(&pdevinfo, 0, sizeof(pdevinfo));
 	pdevinfo.name = isd->id->name;
 	pdevinfo.id = ipu_id * num_isd + isd->id->index;
 	pdevinfo.parent = imxmd->md.dev;
Signature · 1 line
2.14.1
#1 lore raw
Quoted 5 lines · Fabio Estevam

When building with W=1 the following warning shows up:

drivers/staging/media/imx/imx-media-internal-sd.c:274:49: warning: Using plain integer as NULL pointer

Fix this problem by using memset() to clear the pdevinfo structure.

Hi Fabio,

I thought initializers were preferred to memset. I think the problem here is the first element of the struct is a pointer. Maybe this would be better?

struct platform_device_info pdevinfo = {NULL};

I see similar patches, for example:
https://patchwork.kernel.org/patch/10095129/

Regards,
IanJ

Quoted 28 lines
---
  drivers/staging/media/imx/imx-media-internal-sd.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-internal-sd.c +2 -1
index 70833fe503b5..377c20863b76 100644
@@ -271,7 +271,7 @@ static int add_internal_subdev(struct imx_media_dev *imxmd,
  			       int ipu_id)
  {
  	struct imx_media_internal_sd_platformdata pdata;
-	struct platform_device_info pdevinfo = {0};
+	struct platform_device_info pdevinfo;
  	struct platform_device *pdev;
 
  	pdata.grp_id = isd->id->grp_id;
@@ -283,6 +283,7 @@ static int add_internal_subdev(struct imx_media_dev *imxmd,
  	imx_media_grp_id_to_sd_name(pdata.sd_name, sizeof(pdata.sd_name),
  				    pdata.grp_id, ipu_id);
 
+	memset(&pdevinfo, 0, sizeof(pdevinfo));
  	pdevinfo.name = isd->id->name;
  	pdevinfo.id = ipu_id * num_isd + isd->id->index;
  	pdevinfo.parent = imxmd->md.dev;
#2 lore raw
Quoted 5 lines · Ian Arkver
Quoted 4 lines · Fabio Estevam

When building with W=1 the following warning shows up:

drivers/staging/media/imx/imx-media-internal-sd.c:274:49: warning: Using plain integer as NULL pointer

Quoted 7 lines
Quoted 1 line

Fix this problem by using memset() to clear the pdevinfo structure.

Hi Fabio,

I thought initializers were preferred to memset. I think the problem here is the first element of the struct is a pointer. Maybe this would be better?

struct platform_device_info pdevinfo = {NULL};

Actually an empty initialiser list would be better again.

eg:
https://patchwork.kernel.org/patch/9480131/

Quoted 33 lines

I see similar patches, for example:
https://patchwork.kernel.org/patch/10095129/

Regards,
IanJ

Quoted 28 lines

---
  drivers/staging/media/imx/imx-media-internal-sd.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-internal-sd.c +2 -1
index 70833fe503b5..377c20863b76 100644
@@ -271,7 +271,7 @@ static int add_internal_subdev(struct 
 imx_media_dev *imxmd,
                      int ipu_id)
   {
       struct imx_media_internal_sd_platformdata pdata;
-    struct platform_device_info pdevinfo = {0};
+    struct platform_device_info pdevinfo;
       struct platform_device *pdev;
       pdata.grp_id = isd->id->grp_id;
@@ -283,6 +283,7 @@ static int add_internal_subdev(struct 
 imx_media_dev *imxmd,
       imx_media_grp_id_to_sd_name(pdata.sd_name, sizeof(pdata.sd_name),
                       pdata.grp_id, ipu_id);
+    memset(&pdevinfo, 0, sizeof(pdevinfo));
       pdevinfo.name = isd->id->name;
       pdevinfo.id = ipu_id * num_isd + isd->id->index;
       pdevinfo.parent = imxmd->md.dev;