The following issues were found

site_scons/site_tools/compilation_db.py
33 issues
Unable to import 'SCons'
Error

Line: 24 Column: 1

              #

import json
import SCons
import itertools

# Implements the ability for SCons to emit a compilation database for the MongoDB project. See
# http://clang.llvm.org/docs/JSONCompilationDatabase.html for details on what a compilation
# database is, and why you might want one. The only user visible entry point here is

            

Reported by Pylint.

TODO: Is there a better way to do this than this global? Right now this exists so that the
Error

Line: 34 Column: 3

              # should hold the compilation database, otherwise, the file defaults to compile_commands.json,
# which is the name that most clang tools search for by default.

# TODO: Is there a better way to do this than this global? Right now this exists so that the
# emitter we add can record all of the things it emits, so that the scanner for the top level
# compilation database can access the complete list, and also so that the writer has easy
# access to write all of the files. But it seems clunky. How can the emitter and the scanner
# communicate more gracefully?
__COMPILATION_DB_ENTRIES = []

            

Reported by Pylint.

Unused argument 'target'
Error

Line: 60 Column: 42

                      self.Decider(changed_since_last_build_node)


def changed_since_last_build_node(child, target, prev_ni, node):
    """ Dummy decider to force always building"""
    return True


def makeEmitCompilationDbEntry(comstr):

            

Reported by Pylint.

Unused argument 'child'
Error

Line: 60 Column: 35

                      self.Decider(changed_since_last_build_node)


def changed_since_last_build_node(child, target, prev_ni, node):
    """ Dummy decider to force always building"""
    return True


def makeEmitCompilationDbEntry(comstr):

            

Reported by Pylint.

Unused argument 'prev_ni'
Error

Line: 60 Column: 50

                      self.Decider(changed_since_last_build_node)


def changed_since_last_build_node(child, target, prev_ni, node):
    """ Dummy decider to force always building"""
    return True


def makeEmitCompilationDbEntry(comstr):

            

Reported by Pylint.

Unused argument 'node'
Error

Line: 60 Column: 59

                      self.Decider(changed_since_last_build_node)


def changed_since_last_build_node(child, target, prev_ni, node):
    """ Dummy decider to force always building"""
    return True


def makeEmitCompilationDbEntry(comstr):

            

Reported by Pylint.

Access to a protected member __COMPILATIONDB_Entry of a client class
Error

Line: 88 Column: 17

              
        dbtarget = __CompilationDbNode(source)

        entry = env.__COMPILATIONDB_Entry(
            target=dbtarget,
            source=[],
            __COMPILATIONDB_UTARGET=target,
            __COMPILATIONDB_USOURCE=source,
            __COMPILATIONDB_UACTION=user_action,

            

Reported by Pylint.

TODO: Technically, these next two lines should not be required: it should be fine to
Error

Line: 97 Column: 3

                          __COMPILATIONDB_ENV=env,
        )

        # TODO: Technically, these next two lines should not be required: it should be fine to
        # cache the entries. However, they don't seem to update properly. Since they are quick
        # to re-generate disable caching and sidestep this problem.
        env.AlwaysBuild(entry)
        env.NoCache(entry)


            

Reported by Pylint.

Unused argument 'source'
Error

Line: 110 Column: 38

                  return EmitCompilationDbEntry


