V4L/DVB (13241): Cleanup redundant tests on unsigned
authorRoel Kluin <roel.kluin@gmail.com>
Fri, 23 Oct 2009 10:59:42 +0000 (07:59 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 5 Dec 2009 20:41:04 +0000 (18:41 -0200)
The variables are unsigned so the test `>= 0' is always true,
the `< 0' test always fails. In these cases the other part of
the test catches wrapped values.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
13 files changed:
drivers/media/common/tuners/tda9887.c
drivers/media/dvb/siano/smscoreapi.c
drivers/media/video/bt819.c
drivers/media/video/hexium_gemini.c
drivers/media/video/hexium_orion.c
drivers/media/video/mxb.c
drivers/media/video/s2255drv.c
drivers/media/video/saa7110.c
drivers/media/video/saa717x.c
drivers/media/video/tuner-core.c
drivers/media/video/usbvision/usbvision-video.c
drivers/media/video/vpx3220.c
drivers/media/video/zoran/zoran_driver.c

index 544cdbe88a6c9220eef89326ee363739cb0f2434..a71c100c95df674c60ff3033624f675f420f14c9 100644 (file)
@@ -463,7 +463,7 @@ static int tda9887_set_insmod(struct dvb_frontend *fe)
                        buf[1] &= ~cQSS;
        }
 
-       if (adjust >= 0x00 && adjust < 0x20) {
+       if (adjust < 0x20) {
                buf[2] &= ~cTopMask;
                buf[2] |= adjust;
        }
index fa6a62369a78361c81e6a06f650308b1ed0d5205..ca758bcb48c95ee00d8a23cd4e047f37e98d08f4 100644 (file)
@@ -1373,7 +1373,7 @@ static int GetGpioPinParams(u32 PinNum, u32 *pTranslatedPinNum,
 
        *pGroupCfg = 1;
 
-       if (PinNum >= 0 && PinNum <= 1) {
+       if (PinNum <= 1)        {
                *pTranslatedPinNum = 0;
                *pGroupNum = 9;
                *pGroupCfg = 2;
index f9330e3529c3e1d03b903ac0fad8a7f49a96c733..5bb0f9e7158371d353860eac61964804d94fd92e 100644 (file)
@@ -299,7 +299,7 @@ static int bt819_s_routing(struct v4l2_subdev *sd,
 
        v4l2_dbg(1, debug, sd, "set input %x\n", input);
 
-       if (input < 0 || input > 7)
+       if (input > 7)
                return -EINVAL;
 
        if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
index 71c211402eb5e3bd9c6759904299a80fa1cb2544..60d992ee2589b71253ec40c4aed73a6f9e95321d 100644 (file)
@@ -251,7 +251,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
 
        DEB_EE(("VIDIOC_S_INPUT %d.\n", input));
 
-       if (input < 0 || input >= HEXIUM_INPUTS)
+       if (input >= HEXIUM_INPUTS)
                return -EINVAL;
 
        hexium->cur_input = input;
index 39d65ca41c627026a83ebc899a84fdb08d71b438..938a1f8f880a0a2ca4471d3e2fc81ca722fad09e 100644 (file)
@@ -350,7 +350,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
        struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
        struct hexium *hexium = (struct hexium *) dev->ext_priv;
 
-       if (input < 0 || input >= HEXIUM_INPUTS)
+       if (input >= HEXIUM_INPUTS)
                return -EINVAL;
 
        hexium->cur_input = input;
index 3454070e63f00de6e1491d106cd2b6c60a8328e3..c1fc6dc776f5804f985107f9490a11c1dbe44136 100644 (file)
@@ -478,7 +478,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
 
        DEB_EE(("VIDIOC_S_INPUT %d.\n", input));
 
-       if (input < 0 || input >= MXB_INPUTS)
+       if (input >= MXB_INPUTS)
                return -EINVAL;
 
        mxb->cur_input = input;
index 2c0bb06cab3b5155f81069f81c284247e467bab0..d0824f3c734f1bded09b662505222498b4056a32 100644 (file)
@@ -1958,7 +1958,7 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
                                if (pdword[1] >= MAX_CHANNELS)
                                        break;
                                cc = G_chnmap[pdword[1]];
-                               if (!(cc >= 0 && cc < MAX_CHANNELS))
+                               if (cc >= MAX_CHANNELS)
                                        break;
                                switch (pdword[2]) {
                                case S2255_RESPONSE_SETMODE:
index 5c24c993ac16724e1d29ab077ae3184cfa0ea0e3..3bca744e43af18a47607601c59fbe74c7dbaf3bc 100644 (file)
@@ -304,7 +304,7 @@ static int saa7110_s_routing(struct v4l2_subdev *sd,
 {
        struct saa7110 *decoder = to_saa7110(sd);
 
-       if (input < 0 || input >= SAA7110_MAX_INPUT) {
+       if (input >= SAA7110_MAX_INPUT) {
                v4l2_dbg(1, debug, sd, "input=%d not available\n", input);
                return -EINVAL;
        }
index b15c40908e8423556ed4ca6dae8590af520395c4..ad6cd37311facafd8a7935b04b2f2fbf8c608ec8 100644 (file)
@@ -1115,7 +1115,7 @@ static int saa717x_s_video_routing(struct v4l2_subdev *sd,
        v4l2_dbg(1, debug, sd, "decoder set input (%d)\n", input);
        /* inputs from 0-9 are available*/
        /* saa717x have mode0-mode9 but mode5 is reserved. */
-       if (input < 0 || input > 9 || input == 5)
+       if (input > 9 || input == 5)
                return -EINVAL;
 
        if (decoder->input != input) {
index 50f6db5cd50b3aa4d2d9eba3863ccd9ef07adeaa..a9c9703113c2fa3b8dee0dae96adceb88c7157c7 100644 (file)
@@ -328,7 +328,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
 
        t->type = type;
        /* prevent invalid config values */
-       t->config = ((new_config >= 0) && (new_config < 256)) ? new_config : 0;
+       t->config = new_config < 256 ? new_config : 0;
        if (tuner_callback != NULL) {
                tuner_dbg("defining GPIO callback\n");
                t->fe.callback = tuner_callback;
index a2a50d608a3fd0d061b655119cbf8d4627b0be05..c07b0ac452abf8a986d134ab260e78ae5890f463 100644 (file)
@@ -601,7 +601,7 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input)
 {
        struct usb_usbvision *usbvision = video_drvdata(file);
 
-       if ((input >= usbvision->video_inputs) || (input < 0) )
+       if (input >= usbvision->video_inputs)
                return -EINVAL;
 
        mutex_lock(&usbvision->lock);
index 97e0ce28ff18f91655d4e69b928c54ad0a2b0e47..33205d7537d8f59524edb2dc617f54468f642785 100644 (file)
@@ -391,7 +391,7 @@ static int vpx3220_s_routing(struct v4l2_subdev *sd,
                {0x0e, 1}
        };
 
-       if (input < 0 || input > 2)
+       if (input > 2)
                return -EINVAL;
 
        v4l2_dbg(1, debug, sd, "input switched to %s\n", inputs[input]);
index 47137deafcfd9b5a04951ca7c6cc0745f1ebe4af..e9f72ca458f1b977dada7cf3b177f47483073889 100644 (file)
@@ -2764,7 +2764,7 @@ static int zoran_enum_input(struct file *file, void *__fh,
        struct zoran_fh *fh = __fh;
        struct zoran *zr = fh->zr;
 
-       if (inp->index < 0 || inp->index >= zr->card.inputs)
+       if (inp->index >= zr->card.inputs)
                return -EINVAL;
        else {
                int id = inp->index;