directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRAPI-303) If and else-if branches has the same condition
Date Tue, 26 Dec 2017 09:34:00 GMT

    [ https://issues.apache.org/jira/browse/DIRAPI-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16303685#comment-16303685
] 

Emmanuel Lecharny commented on DIRAPI-303:
------------------------------------------

Very true. The correct second test should be :

{code:java}
            else if ( ( bytes[pos] & UTF8_SIX_BYTES_MASK ) == UTF8_SIX_BYTES )
{code}

Fixed with commit 72af649a9a1e786e6f82535b8c617027199751f1

> If and else-if branches has the same condition
> ----------------------------------------------
>
>                 Key: DIRAPI-303
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-303
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-RC2
>            Reporter: songwanging
>
> Our tool DeepTect has detected a piece of buggy code snippet, in which the if and else
branches has the same condition.
> Path: directory-ldap-api/util/src/main/java/org/apache/directory/api/util/Unicode.java
> {code:java}
> public static char bytesToChar( byte[] bytes, int pos ){
> ...
>    else if ( ( bytes[pos] & UTF8_FIVE_BYTES_MASK ) == UTF8_FIVE_BYTES ){
>              // Five bytes char
>              ...
>     }
>    else if ( ( bytes[pos] & UTF8_FIVE_BYTES_MASK ) == UTF8_FIVE_BYTES ){
>                 // Six bytes char
>                  ...
>             }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message