def CompilationDbEntryAction(target, source, env, **kw):
    """
    Create a dictionary with evaluated command line, target, source
    and store that info as an attribute on the target
    (Which has been stored in __COMPILATION_DB_ENTRIES array
    :param target: target node(s)

            

Reported by Pylint.

Unused argument 'kw'
Error

Line: 110 Column: 1

                  return EmitCompilationDbEntry


def CompilationDbEntryAction(target, source, env, **kw):
    """
    Create a dictionary with evaluated command line, target, source
    and store that info as an attribute on the target
    (Which has been stored in __COMPILATION_DB_ENTRIES array
    :param target: target node(s)

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_join06.py
33 issues
Unable to import 'wiredtiger'
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import os
import wiredtiger, wttest, run
from wtscenario import make_scenarios

# test_join06.py
#    Join operations
# Joins with a read-uncommitted

            

Reported by Pylint.

Unused import os
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import os
import wiredtiger, wttest, run
from wtscenario import make_scenarios

# test_join06.py
#    Join operations

            

Reported by Pylint.

Unused import run
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import os
import wiredtiger, wttest, run
from wtscenario import make_scenarios

# test_join06.py
#    Join operations
# Joins with a read-uncommitted

            

Reported by Pylint.

TODO: needed?
Error

Line: 81 Column: 3

              
        self.populate(self.session, self.gen_values)

        # TODO: needed?
        #self.reopen_conn()

        if self.isolation != '':
            self.session.begin_transaction('isolation=' + self.isolation)


            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 90 Column: 9

                      jc = self.session.open_cursor('join:table:join06', None, None)
        c0 = self.session.open_cursor('index:join06:index0', None, None)
        c0.set_key('520')
        self.assertEquals(0, c0.search())
        self.session.join(jc, c0, 'compare=ge')

        joinconfig = 'compare=eq'
        if self.bloom:
            joinconfig += ',strategy=bloom,count=1000'

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 98 Column: 9

                          joinconfig += ',strategy=bloom,count=1000'
        c1 = self.session.open_cursor('index:join06:index1', None, None)
        c1.set_key('555')
        self.assertEquals(0, c1.search())
        self.session.join(jc, c1, joinconfig)

        if self.isolation == 'read-uncommitted' and self.bloom:
            # Make sure that read-uncommitted with Bloom is not allowed.
            # This is detected on the first next() operation.

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 106 Column: 17

                          # This is detected on the first next() operation.
            msg = '/cannot be used with read-uncommitted/'
            self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
                lambda: jc.next(), msg)
            return

        # Changes made in another session may or may not be visible to us,
        # depending on the isolation level.
        if self.isolation == 'read-uncommitted':

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 126 Column: 17

                          [v0,v1] = jc.get_values()
            #self.tty('GOT: ' + str(k) + ': ' + str(jc.get_values()))
            if altered and self.isolation == 'read-uncommitted':
                self.assertEquals(self.gen_values2(k), [v0, v1])
            else:
                self.assertEquals(self.gen_values(k), [v0, v1])
            if not k in mbr:
                self.tty('**** ERROR: result ' + str(k) + ' is not in: ' +
                         str(mbr))

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 128 Column: 17

                          if altered and self.isolation == 'read-uncommitted':
                self.assertEquals(self.gen_values2(k), [v0, v1])
            else:
                self.assertEquals(self.gen_values(k), [v0, v1])
            if not k in mbr:
                self.tty('**** ERROR: result ' + str(k) + ' is not in: ' +
                         str(mbr))
            self.assertTrue(k in mbr)
            mbr.remove(k)

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 149 Column: 9

              
        if len(mbr) != 0:
            self.tty('**** ERROR: did not see these: ' + str(mbr))
        self.assertEquals(0, len(mbr))

        jc.close()
        c1.close()
        c0.close()
        if self.isolation != '':

            

Reported by Pylint.

src/third_party/zstandard-1.4.4/zstd/tests/bigdict.c
33 issues
Memory leak: out
Error

Line: 82 CWE codes: 401

                  }

    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, 31)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))

            

Reported by Cppcheck.

Memory leak: buffer
Error

Line: 82 CWE codes: 401

                  }

    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, 31)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))

            

Reported by Cppcheck.

Memory leak: roundtrip
Error

Line: 82 CWE codes: 401

                  }

    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, 31)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))

            

Reported by Cppcheck.

Memory leak: roundtrip
Error

Line: 84 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, 31)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))

            

Reported by Cppcheck.

Memory leak: out
Error

Line: 84 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, 31)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))

            

Reported by Cppcheck.

Memory leak: buffer
Error

Line: 84 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, 31)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))

            

Reported by Cppcheck.

Memory leak: out
Error

Line: 86 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetLength, 7)))

            

Reported by Cppcheck.

Memory leak: buffer
Error

Line: 86 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetLength, 7)))

            

Reported by Cppcheck.

Memory leak: roundtrip
Error

Line: 86 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetLength, 7)))

            

Reported by Cppcheck.

Memory leak: roundtrip
Error

Line: 88 CWE codes: 401

                  if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_overlapLog, 9)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 1)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btopt)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetLength, 7)))
        return 1;
    if (ZSTD_isError(ZSTD_CCtx_setParameter(cctx, ZSTD_c_minMatch, 7)))

            

