https://issues.apache.org/bugzilla/show_bug.cgi?id=56878

            Bug ID: 56878
           Summary: Checking whether unsigned int is less than zero is
                    useless
           Product: Tomcat Native
           Version: 1.1.31
          Hardware: PC
                OS: Mac OS X 10.4
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: Library
          Assignee: dev@tomcat.apache.org
          Reporter: ch...@christopherschultz.net

I just saw this when compiling with clang on Mac OS X (partially because clang
shows all warnings and errors in BIG BOLD SUPER HIGHLIGHTED TEXT!):

src/jnilib.c:130:11: warning: comparison of unsigned expression < 0 is always
      false [-Wtautological-compare]
    if (l < 0)
        ~ ^ ~
1 warning generated.

I checked, and the function [jstring tcn_new_stringn(JNIEnv *env, const char
*str, size_t l)] accepts an argument of size_t and then checks to see if it is
less than 0. Since it's unsigned, it will never be negative.

I checked, and this function is not even used in the tcnative library itself.

Looking at similar functions, I can see that tcn_new_stringn actually checks
the Java runtime to see if new references can be created in the local scope and
fails if it can't. The other similar functions do not do such checking, and are
therefore fragile.

I think it makes sense to review these functions to decide what functions to
eliminate (e.g. tcn_new_stringn) and to what extent will the code in tcnative
do diligent sanity checking rather than letting the runtime fail in various
ways.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to