OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_ch_socket.c versions 1.15 and 1.16
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_ch_socket.c 1.15 -> 1.16

--- l2_ch_socket.c       2001/09/06 14:43:25     1.15
+++ l2_ch_socket.c       2001/09/06 16:10:05     1.16
@@ -126,14 +126,10 @@
 /* configure channel */
 static l2_result_t hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
 {
-    l2_ch_socket_t *cfg;
+    l2_ch_socket_t *cfg = (l2_ch_socket_t *)ctx->vp;
     l2_param_t pa[4];
     l2_result_t rv;
 
-    /* parameter checks */
-    if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
-
     /* feed and call generic parameter parsing engine */
     L2_PARAM_SET(pa[0], ipversion, INT,     &cfg->iFamily);
     L2_PARAM_SET(pa[1], host,      CHARPTR, &cfg->pszHost);
@@ -147,15 +143,13 @@
 /* open channel */
 static l2_result_t hook_open(l2_context_t *ctx, l2_channel_t *ch)
 {
-    l2_ch_socket_t      *cfg;
+    l2_ch_socket_t *cfg = (l2_ch_socket_t *)ctx->vp;
     struct hostent      *pHostentry;
     struct sockaddr_in  IP4Sockaddr;
     struct sockaddr_in6 IP6Sockaddr;
     struct in6_addr     *IP6Addr;
 
-    /* parameter checks */
-    if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
+    /* make sure a target is configured */
     if (cfg->pszHost == NULL)
         return L2_ERR_USE;
 
@@ -245,13 +239,11 @@
 static l2_result_t hook_write(l2_context_t *ctx, l2_channel_t *ch, 
                       const char *buf, size_t buf_size)
 {
-    l2_ch_socket_t *cfg;
+    l2_ch_socket_t *cfg = (l2_ch_socket_t *)ctx->vp;
     size_t          sizeWrite;
     size_t          sizeRemain;
 
     /* parameter checks */
-    if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
     if (cfg->iSocket == -1)
         return L2_ERR_USE;
 
@@ -274,11 +266,9 @@
 /* close channel */
 static l2_result_t hook_close(l2_context_t *ctx, l2_channel_t *ch)
 {
-    l2_ch_socket_t *cfg;
+    l2_ch_socket_t *cfg = (l2_ch_socket_t *)ctx->vp;
 
     /* parameter checks */
-    if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
     if (cfg->iSocket == -1)
         return L2_ERR_USE;
 
@@ -292,12 +282,10 @@
 /* destroy channel */
 static l2_result_t hook_destroy(l2_context_t *ctx, l2_channel_t *ch)
 {
-    /* parameter checks */
-    if (ctx->vp == NULL) 
-        return L2_ERR_ARG;
+    l2_ch_socket_t *cfg = (l2_ch_socket_t *)ctx->vp;
 
     /* destroy channel configuration */
-    free(ctx->vp);
+    free(cfg);
 
     return L2_OK;
 }

CVSTrac 2.0.1