Reported by Cppcheck.

src/third_party/icu4c-57.1/source/common/putil.cpp
33 issues
readlink - This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL.
Security

Line: 1022 Column: 32 CWE codes: 362 20
Suggestion: Reconsider approach

                      because the tzfile contents is underspecified.
        This isn't guaranteed to work because it may not be a symlink.
        */
        int32_t ret = (int32_t)readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer));
        if (0 < ret) {
            int32_t tzZoneInfoLen = uprv_strlen(TZZONEINFO);
            gTimeZoneBuffer[ret] = 0;
            if (uprv_strncmp(gTimeZoneBuffer, TZZONEINFO, tzZoneInfoLen) == 0
                && isValidOlsonID(gTimeZoneBuffer + tzZoneInfoLen))

            

Reported by FlawFinder.

strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 1876 Column: 5 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                  static char codepage[64];

    strncpy(codepage, nl_langinfo(CODESET),63-strlen(UCNV_SWAP_LFNL_OPTION_STRING));
    strcat(codepage,UCNV_SWAP_LFNL_OPTION_STRING);
    codepage[63] = 0; /* NULL terminate */

    return codepage;

#elif U_PLATFORM_USES_ONLY_WIN32_API

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 249 Column: 34 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                  umtx_lock(&fakeClockMutex);
    if(!fakeClock_set) {
        UDate real = getUTCtime_real();
        const char *fake_start = getenv("U_FAKETIME_START");
        if((fake_start!=NULL) && (fake_start[0]!=0)) {
            sscanf(fake_start,"%lf",&fakeClock_t0);
            fakeClock_dt = fakeClock_t0 - real;
            fprintf(stderr,"U_DEBUG_FAKETIME was set at compile time, so the ICU clock will start at a preset value\n"
                    "env variable U_FAKETIME_START=%.0f (%s) for an offset of %.0f ms from the current time %.0f\n",

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 818 Column: 68 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

              {
    int32_t idx;
#ifdef DEBUG_TZNAME
    fprintf(stderr, "TZ=%s std=%s dst=%s daylight=%d offset=%d\n", getenv("TZ"), stdID, dstID, daylightType, offset);
#endif
    for (idx = 0; idx < UPRV_LENGTHOF(OFFSET_ZONE_MAPPINGS); idx++)
    {
        if (offset == OFFSET_ZONE_MAPPINGS[idx].offsetSeconds
            && daylightType == OFFSET_ZONE_MAPPINGS[idx].daylightType

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 996 Column: 12 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

              
/* This code can be temporarily disabled to test tzname resolution later on. */
#ifndef DEBUG_TZNAME
    tzid = getenv("TZ");
    if (tzid != NULL && isValidOlsonID(tzid)
#if U_PLATFORM == U_PF_SOLARIS
    /* When TZ equals localtime on Solaris, check the /etc/localtime file. */
        && uprv_strcmp(tzid, TZ_ENV_CHECK) != 0
#endif

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 1257 Column: 10 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                  */
#   if !defined(ICU_NO_USER_DATA_OVERRIDE) && !UCONFIG_NO_FILE_IO
    /* First try to get the environment variable */
    path=getenv("ICU_DATA");
#   endif

    /* ICU_DATA_DIR may be set as a compile option.
     * U_ICU_DATA_DEFAULT_DIR is provided and is set by ICU at compile time
     * and is used only when data is built in archive mode eliminating the need

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 1270 Column: 30 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

              #if defined(ICU_DATA_DIR) || defined(U_ICU_DATA_DEFAULT_DIR)
    if(path==NULL || *path==0) {
# if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
        const char *prefix = getenv(ICU_DATA_DIR_PREFIX_ENV_VAR);
# endif
# ifdef ICU_DATA_DIR
        path=ICU_DATA_DIR;
# else
        path=U_ICU_DATA_DEFAULT_DIR;

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 1326 Column: 23 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                      status = U_MEMORY_ALLOCATION_ERROR;
        return;
    }
    const char *dir = getenv("ICU_TIMEZONE_FILES_DIR");
#if defined(U_TIMEZONE_FILES_DIR)
    if (dir == NULL) {
        dir = TO_STRING(U_TIMEZONE_FILES_DIR);
    }
#endif

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 1389 Column: 23 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                          || (uprv_strcmp("POSIX", posixID) == 0))
        {
            /* Maybe we got some garbage.  Try something more reasonable */
            posixID = getenv("LC_ALL");
            /* Solaris speaks POSIX -  See IEEE Std 1003.1-2008 
             * This is needed to properly handle empty env. variables
             */
#if U_PLATFORM == U_PF_SOLARIS
            if ((posixID == 0) || (posixID[0] == '\0')) {

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 1395 Column: 27 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                           */
#if U_PLATFORM == U_PF_SOLARIS
            if ((posixID == 0) || (posixID[0] == '\0')) {
                posixID = getenv(category == LC_MESSAGES ? "LC_MESSAGES" : "LC_CTYPE");
                if ((posixID == 0) || (posixID[0] == '\0')) {
#else
            if (posixID == 0) {
                posixID = getenv(category == LC_MESSAGES ? "LC_MESSAGES" : "LC_CTYPE");
                if (posixID == 0) {

            

Reported by FlawFinder.

src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid128_pow.c
33 issues
Shifting 32-bit value by 49 bits is undefined behaviour
Error

Line: 930 CWE codes: 758

                is_odd = 0;

  if (is_int)
   { int e = ((y_int.w[BID_HIGH_128W] >> 49) & ((1ull<<14)-1));
     if ((e == 6176) && (y_int.w[BID_LOW_128W] & 1)) is_odd = 1;
   }

// Now the cases where the first arg is infinite:
//

            

Reported by Cppcheck.

Shifting 32-bit value by 49 bits is undefined behaviour
Error

Line: 1000 CWE codes: 758

              // Unpack the number, but check canonicality or plain zero
// and return -inf in that case.

  e = ((xa.w[BID_HIGH_128W] >> 49) & ((1ull<<14)-1)) - 6176;
  c.w[1] = xa.w[BID_HIGH_128W] & ((1ull<<49)-1);
  c.w[0] = xa.w[BID_LOW_128W];
  k = clz128(c.w[1],c.w[0]);
  sll128(c.w[1],c.w[0],k);
  k = 128 - k;

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 1010 CWE codes: 758

              // Start out our result as e * log(10) + k * log(2)
// Note that k is always positive, but e may have either sign

  __mul_64x192_to_192(ans,(BID_UINT64) k,bid_log_2_entry);
  if (e >= 0)
   { __mul_64x192_to_192(loc,(BID_UINT64) e,bid_log_10_entry);
     __add_192_192(ans,ans,loc);
   }
  else

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 1012 CWE codes: 758

              
  __mul_64x192_to_192(ans,(BID_UINT64) k,bid_log_2_entry);
  if (e >= 0)
   { __mul_64x192_to_192(loc,(BID_UINT64) e,bid_log_10_entry);
     __add_192_192(ans,ans,loc);
   }
  else
   { __mul_64x192_to_192(loc,(BID_UINT64)(-e),bid_log_10_entry);
     __sub_192_192(ans,ans,loc);

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 1016 CWE codes: 758

                   __add_192_192(ans,ans,loc);
   }
  else
   { __mul_64x192_to_192(loc,(BID_UINT64)(-e),bid_log_10_entry);
     __sub_192_192(ans,ans,loc);
   }

// Pick out toplevel bitfield and find its approximate reciprocal
// After this multiplication the result (considered as a fraction)

            

Reported by Cppcheck.

Shifting 32-bit value by 56 bits is undefined behaviour
Error

Line: 1024 CWE codes: 758

              // After this multiplication the result (considered as a fraction)
// is 1/2 * (1 - e) where 0 <= e <= 2^-7

  b = c.w[1] >> 56;
  r1 = bid_recip_table_1[b-128];
  __mul_64x128_to_192(p,r1,c);
  __sub_192_192(ans,ans,bid_log_table_1[b-128]);

// Now the next stage in this bipartite arrangment.

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 1026 CWE codes: 758

              
  b = c.w[1] >> 56;
  r1 = bid_recip_table_1[b-128];
  __mul_64x128_to_192(p,r1,c);
  __sub_192_192(ans,ans,bid_log_table_1[b-128]);

// Now the next stage in this bipartite arrangment.
// After this the result (considered as a fraction) is
// 1/4 * (1 - e) where 0 <= e < 2^-12 (maybe 2^-13, I should check)

            

Reported by Cppcheck.

Shifting 32-bit value by 49 bits is undefined behaviour
Error

Line: 1033 CWE codes: 758

              // After this the result (considered as a fraction) is
// 1/4 * (1 - e) where 0 <= e < 2^-12 (maybe 2^-13, I should check)

  b = (p.w[2] >> 49) & 0x7F;
  r2 = bid_recip_table_2[b];
  __mul_64x192_to_256(q,r2,p);
  __sub_192_192(ans,ans,bid_log_table_2[b]);

// Complement and shift back by 2 bits to get a proper binary fraction

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 1035 CWE codes: 758

              
  b = (p.w[2] >> 49) & 0x7F;
  r2 = bid_recip_table_2[b];
  __mul_64x192_to_256(q,r2,p);
  __sub_192_192(ans,ans,bid_log_table_2[b]);

// Complement and shift back by 2 bits to get a proper binary fraction

  sll192_short(q.w[3],q.w[2],q.w[1],2);

            

Reported by Cppcheck.

Shifting 32-bit value by 62 bits is undefined behaviour
Error

Line: 1040 CWE codes: 758

              
// Complement and shift back by 2 bits to get a proper binary fraction

  sll192_short(q.w[3],q.w[2],q.w[1],2);
  q.w[3] = ~q.w[3], q.w[2] = ~q.w[2], q.w[1] = ~q.w[1];

// Now compute the power series
// Should use Remez and maybe something shorter?


            

Reported by Cppcheck.

src/third_party/wiredtiger/dist/prototypes.py
33 issues
Redefining built-in 'list'
Error

Line: 8 Column: 16

              from dist import compare_srcfile, format_srcfile, source_files

# Build function prototypes from a list of files.
def prototypes(list, name):
    s = open(name, 'r').read()
    for p in re.findall(r'\n[A-Za-z_].*\n__wt_[^{]*', s):
        l = p.strip()

        # Ignore statics in XXX.c files.

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 58 Column: 1

                  p = []
    for name in source_files():
        if not fnmatch.fnmatch(name, '*.c') + fnmatch.fnmatch(name, '*_inline.h'):
                continue;
        if fnmatch.fnmatch(name, '*/checksum/arm64/*'):
            continue
        if fnmatch.fnmatch(name, '*/checksum/power8/*'):
            continue
        if fnmatch.fnmatch(name, '*/checksum/zseries/*'):

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 80 Column: 1

                  p = []
    for name in source_files():
        if not fnmatch.fnmatch(name, '*.c') + fnmatch.fnmatch(name, '*_inline.h'):
                continue;
        if not fnmatch.fnmatch(name, '*/os_posix/*'):
            continue
        prototypes(p, name)

    output(p, "../src/include/extern_posix.h")

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 92 Column: 1

                  p = []
    for name in source_files():
        if not fnmatch.fnmatch(name, '*.c') + fnmatch.fnmatch(name, '*_inline.h'):
                continue;
        if not fnmatch.fnmatch(name, '*/os_win/*'):
            continue
        prototypes(p, name)

    output(p, "../src/include/extern_win.h")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python

# Generate WiredTiger function prototypes.
import fnmatch, re
from dist import compare_srcfile, format_srcfile, source_files

# Build function prototypes from a list of files.
def prototypes(list, name):
    s = open(name, 'r').read()

            

Reported by Pylint.

Multiple imports on one line (fnmatch, re)
Error

Line: 4 Column: 1

              #!/usr/bin/env python

# Generate WiredTiger function prototypes.
import fnmatch, re
from dist import compare_srcfile, format_srcfile, source_files

# Build function prototypes from a list of files.
def prototypes(list, name):
    s = open(name, 'r').read()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              from dist import compare_srcfile, format_srcfile, source_files

# Build function prototypes from a list of files.
def prototypes(list, name):
    s = open(name, 'r').read()
    for p in re.findall(r'\n[A-Za-z_].*\n__wt_[^{]*', s):
        l = p.strip()

        # Ignore statics in XXX.c files.

            

Reported by Pylint.

Variable name "s" doesn't conform to snake_case naming style
Error

Line: 9 Column: 5

              
# Build function prototypes from a list of files.
def prototypes(list, name):
    s = open(name, 'r').read()
    for p in re.findall(r'\n[A-Za-z_].*\n__wt_[^{]*', s):
        l = p.strip()

        # Ignore statics in XXX.c files.
        if fnmatch.fnmatch(name, "*.c") and 'static' in l:

            

Reported by Pylint.

Variable name "p" doesn't conform to snake_case naming style
Error

Line: 10 Column: 9

              # Build function prototypes from a list of files.
def prototypes(list, name):
    s = open(name, 'r').read()
    for p in re.findall(r'\n[A-Za-z_].*\n__wt_[^{]*', s):
        l = p.strip()

        # Ignore statics in XXX.c files.
        if fnmatch.fnmatch(name, "*.c") and 'static' in l:
                continue

            

Reported by Pylint.

Variable name "l" doesn't conform to snake_case naming style
Error

Line: 11 Column: 9

              def prototypes(list, name):
    s = open(name, 'r').read()
    for p in re.findall(r'\n[A-Za-z_].*\n__wt_[^{]*', s):
        l = p.strip()

        # Ignore statics in XXX.c files.
        if fnmatch.fnmatch(name, "*.c") and 'static' in l:
                continue


            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_jsondump02.py
33 issues
Unable to import 'wiredtiger'
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import os, sys
import wiredtiger, wttest
from suite_subprocess import suite_subprocess

# test_jsondump.py
# Test dump output from json cursors.
class test_jsondump02(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

Unused import sys
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import os, sys
import wiredtiger, wttest
from suite_subprocess import suite_subprocess

# test_jsondump.py
# Test dump output from json cursors.

            

Reported by Pylint.

Unused import os
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import os, sys
import wiredtiger, wttest
from suite_subprocess import suite_subprocess

# test_jsondump.py
# Test dump output from json cursors.

            

Reported by Pylint.

Unused variable 'pos'
Error

Line: 83 Column: 9

                  # Check the result of using a JSON cursor on the URI.
    def load_json(self, uri, inserts):
        cursor = self.session.open_cursor(uri, None, 'dump=json')
        pos = 0
        try:
            for insert in inserts:
                cursor[insert[0]] = insert[1]
        finally:
            cursor.close()

            

Reported by Pylint.

Cell variable uni defined in loop
Error

Line: 205 Column: 23

                          self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
                lambda: self.load_json(self.table_uri2,
                  (('"key0" : "KEY002"', '"value0" : 123,\n"value1" : "'
                    + uni + '"'),)),
                '/invalid Unicode/')

        # this one should work
        self.load_json(self.table_uri2,
              (('"key0" : "KEY002"', '"value0" : 34,\n"value1" : "str2"'),))

            

Reported by Pylint.

Unused variable 'j'
Error

Line: 400 Column: 13

                      for i in range(0, 256):
            self.generate_key(i, k)
            self.generate_value(i, v, False)
            j = i if (i > 0 and i < 126) else 88
            table5_json.append(('"key0" : "' + bin_unicode[k[0]] +
                                bin_unicode[k[1]] + '"',
                                '"value0" : "' + bin_unicode[v[0]] +
                                bin_unicode[v[1]] +
                                bin_unicode[v[2]] + '"'))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

Multiple imports on one line (os, sys)
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import os, sys
import wiredtiger, wttest
from suite_subprocess import suite_subprocess

# test_jsondump.py
# Test dump output from json cursors.

            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import os, sys
import wiredtiger, wttest
from suite_subprocess import suite_subprocess

# test_jsondump.py
# Test dump output from json cursors.
class test_jsondump02(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

Class name "test_jsondump02" doesn't conform to PascalCase naming style
Error

Line: 35 Column: 1

              
# test_jsondump.py
# Test dump output from json cursors.
class test_jsondump02(wttest.WiredTigerTestCase, suite_subprocess):

    table_uri1 = 'table:jsondump02a.wt'
    table_uri2 = 'table:jsondump02b.wt'
    table_uri3 = 'table:jsondump02c.wt'
    basename_uri4 = 'jsondump02d.wt'

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_rollback_to_stable10.py
33 issues
Unable to import 'wiredtiger'
Error

Line: 32 Column: 1

              import fnmatch, os, shutil, threading, time
from helper import copy_wiredtiger_home, simulate_crash_restart
from test_rollback_to_stable01 import test_rollback_to_stable_base
from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios
from wtthread import checkpoint_thread, op_thread

# test_rollback_to_stable10.py

            

Reported by Pylint.

An attribute defined in wttest line 401 hides this method
Error

Line: 54 Column: 5

              
    scenarios = make_scenarios(key_format_values, prepare_values)

    def conn_config(self):
        config = 'cache_size=6MB,statistics=(all),statistics_log=(json,on_close,wait=1),log=(enabled=true),timing_stress_for_test=[history_store_checkpoint_delay]'
        return config

    def test_rollback_to_stable(self):
        nrows = 1000

            

Reported by Pylint.

Undefined variable 'wttest'
Error

Line: 335 Column: 5

                      self.ignoreStdoutPatternIfExists("oldest pinned transaction ID rolled back for eviction")

if __name__ == '__main__':
    wttest.run()

            

Reported by Pylint.

Unused import time
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import fnmatch, os, shutil, threading, time
from helper import copy_wiredtiger_home, simulate_crash_restart
from test_rollback_to_stable01 import test_rollback_to_stable_base
from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios

            

Reported by Pylint.

Unused import shutil
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import fnmatch, os, shutil, threading, time
from helper import copy_wiredtiger_home, simulate_crash_restart
from test_rollback_to_stable01 import test_rollback_to_stable_base
from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios

            

Reported by Pylint.

Unused import os
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import fnmatch, os, shutil, threading, time
from helper import copy_wiredtiger_home, simulate_crash_restart
from test_rollback_to_stable01 import test_rollback_to_stable_base
from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios

            

Reported by Pylint.

Unused import fnmatch
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import fnmatch, os, shutil, threading, time
from helper import copy_wiredtiger_home, simulate_crash_restart
from test_rollback_to_stable01 import test_rollback_to_stable_base
from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios

            

Reported by Pylint.

Unused op_thread imported from wtthread
Error

Line: 35 Column: 1

              from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios
from wtthread import checkpoint_thread, op_thread

# test_rollback_to_stable10.py
# Test the rollback to stable operation performs sweeping history store.
class test_rollback_to_stable10(test_rollback_to_stable_base):
    session_config = 'isolation=snapshot'

            

Reported by Pylint.

Unused variable 'value_f'
Error

Line: 198 Column: 9

                      value_c = "ccccc" * 100
        value_d = "ddddd" * 100
        value_e = "eeeee" * 100
        value_f = "fffff" * 100

        # Perform several updates.
        self.pr("large updates")
        self.large_updates(uri_1, value_d, ds_1, nrows, self.prepare, 20)
        self.large_updates(uri_1, value_c, ds_1, nrows, self.prepare, 30)

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 239 Column: 17

                              key = ds.key(i)
                cursor.set_key(key)
                cursor.set_value(value)
                self.assertEquals(cursor.update(), 0)
            self.pr("prepare")
            session.prepare_transaction(prepare_config)

        # Create a checkpoint thread
        done = threading.Event()

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_prepare_hs03.py
33 issues
Unable to import 'wiredtiger'
Error

Line: 35 Column: 1

              # [END_TAGS]

from helper import copy_wiredtiger_home
import wiredtiger, wttest
from wtdataset import SimpleDataSet
import os, shutil
from wtscenario import make_scenarios
from wiredtiger import stat


            

Reported by Pylint.

Unable to import 'wiredtiger'
Error

Line: 39 Column: 1

              from wtdataset import SimpleDataSet
import os, shutil
from wtscenario import make_scenarios
from wiredtiger import stat

# test_prepare_hs03.py
# test to ensure salvage, verify & simulating crash are working for prepared transactions.
class test_prepare_hs03(wttest.WiredTigerTestCase):
    # Force a small cache.

            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 35 Column: 1

              # [END_TAGS]

from helper import copy_wiredtiger_home
import wiredtiger, wttest
from wtdataset import SimpleDataSet
import os, shutil
from wtscenario import make_scenarios
from wiredtiger import stat


            

Reported by Pylint.

Unused import shutil
Error

Line: 37 Column: 1

              from helper import copy_wiredtiger_home
import wiredtiger, wttest
from wtdataset import SimpleDataSet
import os, shutil
from wtscenario import make_scenarios
from wiredtiger import stat

# test_prepare_hs03.py
# test to ensure salvage, verify & simulating crash are working for prepared transactions.

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 65 Column: 9

              
    def corrupt_table(self):
        tablename="test_prepare_hs03.wt"
        self.assertEquals(os.path.exists(tablename), True)

        with open(tablename, 'r+') as tablepointer:
            tablepointer.seek(1024)
            tablepointer.write('Bad!' * 1024)


            

Reported by Pylint.

Redefining name 'stat' from outer scope (line 39)
Error

Line: 88 Column: 24

                              break
            self.session.checkpoint()

    def get_stat(self, stat):
        stat_cursor = self.session.open_cursor('statistics:')
        val = stat_cursor[stat][2]
        stat_cursor.close()
        return val


            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 102 Column: 13

                          self.session.begin_transaction('isolation=snapshot')
            cursor.set_key(ds.key(nrows + i))
            cursor.set_value(commit_value)
            self.assertEquals(cursor.insert(), 0)
            self.session.commit_transaction('commit_timestamp=' + self.timestamp_str(1))
        cursor.close()

        # Set the stable/oldest timstamps.
        self.conn.set_timestamp('stable_timestamp=' + self.timestamp_str(1))

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 130 Column: 17

                          for i in range(start, end):
                cursors[j].set_key(ds.key(nrows + i))
                cursors[j].set_value(prepare_value)
                self.assertEquals(cursors[j].insert(), 0)
            sessions[j].prepare_transaction('prepare_timestamp=' + self.timestamp_str(4))

        hs_writes = self.get_stat(stat.conn.cache_write_hs) - hs_writes_start

        # Assert if not writing anything to the history store.

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 146 Column: 13

                          # The search should pass.
            self.assertEqual(cursor.search(), 0)
            # Correctness Test - commit_value should be visible
            self.assertEquals(cursor.get_value(), commit_value)
            # Correctness Test - prepare_value should NOT be visible
            self.assertNotEquals(cursor.get_value(), prepare_value)
        cursor.close()

        # Close all sessions (and cursors), this will cause prepared updates to be rolled back.

            

Reported by Pylint.

Using deprecated method assertNotEquals()
Error

Line: 148 Column: 13

                          # Correctness Test - commit_value should be visible
            self.assertEquals(cursor.get_value(), commit_value)
            # Correctness Test - prepare_value should NOT be visible
            self.assertNotEquals(cursor.get_value(), prepare_value)
        cursor.close()

        # Close all sessions (and cursors), this will cause prepared updates to be rolled back.
        for j in range (0, nsessions):
            sessions[j].close()

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_encrypt06.py
33 issues
Unable to import 'wiredtiger'
Error

Line: 34 Column: 1

              #

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):
    # To test the sodium encryptor, we use secretkey= rather than

            

Reported by Pylint.

An attribute defined in wttest line 401 hides this method
Error

Line: 115 Column: 5

                      extlist.extension('encryptors', self.table0_encrypt)
        extlist.extension('encryptors', self.table1_encrypt)

    def conn_config(self):
        return 'encryption=(name={0}{1}),'.format(
            self.sys_encrypt, self.sys_encrypt_args)

    def encrypt_table_params(self, name, args):
        if name == None:

            

Reported by Pylint.

Unused import run
Error

Line: 33 Column: 1

              #   Test that encryption is effective, it leaves no clear text
#

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Unused import random
Error

Line: 33 Column: 1

              #   Test that encryption is effective, it leaves no clear text
#

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 34 Column: 1

              #

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):
    # To test the sodium encryptor, we use secretkey= rather than

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

standard import "import os, run, random" should be placed before "import os, run, random"
Error

Line: 33 Column: 1

              #   Test that encryption is effective, it leaves no clear text
#

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Multiple imports on one line (os, run, random)
Error

Line: 33 Column: 1

              #   Test that encryption is effective, it leaves no clear text
#

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 34 Column: 1

              #

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):
    # To test the sodium encryptor, we use secretkey= rather than

            

Reported by Pylint.

third party import "import wiredtiger, wttest" should be placed before "import os, run, random"
Error

Line: 34 Column: 1

              #

import os, run, random
import wiredtiger, wttest
from wtscenario import make_scenarios

# Test encryption, when on, does not leak any information
class test_encrypt06(wttest.WiredTigerTestCase):
    # To test the sodium encryptor, we use secretkey= rather than

            

Reported by Pylint.