harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Hindess (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-6459) [classlib] [portlib] unix/hysock.c hysock_sockaddr_init6 has redundant code
Date Mon, 01 Mar 2010 10:06:06 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-6459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12839628#action_12839628
] 

Mark Hindess commented on HARMONY-6459:
---------------------------------------

Also, the use of "struct sockaddr_in6" is odd in this context since (most of) the rest of
the code uses the "OSSOCKADDR_IN6" define for this structure.  For consistency, it probably
makes sense to replace "struct sockaddr_in6" with "OSSOCKADDR_IN6" throughout this file. 
Similarly for the non-IPv6 "struct sockaddr_in"/"OSSOCKADDR_IN".


> [classlib] [portlib] unix/hysock.c hysock_sockaddr_init6 has redundant code
> ---------------------------------------------------------------------------
>
>                 Key: HARMONY-6459
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6459
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 6.0M1, 5.0M13
>            Reporter: Mark Hindess
>            Assignee: Mark Hindess
>             Fix For: 6.0M2, 5.0M14
>
>
> hysock_sockaddr_init6 has code like:
>   memset (handle, 0, sizeof (struct hysockaddr_struct));
>   if (...) {
>     ...
>   } else { # IPv6
>     sockaddr_6 = (OSSOCKADDR_IN6 *) & handle->addr;
>     ...
>     sockaddr_6->sin6_len = sizeof (struct sockaddr_in6);
>     if (((OSSOCKADDR_IN6 *) & handle->addr)->sin6_len != 0) {
>       sockaddr_6->sin6_len = ((OSSOCKADDR_IN6 *) & handle->addr)->sin6_len;
>     }
> The content of the last if looks bogus because "sockaddr_6" is equivalent to "((OSSOCKADDR_IN6
*) & handle->addr)" (by virtue of the first line of the else) so the left-hand side
and right-hand side are the same field.  Also, because of the same equivalence of the two
structures, the sin6_len if is always executed since sin6_len field is assigned a non-zero
value on the preceding line.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message