Bug 496613

Summary: swig produces code that breaks compilation with -Wall -Werror
Product: [Fedora] Fedora Reporter: Michal Hlavinka <mhlavink>
Component: swigAssignee: Adam Tkac <atkac>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: medium    
Version: 10CC: atkac, ovasik
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-05-12 11:13:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Hlavinka 2009-04-20 11:15:27 UTC
Description of problem:
Swig produces code that breaks compilation with -Wall -Werror


> ./libecryptfs_wrap.c: In function '_wrap_ecryptfs_passphrase_blob':
> ./libecryptfs_wrap.c:2619: error: pointer targets in passing argument 1 of 'PyString_FromStringAndSize' differ in signedness
> ./libecryptfs_wrap.c: In function '_wrap_ecryptfs_passphrase_sig_from_blob':
> ./libecryptfs_wrap.c:2648: error: pointer targets in passing argument 1 of > 'PyString_FromStringAndSize' differ in signedness


Version-Release number of selected component (if applicable):
swig-1.3.35

How reproducible:
allways

Steps to Reproduce:
1. download and install recent ecryptfs-utils srpm
2. prepare build (rpmbuild -bp <path_to_spec> )
3. remove src/libecryptfs-swig/libecryptfs_wrap.c
4. build it
  
Actual results:
build fails

Expected results:
build completes

Additional info:
This was working with swig-1.3.31 (and with 1.3.33 probably)

Comment 1 Adam Tkac 2009-05-12 11:13:37 UTC
Problem is in your code:

src/include/ecryptfs.h:
...
typedef struct binary_data {
        int size;
        unsigned char *data;
} binary_data;
...
-------------
src/libecryptfs-swig/libecryptfs.i:
...
%typemap(out) binary_data {
    $result = PyString_FromStringAndSize($1.data,$1.size);
}
...
-------------
/usr/include/python2.6/stringobject.h:
...
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
...
-------------

As you can see function PyString_FromStringAndSize() takes "const char *" argument bug you are passing unsigned char*. You should modify binary_data structure to contain signed char instead of unsigned or you could modify PyString_FromStringAndSize call in libecryptfs.i:

$result = PyString_FromStringAndSize((char *)($1.data),$1.size);

Not sure which solution is better from ecryptfs-utils perspective. Closing.