[openib-general] [PATCH][kdapl] Small changes in dapl_hca_alloc/dapl_hca_free functions
James Lentini
jlentini at netapp.com
Wed Jun 22 10:04:22 PDT 2005
Committed in revision 2677.
On Mon, 20 Jun 2005, Itamar Rabenstein wrote:
itamar> Small changes in dapl_hca_alloc/dapl_hca_free function
itamar>
itamar> Signed-off-by: Itamar Rabenstein <itamar at mellanox.co.il>
itamar>
itamar> diff -Nurp -X dontdiff dat-provider_hash/dapl_hca_util.c dat-provider/dapl_hca_util.c
itamar> --- dat-provider_hash/dapl_hca_util.c Sun Jun 19 16:12:55 2005
itamar> +++ dat-provider/dapl_hca_util.c Sun Jun 19 16:30:07 2005
itamar> @@ -54,23 +54,18 @@
itamar> struct dapl_hca *dapl_hca_alloc(char *name, struct ib_device *device, u8 port)
itamar> {
itamar> struct dapl_hca *hca;
itamar> -
itamar> - hca = kmalloc(sizeof *hca, GFP_ATOMIC);
itamar> + int malloc_size = sizeof *hca + strlen(name) + 1;
itamar> +
itamar> + hca = kmalloc(malloc_size, GFP_ATOMIC);
itamar> if (hca) {
itamar> - memset(hca, 0, sizeof *hca);
itamar> -
itamar> + memset(hca, 0, malloc_size);
itamar> spin_lock_init(&hca->lock);
itamar> INIT_LIST_HEAD(&hca->ia_list);
itamar> -
itamar> - hca->name = dapl_os_strdup(name);
itamar> + hca->name = (char *)hca + sizeof *hca;
itamar> + strcpy(hca->name, name);
itamar> hca->ib_hca_handle = device;
itamar> hca->port_num = port;
itamar> - if (hca->name == NULL) {
itamar> - kfree(hca);
itamar> - hca = NULL;
itamar> - }
itamar> }
itamar> -
itamar> return hca;
itamar> }
itamar>
itamar> @@ -91,7 +86,6 @@ struct dapl_hca *dapl_hca_alloc(char *na
itamar> */
itamar> void dapl_hca_free(struct dapl_hca *hca)
itamar> {
itamar> - kfree(hca->name);
itamar> kfree(hca);
itamar> }
itamar>
itamar> diff -Nurp -X dontdiff dat-provider_hash/dapl_util.h dat-provider/dapl_util.h
itamar> --- dat-provider_hash/dapl_util.h Sun Jun 19 16:12:56 2005
itamar> +++ dat-provider/dapl_util.h Sun Jun 19 16:30:52 2005
itamar> @@ -121,18 +121,6 @@ static inline void *dapl_os_realloc(void
itamar> }
itamar>
itamar> /*
itamar> - * String Functions
itamar> - */
itamar> -
itamar> -static inline char *dapl_os_strdup(const char *str)
itamar> -{
itamar> - char *ns = kmalloc(strlen(str) + 1, GFP_KERNEL);
itamar> - if (ns)
itamar> - strcpy(ns, str);
itamar> - return ns;
itamar> -}
itamar> -
itamar> -/*
itamar> * *printf format helper. We use the C string constant concatenation
itamar> * ability to define 64 bit formats, which unfortunatly are non standard
itamar> * in the C compiler world.
itamar> --
itamar> Itamar
itamar> _______________________________________________
itamar> openib-general mailing list
itamar> openib-general at openib.org
itamar> http://openib.org/mailman/listinfo/openib-general
itamar>
itamar> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
itamar>
More information about the general
mailing list