[media] tda18212: tda18218: use 'val' if initialized
authorPaul Bolle <pebolle@tiscali.nl>
Thu, 1 Nov 2012 20:00:09 +0000 (17:00 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 21 Dec 2012 20:25:13 +0000 (18:25 -0200)
Commits e666a44fa313cb9329c0381ad02fc6ee1e21cb31 ("[media] tda18212:
silence compiler warning") and e0e52d4e9f5bce7ea887027c127473eb654a5a04
("[media] tda18218: silence compiler warning") silenced warnings
equivalent to these:
    drivers/media/tuners/tda18212.c: In function ‘tda18212_attach’:
    drivers/media/tuners/tda18212.c:299:2: warning: ‘val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    drivers/media/tuners/tda18218.c: In function ‘tda18218_attach’:
    drivers/media/tuners/tda18218.c:305:2: warning: ‘val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
But in both cases 'val' will still be used uninitialized if the calls
of tda18212_rd_reg() or tda18218_rd_reg() fail. Fix this by only
printing the "chip id" if the calls of those functions were successful.
This allows to drop the uninitialized_var() stopgap measure.
Also stop printing the return values of tda18212_rd_reg() or
tda18218_rd_reg(), as these are not interesting.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/tuners/tda18212.c
drivers/media/tuners/tda18218.c

index 5d9f028425012e75ee7edefe97c149fb9f415df6..e4a84ee231cf458a4e5b84292f2e83115e023caf 100644 (file)
@@ -277,7 +277,7 @@ struct dvb_frontend *tda18212_attach(struct dvb_frontend *fe,
 {
        struct tda18212_priv *priv = NULL;
        int ret;
-       u8 uninitialized_var(val);
+       u8 val;
 
        priv = kzalloc(sizeof(struct tda18212_priv), GFP_KERNEL);
        if (priv == NULL)
@@ -296,8 +296,8 @@ struct dvb_frontend *tda18212_attach(struct dvb_frontend *fe,
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */
 
-       dev_dbg(&priv->i2c->dev, "%s: ret=%d chip id=%02x\n", __func__, ret,
-                       val);
+       if (!ret)
+               dev_dbg(&priv->i2c->dev, "%s: chip id=%02x\n", __func__, val);
        if (ret || val != 0xc7) {
                kfree(priv);
                return NULL;
index 18198537be9f45c9f224947643f9884ac22348db..2d31aeb6b088997fbed7678f631a47f175500d55 100644 (file)
@@ -277,7 +277,7 @@ struct dvb_frontend *tda18218_attach(struct dvb_frontend *fe,
        struct i2c_adapter *i2c, struct tda18218_config *cfg)
 {
        struct tda18218_priv *priv = NULL;
-       u8 uninitialized_var(val);
+       u8 val;
        int ret;
        /* chip default registers values */
        static u8 def_regs[] = {
@@ -302,8 +302,8 @@ struct dvb_frontend *tda18218_attach(struct dvb_frontend *fe,
 
        /* check if the tuner is there */
        ret = tda18218_rd_reg(priv, R00_ID, &val);
-       dev_dbg(&priv->i2c->dev, "%s: ret=%d chip id=%02x\n", __func__, ret,
-                       val);
+       if (!ret)
+               dev_dbg(&priv->i2c->dev, "%s: chip id=%02x\n", __func__, val);
        if (ret || val != def_regs[R00_ID]) {
                kfree(priv);
                return NULL;