Re: [PATCH v2 1/6] ACPI: dock: clean up error handling paths in dock_add()



Hi Alex,

On Wed, Oct 14, 2009 at 04:46:16PM -0600, Alex Chiang wrote:
Remove some copy/paste code in our error handling paths, which makes
the function smaller and slightly easier to read.

Changing individual attributes into attribute_group would greatly
simplify the code.


Signed-off-by: Alex Chiang <achiang@xxxxxx>
---

drivers/acpi/dock.c | 75 +++++++++++++++++++--------------------------------
1 files changed, 28 insertions(+), 47 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 7338b6a..642c7dd 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -968,11 +968,9 @@ static int dock_add(acpi_handle handle)
platform_device_register_simple(dock_device_name,
dock_station_count, NULL, 0);
dock_device = dock_station->dock_device;
- if (IS_ERR(dock_device)) {
- kfree(dock_station);
- dock_station = NULL;
- return PTR_ERR(dock_device);
- }
+ ret = IS_ERR(dock_device) ? PTR_ERR(dock_device) : 0;
+ if (ret)
+ goto out;

I think

if (IS_ERR(dock_device)) {
ret = PTR_ERR(dock_device);
goto out;
}

is more commonly used form.

Thanks.

--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH 10/10] x86: Unify percpu.h
    ... earlier patches and so its justifiable to put them together to simplify ... the next patchset. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [PATCH 4/4] Staging: zram: simplify zram_make_request
    ... void to simplify the code. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • [PATCH 1/9 v2] staging: dt3155: check put_user() return value
    ... To simplify the code ... fill local struct dt3155_read with data and copy it with single ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • [PATCH 1/9 v3] staging: dt3155: check put_user() return value
    ... To simplify the code ... fill local struct dt3155_read with data and copy it with single ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: vector and for-loop
    ... Kitty wrote: ... >>Is it possible to further simplify and improve the speed of the above ... C++ Faq: http://www.parashift.com/c++-faq-lite C Faq: http://www.eskimo.com/~scs/c-faq/top.html alt.comp.lang.learn.c-c++ faq: ... Other sites: http://www.josuttis.com -- C++ STL Library book http://www.sgi.com/tech/stl -- Standard Template Library ...
    (comp.lang.cpp)