Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-4318

SWIG generated code for Python has serious warnings on Windows

    • Storage Engines

      I see these warnings on Windows when building a pull request :

      c:\\swigwin-3.0.8\\swig.exe -o lang\python\wiredtiger_wrap.c -python -threads -O -nodefaultctor -nodefaultdtor lang\python\wiredtiger.i
      cl /Folang\python\wiredtiger_wrap.obj /c lang\python\wiredtiger_wrap.c /W3 /wd4090 /wd4996 /Z7 /TC /Ob1 /O2 /GF /EHsc /GS /Gy /Zc:wchar_t /Gd /MT /nologo /Isrc\include /Ibuild_win /Itest\windows /I. /IC:\Python27\include
      wiredtiger_wrap.c
      lang\python\wiredtiger_wrap.c(3476): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
      lang\python\wiredtiger_wrap.c(3502): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
      lang\python\wiredtiger_wrap.c(3616): warning C4133: 'function': incompatible types - from '__wt_async_op *' to 'WT_CURSOR *'
      lang\python\wiredtiger_wrap.c(5245): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
      lang\python\wiredtiger_wrap.c(5779): warning C4244: 'function': conversion from 'uint64_t' to 'int', possible loss of data
      lang\python\wiredtiger_wrap.c(6388): warning C4047: 'function': 'int' differs in levels of indirection from 'char *'
      lang\python\wiredtiger_wrap.c(6388): warning C4024: 'wiredtiger_strerror': different types for formal and actual parameter 1
      lang\python\wiredtiger_wrap.c(8667): warning C4133: 'function': incompatible types - from 'WT_ASYNC_OP_IMPL *' to 'WT_SESSION_IMPL *'
      link /DEBUG /INCREMENTAL:NO /OPT:REF /DYNAMICBASE /NXCOMPAT /dll /out:_wiredtiger.pyd /implib:_wiredtiger.lib /LIBPATH:C:\Python27\libs libwiredtiger.lib lang\python\wiredtiger_wrap.obj
      Microsoft (R) Incremental Linker Version 14.00.24223.0
      Copyright (C) Microsoft Corporation.  All rights reserved. 

      It doesn't have anything to do with any code I'm changing, but the Windows compiler is (rightly!) catching some problems.  I don't have a Windows build in front of me, and the line numbers don't correlate with my version of SWIG, but I can see that the last error, flagged for line 8667 probably corresponds to this code:

      if (__wt_calloc_def((WT_ASYNC_OP_IMPL *)(*arg6), 1, &pcb) != 0)
            SWIG_exception_fail(SWIG_MemoryError, "WT calloc failed"); 

      arg6 is declared as WT_ASYNC_OP **arg6 , it should be passing a WT_SESSION_IMPL.  The warning before that (line 6388), I think corresponds to:

              SWIG_SetErrorMsg(wtError, wiredtiger_strerror(result));

      and result is declared as char *result; WT_SESSION->strerror is one of the only functions in our API that doesn't return an int, this is boilerplate code generated for when a function does not succeed.

      It would be good to clean these up, and to catch these kind of errors at build time.

            Assignee:
            backlog-server-storage-engines [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            donald.anderson@mongodb.com Donald Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: