[hipl-commit] [tiny] Rev 3775: Removed pointless checks of packet type and ambiguous 'const' keyword.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Fri, 30 Apr 2010 20:01:23 +0300

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: 30/04/2010 at 20:01:23
Revision: 3775
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Removed pointless checks of packet type and ambiguous 'const' keyword.
  
  The checks if the message type exceeded the maximum value were pointless,
  because an unsinged int cannot be greater than 255 (the maximum packet type).
  
  Also removed the 'const' keyword in user handle function (de-)registration.

Modified:
  M  hipd/user.c
  M  hipd/user.h

=== modified file 'hipd/user.c'
--- hipd/user.c 2010-04-29 19:59:07 +0000
+++ hipd/user.c 2010-04-30 16:59:24 +0000
@@ -70,10 +70,6 @@
     int err = 0;
     struct usr_msg_handle *new_entry = NULL;
 
-    HIP_IFEL(msg_type > HIP_MSG_ROOT_MAX,
-             -1,
-             "Maximum message type exceeded.\n");
-
     HIP_IFEL(!(new_entry = malloc(sizeof(struct usr_msg_handle))),
              -1,
              "Error on allocating memory for a handle function entry.\n");
@@ -107,20 +103,11 @@
  *         Error   = -1
  */
 int hip_user_unregister_handle(const uint8_t msg_type,
-                               const int (*handle_func)(hip_common_t *msg,
-                                                        struct sockaddr_in6 
*src))
+                               int (*handle_func)(hip_common_t *msg,
+                                                  struct sockaddr_in6 *src))
 {
-    int err = 0;
-
-    HIP_IFEL(msg_type > HIP_MSG_ROOT_MAX,
-             -1,
-             "Maximum message type exceeded.\n");
-
-    err = lmod_unregister_function(hip_user_msg_handles[msg_type],
-                                   handle_func);
-
-out_err:
-    return err;
+    return lmod_unregister_function(hip_user_msg_handles[msg_type],
+                                    handle_func);
 }
 
 /**
@@ -142,13 +129,8 @@
                          hip_common_t *msg,
                          struct sockaddr_in6 *src)
 {
-    int            err  = 0;
     hip_ll_node_t *iter = NULL;
 
-    HIP_IFEL(msg_type > HIP_MSG_ROOT_MAX,
-             -1,
-             "Maximum message type exceeded.\n");
-
     if (!hip_user_msg_handles[msg_type] ||
         !hip_ll_get_size(hip_user_msg_handles[msg_type])) {
         HIP_DEBUG("User message (type: %d) not dynamically handled -> " \
@@ -162,8 +144,7 @@
         ((struct usr_msg_handle *) iter->ptr)->func_ptr(msg, src);
     }
 
-out_err:
-    return err;
+    return 0;
 }
 
 /**

=== modified file 'hipd/user.h'
--- hipd/user.h 2010-04-23 15:10:44 +0000
+++ hipd/user.h 2010-04-30 16:59:24 +0000
@@ -31,8 +31,8 @@
                                                 struct sockaddr_in6 *src),
                              const uint16_t priority);
 int hip_user_unregister_handle(const uint8_t msg_type,
-                               const int (*handle_func)(hip_common_t *msg,
-                                                        struct sockaddr_in6 
*src));
+                               int (*handle_func)(hip_common_t *msg,
+                                                  struct sockaddr_in6 *src));
 int hip_user_run_handles(const uint8_t msg_type,
                          hip_common_t *msg,
                          struct sockaddr_in6 *src);

Other related posts:

  • » [hipl-commit] [tiny] Rev 3775: Removed pointless checks of packet type and ambiguous 'const' keyword. - Tim Just