ngene: remove an unneeded condition
Subsystems (2)
PATCH 1/1 ngene: remove an unneeded condition
"stat" is always zero here. The condition used to be needed, but we shifted stuff around in 0f0b270f90 "[media] ngene: CXD2099AR Common Interface driver".
This doesn't change how the code works, it's just a bit tidier.
drivers/media/dvb/ngene/ngene-core.c +1 -3
@@ -1409,10 +1409,8 @@ static int ngene_start(struct ngene *dev)if (stat <0 ) goto fail; -if (!stat) -return stat; +return 0 ; -/* otherwise error: fall through */ fail:ngwritel (0 ,NGENE_INT_ENABLE );free_irq (dev->pci_dev->irq, dev);
Am 20.04.2012 15:15, schrieb Dan Carpenter:
Quoted 14 lines
"stat" is always zero here. The condition used to be needed, but we shifted stuff around in
0f0b270f90"[media] ngene: CXD2099AR Common Interface driver".This doesn't change how the code works, it's just a bit tidier.
Signed-off-by Dan Carpenter <[email protected]>drivers/media/dvb/ngene/ngene-core.c +0
-0@@ -1409,10 +1409,8 @@ static int ngene_start(struct ngene *dev)if (stat <0 )
drivers/media/dvb/ngene/ngene-core.c static int ngene_start(struct ngene *dev) · line 1416
Quoted 10 lines
drivers/media/dvb/ngene/ngene-core.c +1
-3goto fail; -if (!stat) -return stat; +return 0 ; -/* otherwise error: fall through */ fail:ngwritel (0 ,NGENE_INT_ENABLE );free_irq (dev->pci_dev->irq, dev);
it seems more logical to use the positive exit in this case like:
if (stat >=0)
return 0;
instead of jumping over return 0:
just my 2 cents,
re,
wh
Quoted 30 lines · walter harms
Am 20.04.2012 15:15, schrieb Dan Carpenter:
Quoted 14 lines
"stat" is always zero here. The condition used to be needed, but we shifted stuff around in
0f0b270f90"[media] ngene: CXD2099AR Common Interface driver".This doesn't change how the code works, it's just a bit tidier.
Signed-off-by Dan Carpenter <[email protected]>drivers/media/dvb/ngene/ngene-core.c +0
-0@@ -1409,10 +1409,8 @@ static int ngene_start(struct ngene *dev)if (stat <0 )drivers/media/dvb/ngene/ngene-core.c static int ngene_start(struct ngene *dev) · line 1416
Quoted 10 lines
drivers/media/dvb/ngene/ngene-core.c +1
-3goto fail; -if (!stat) -return stat; +return 0 ; -/* otherwise error: fall through */ fail:ngwritel (0 ,NGENE_INT_ENABLE );free_irq (dev->pci_dev->irq, dev);it seems more logical to use the positive exit in this case like:
Quoted 5 lines
if (stat >=0)
return 0;instead of jumping over return 0:
I would say it's more readable to handle the error condition as a special case instead of handling the normal success case as special. It's better to be consistent instead of changing back and forth:
if (error condition) return ret; if (error condition) return ret; if (success conditi) return ret; if (error condition) return ret;
regards,
dan carpenter
Am 28.04.2012 17:16, schrieb Dan Carpenter:
Quoted 42 lines · walter harms
Quoted 30 lines
Am 20.04.2012 15:15, schrieb Dan Carpenter:
Quoted 14 lines
"stat" is always zero here. The condition used to be needed, but we shifted stuff around in
0f0b270f90"[media] ngene: CXD2099AR Common Interface driver".This doesn't change how the code works, it's just a bit tidier.
Signed-off-by Dan Carpenter <[email protected]>drivers/media/dvb/ngene/ngene-core.c +0
-0@@ -1409,10 +1409,8 @@ static int ngene_start(struct ngene *dev)if (stat <0 )drivers/media/dvb/ngene/ngene-core.c static int ngene_start(struct ngene *dev) · line 1416
Quoted 10 lines
drivers/media/dvb/ngene/ngene-core.c +1
-3goto fail; -if (!stat) -return stat; +return 0 ; -/* otherwise error: fall through */ fail:ngwritel (0 ,NGENE_INT_ENABLE );free_irq (dev->pci_dev->irq, dev);it seems more logical to use the positive exit in this case like:
Quoted 5 lines
if (stat >=0)
return 0;instead of jumping over return 0:
I would say it's more readable to handle the error condition as a special case instead of handling the normal success case as special. It's better to be consistent instead of changing back and forth:
Quoted 10 lines
if (error condition) return ret; if (error condition) return ret; if (success conditi) return ret; if (error condition) return ret;
i agree but in this special case it looks strange. Would that more readable ?
if (stat < 0)
{
<errorhandling here>
return stat;
}
return 0:
re,
wh
Quoted 11 lines · walter harms
i agree but in this special case it looks strange. Would that more readable ?
if (stat < 0)
{
<errorhandling here>
return stat;
}return 0:
No. Gotos are perfectly fine for unwinding in the error handling code. In this case there are several in a row. Copy and pasting the error handling leads to forgot to add a kfree() bugs.
It doesn't look weird at all, it looks like the most normal kind of error handling there is in the kernel.
regards,
dan carpenter