Skip to contentSkip to conversation

Thermal:Remove usless if(!result) before return tz

PATCH Superseded Yao Dongdong 2 participants 4 messages Oct 20, 2014 – Oct 21, 2014 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Thermal:Remove usless if(!result) before return tz

result is always zero when comes here.

Signed-off-by [email protected]
---
 drivers/thermal/thermal_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/thermal_core.c +1 -2
index 5b7d466..19cac8e 100644
@@ -1568,8 +1568,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 
    thermal_zone_device_update(tz);
 
-   if (!result)
-       return tz;
+   return tz;
 
 unregister:
    release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);

--
1.8.0.1

#1 lore raw

Hello Yao

Quoted 13 lines · Yao Dongdong

result is always zero when comes here.

Signed-off-by [email protected]
---
 drivers/thermal/thermal_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/thermal_core.c +0 -0
index 5b7d466..19cac8e 100644

drivers/thermal/thermal_core.c struct thermal_zone_device *thermal_zone_device_register(const char *type, · line 1572

Quoted 7 lines
drivers/thermal/thermal_core.c +1 -2
@@ -1568,8 +1568,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 
    thermal_zone_device_update(tz);
 
-   if (!result)
-       return tz;
+   return tz;
 

Adding a return here will make the resource release below not reachable in the fail path.

Quoted 6 lines
drivers/thermal/thermal_core.c +0 -1
 unregister:
    release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
--

1.8.0.1

#2 lore raw
Quoted 17 lines · Eduardo Valentin

Hello Yao

Quoted 14 lines · Yao Dongdong

result is always zero when comes here.

Signed-off-by [email protected]
---
 drivers/thermal/thermal_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/thermal_core.c +0 -0
index 5b7d466..19cac8e 100644
@@ -1568,8 +1568,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 
Quoted 8 lines

drivers/thermal/thermal_core.c struct thermal_zone_device *thermal_zone_device_register(const char *type, · line 1572

Quoted 6 lines
drivers/thermal/thermal_core.c +1 -2
    thermal_zone_device_update(tz);
 
-   if (!result)
-       return tz;
+   return tz;
 

Adding a return here will make the resource release below not reachable in the fail path.

But all fails above followed a "goto unregister", so i think it must be successful when come here.

Thanks.

Quoted 6 lines
Quoted 6 lines
drivers/thermal/thermal_core.c +0 -1
 unregister:
    release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
--

1.8.0.1

#3 lore raw

Hello Yao,

Quoted 21 lines · Yao Dongdong
Quoted 19 lines · Eduardo Valentin

Hello Yao

Quoted 16 lines · Yao Dongdong

result is always zero when comes here.

Signed-off-by [email protected]
---
 drivers/thermal/thermal_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/thermal_core.c +0 -0
index 5b7d466..19cac8e 100644
@@ -1568,8 +1568,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 
    thermal_zone_device_update(tz);
 
Quoted 8 lines
Quoted 6 lines

drivers/thermal/thermal_core.c struct thermal_zone_device *thermal_zone_device_register(const char *type, · line 1572

Quoted 4 lines
drivers/thermal/thermal_core.c +1 -2
-   if (!result)
-       return tz;
+   return tz;
 

Adding a return here will make the resource release below not reachable in the fail path.

But all fails above followed a "goto unregister", so i think it must be successful when come here.

Yes, I see your point. Agreed.

Quoted 11 lines

Thanks.

Quoted 6 lines
Quoted 6 lines
drivers/thermal/thermal_core.c +0 -1
 unregister:
    release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
--

1.8.0.1