[hipl-commit] [tiny] Rev 3577: Removed casts of malloc return values and several style changes.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 25 Feb 2010 19:32:22 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Thu Feb 25 18:31:28 2010 +0100
Revision: 3577
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Removed casts of malloc return values and several style changes.

Modified:
  M  lib/modularization/modularization.c
  M  modules/update/hipd/update.c

=== modified file 'lib/modularization/modularization.c'
--- lib/modularization/modularization.c 2010-02-25 15:43:37 +0000
+++ lib/modularization/modularization.c 2010-02-25 17:31:28 +0000
@@ -67,15 +67,14 @@
              "Maximum host association state exceeded.\n");
 
     if (!handle_functions[packet_type][ha_state]) {
-        HIP_IFEL(((new_func_list = (hip_ll_t *) malloc(sizeof(hip_ll_t))) == 
NULL),
+        HIP_IFEL(((new_func_list = malloc(sizeof(hip_ll_t))) == NULL),
                  -1,
                  "Error on allocating memory for a linked list.\n");
         hip_ll_init(new_func_list);
         handle_functions[packet_type][ha_state] = new_func_list;
     }
 
-    HIP_IFEL(((handle_func = (struct handle_func_entry *)
-                             malloc(sizeof(struct handle_func_entry))) == 
NULL),
+    HIP_IFEL(((handle_func = malloc(sizeof(struct handle_func_entry))) == 
NULL),
              -1,
              "Error on allocating memory for a linked list.\n");
 
@@ -83,7 +82,7 @@
     handle_func->priority    = priority;
 
     /* Iterate through handle functions until the desired position is found */
-    while((iter = hip_ll_iterate(handle_functions[packet_type][ha_state], 
iter)) != NULL) {
+    while ((iter = hip_ll_iterate(handle_functions[packet_type][ha_state], 
iter)) != NULL) {
         if (priority < ((struct handle_func_entry *) iter->ptr)->priority) {
             break;
         } else {
@@ -130,7 +129,7 @@
     }
 
     /* Iterate through handle functions until the desired function is found */
-    while((iter = hip_ll_iterate(handle_functions[packet_type][ha_state], 
iter)) != NULL) {
+    while ((iter = hip_ll_iterate(handle_functions[packet_type][ha_state], 
iter)) != NULL) {
         if (handle_function == ((struct handle_func_entry *) 
iter->ptr)->handle_func) {
             hip_ll_del(handle_functions[packet_type][ha_state], index, free);
             break;
@@ -174,7 +173,7 @@
 
     list = handle_functions[packet_type][ha_state];
 
-    while((iter = hip_ll_iterate(list, iter)) != NULL) {
+    while ((iter = hip_ll_iterate(list, iter)) != NULL) {
         ((struct handle_func_entry *) iter->ptr)->handle_func(packet_type,
                                                               ha_state,
                                                               ctx);
@@ -218,12 +217,12 @@
 {
     struct modular_state *state;
 
-    if ((state = (struct modular_state*) malloc(sizeof(struct modular_state))) 
== NULL) {
+    if ((state = malloc(sizeof(struct modular_state))) == NULL) {
         HIP_ERROR("Error on allocating memory for a modular_state 
instance.\n");
         return NULL;
     }
 
-    if ((state->item_list = (hip_ll_t*) malloc(sizeof(hip_ll_t))) == NULL) {
+    if ((state->item_list = malloc(sizeof(hip_ll_t))) == NULL) {
         HIP_ERROR("Error on allocating memory for a linked list.\n");
         return NULL;
     }
@@ -254,7 +253,7 @@
     HIP_IFEL(!func, -1, "Invalid init function provided");
 
     if (!state_init_functions) {
-        HIP_IFEL(((new_func_list = (hip_ll_t *) malloc(sizeof(hip_ll_t))) == 
NULL),
+        HIP_IFEL(((new_func_list = malloc(sizeof(hip_ll_t))) == NULL),
                  -1,
                  "Error on allocating memory for a linked list.\n");
         hip_ll_init(new_func_list);
@@ -283,7 +282,7 @@
     hip_ll_node_t *iter = NULL;
     int (*init_function)(struct modular_state *state) = NULL;
 
-    while((iter = hip_ll_iterate(state_init_functions, iter)) != NULL) {
+    while ((iter = hip_ll_iterate(state_init_functions, iter)) != NULL) {
         init_function = iter->ptr;
         init_function(state);
     }

=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c        2010-02-25 15:43:37 +0000
+++ modules/update/hipd/update.c        2010-02-25 17:31:28 +0000
@@ -897,16 +897,15 @@
     int err = 0;
     struct update_state *update_state;
 
-    HIP_IFEL((update_state = (struct update_state*)
-                             malloc(sizeof(struct update_state))) == NULL,
+    HIP_IFEL((update_state = malloc(sizeof(struct update_state))) == NULL,
              -1,
              "Error on allocating memory for a update state instance.\n");
 
-    update_state->update_state     = 0;
-    update_state->hadb_update_func = NULL;
+    update_state->update_state                   = 0;
+    update_state->hadb_update_func               = NULL;
     update_state->addresses_to_send_echo_request = hip_linked_list_init();
-    update_state->update_id_out    = 0;
-    update_state->update_id_in     = 0;
+    update_state->update_id_out                  = 0;
+    update_state->update_id_in                   = 0;
 
     err = hip_add_state_item(state, update_state, "update");

Other related posts:

  • » [hipl-commit] [tiny] Rev 3577: Removed casts of malloc return values and several style changes. - Tim Just