diff -r 74853e018898 -r ed15eef57d5c master/pdo_list.c --- a/master/pdo_list.c Mon Nov 17 15:04:28 2008 +0000 +++ b/master/pdo_list.c Mon Nov 17 17:18:02 2008 +0000 @@ -116,8 +116,7 @@ /** Add a new Pdo to the list. * - * \retval >0 Pointer to new Pdo. - * \retval NULL No memory. + * \return Pointer to new Pdo, otherwise an ERR_PTR() code. */ ec_pdo_t *ec_pdo_list_add_pdo( ec_pdo_list_t *pl, /**< Pdo list. */ @@ -128,7 +127,7 @@ if (!(pdo = (ec_pdo_t *) kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { EC_ERR("Failed to allocate memory for Pdo.\n"); - return NULL; + return ERR_PTR(-ENOMEM); } ec_pdo_init(pdo); @@ -149,22 +148,24 @@ ) { ec_pdo_t *mapped_pdo; + int ret; // Pdo already mapped? list_for_each_entry(mapped_pdo, &pl->list, list) { if (mapped_pdo->index != pdo->index) continue; EC_ERR("Pdo 0x%04X is already mapped!\n", pdo->index); - return -1; + return -EEXIST; } if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { EC_ERR("Failed to allocate Pdo memory.\n"); - return -1; - } - - if (ec_pdo_init_copy(mapped_pdo, pdo)) { + return -ENOMEM; + } + + ret = ec_pdo_init_copy(mapped_pdo, pdo); + if (ret < 0) { kfree(mapped_pdo); - return -1; + return ret; } list_add_tail(&mapped_pdo->list, &pl->list); @@ -183,13 +184,15 @@ ) { ec_pdo_t *other_pdo; + int ret; ec_pdo_list_clear_pdos(pl); // Pdo already mapped? list_for_each_entry(other_pdo, &other->list, list) { - if (ec_pdo_list_add_pdo_copy(pl, other_pdo)) - return -1; + ret = ec_pdo_list_add_pdo_copy(pl, other_pdo); + if (ret) + return ret; } return 0;