V4L/DVB (4316): Check __must_check warnings
authorMichael Krufky <mkrufky@linuxtv.org>
Wed, 19 Jul 2006 16:23:38 +0000 (13:23 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sat, 29 Jul 2006 20:22:21 +0000 (17:22 -0300)
Check __must_check warnings for class_device_register and class_device_create_file

video_device_create_file was declared as a void, but instead should
return the int value of class_device_create_file.

Move the check from bttv-driver.c into v4l2-dev.h, because all other
callers of video_device_create_file must also be checked.

Replace the call to class_device_create_file in videodev.c with
video_device_create_file, as defined in v4l2-dev.h, so that the
return value of class_device_create_file will be checked.

Check the return value of class_device_register in videodev.c and
pvrusb2-sysfs.c

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/bt8xx/bttv-driver.c
drivers/media/video/pvrusb2/pvrusb2-sysfs.c
drivers/media/video/videodev.c
include/media/v4l2-dev.h

index 63e83162286cc7126f4c9effd6e730530f902538..6db5e4e73397f1edc183345f169cea4e37e0e137 100644 (file)
@@ -3909,8 +3909,6 @@ static void bttv_unregister_video(struct bttv *btv)
 /* register video4linux devices */
 static int __devinit bttv_register_video(struct bttv *btv)
 {
-       int ret;
-
        if (no_overlay <= 0) {
                bttv_video_template.type |= VID_TYPE_OVERLAY;
        } else {
@@ -3925,10 +3923,8 @@ static int __devinit bttv_register_video(struct bttv *btv)
                goto err;
        printk(KERN_INFO "bttv%d: registered device video%d\n",
               btv->c.nr,btv->video_dev->minor & 0x1f);
-       ret = video_device_create_file(btv->video_dev, &class_device_attr_card);
-       if (ret < 0)
-               printk(KERN_WARNING "bttv: video_device_create_file error: "
-                       "%d\n", ret);
+
+       video_device_create_file(btv->video_dev, &class_device_attr_card);
 
        /* vbi */
        btv->vbi_dev = vdev_init(btv, &bttv_vbi_template, "vbi");
index 6af55a8b6f055cb3b2e1e961bf00b3a78e8c817a..ef46d4f40cff3711e1e43de62f567b0483e4b87c 100644 (file)
@@ -600,6 +600,8 @@ static ssize_t debugcmd_store(struct class_device *,const char *,size_t count);
 static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
 {
        struct pvr2_sysfs_debugifc *dip;
+       int ret;
+
        dip = kmalloc(sizeof(*dip),GFP_KERNEL);
        if (!dip) return;
        memset(dip,0,sizeof(*dip));
@@ -613,8 +615,14 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
        dip->attr_debuginfo.attr.mode = S_IRUGO;
        dip->attr_debuginfo.show = debuginfo_show;
        sfp->debugifc = dip;
-       class_device_create_file(sfp->class_dev,&dip->attr_debugcmd);
-       class_device_create_file(sfp->class_dev,&dip->attr_debuginfo);
+       ret = class_device_create_file(sfp->class_dev,&dip->attr_debugcmd);
+       if (ret < 0)
+               printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
+                      __FUNCTION__, ret);
+       ret = class_device_create_file(sfp->class_dev,&dip->attr_debuginfo);
+       if (ret < 0)
+               printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
+                      __FUNCTION__, ret);
 }
 
 
@@ -709,6 +717,8 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
 {
        struct usb_device *usb_dev;
        struct class_device *class_dev;
+       int ret;
+
        usb_dev = pvr2_hdw_get_dev(sfp->channel.hdw);
        if (!usb_dev) return;
        class_dev = kmalloc(sizeof(*class_dev),GFP_KERNEL);
@@ -733,20 +743,33 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
 
        sfp->class_dev = class_dev;
        class_dev->class_data = sfp;
-       class_device_register(class_dev);
+       ret = class_device_register(class_dev);
+       if (ret) {
+               printk(KERN_ERR "%s: class_device_register failed\n",
+                      __FUNCTION__);
+               kfree(class_dev);
+               return;
+       }
 
        sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE;
        sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
        sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
        sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
        sfp->attr_v4l_minor_number.store = NULL;
-       class_device_create_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
+       ret = class_device_create_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
+       if (ret < 0)
+               printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
+                      __FUNCTION__, ret);
+
        sfp->attr_unit_number.attr.owner = THIS_MODULE;
        sfp->attr_unit_number.attr.name = "unit_number";
        sfp->attr_unit_number.attr.mode = S_IRUGO;
        sfp->attr_unit_number.show = unit_number_show;
        sfp->attr_unit_number.store = NULL;
-       class_device_create_file(sfp->class_dev,&sfp->attr_unit_number);
+       ret = class_device_create_file(sfp->class_dev,&sfp->attr_unit_number);
+       if (ret < 0)
+               printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
+                      __FUNCTION__, ret);
 
        pvr2_sysfs_add_controls(sfp);
 #ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
index b26ebaff226f49182537c0a350ff4189969eaddf..4c3f92605a82b4173bd79112e7578b7f2bf01a61 100644 (file)
@@ -1512,6 +1512,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
        int i=0;
        int base;
        int end;
+       int ret;
        char *name_base;
 
        switch(type)
@@ -1571,9 +1572,13 @@ int video_register_device(struct video_device *vfd, int type, int nr)
        vfd->class_dev.class       = &video_class;
        vfd->class_dev.devt        = MKDEV(VIDEO_MAJOR, vfd->minor);
        sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base);
-       class_device_register(&vfd->class_dev);
-       class_device_create_file(&vfd->class_dev,
-                               &class_device_attr_name);
+       ret = class_device_register(&vfd->class_dev);
+       if (ret) {
+               printk(KERN_ERR "%s: class_device_register failed\n",
+                      __FUNCTION__);
+               return ret;
+       }
+       video_device_create_file(vfd, &class_device_attr_name);
 
 #if 1
        /* needed until all drivers are fixed */
index 62dae1a8c4412c3f363193ad8efdd898f3fd0c22..f8665326ed9fc2a62a683e35a5595b1bc9fdc9fe 100644 (file)
@@ -341,11 +341,14 @@ extern int video_usercopy(struct inode *inode, struct file *file,
 extern struct video_device* video_devdata(struct file*);
 
 #define to_video_device(cd) container_of(cd, struct video_device, class_dev)
-static inline void
+static inline int
 video_device_create_file(struct video_device *vfd,
                         struct class_device_attribute *attr)
 {
-       class_device_create_file(&vfd->class_dev, attr);
+       int ret = class_device_create_file(&vfd->class_dev, attr);
+       if (ret < 0)
+               printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret);
+       return ret;
 }
 static inline void
 video_device_remove_file(struct video_device *vfd,