libftdi Archives

Subject: Re: SWIG: Python: compiler warnings

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 6 Aug 2019 10:43:08 +0200
Hi Yegor,

You wrote on Mon, Aug 05, 2019 at 03:46:16PM +0200:
> I get following compiler warnings when compiling libftdi Python
> bindings with gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1):
> 
> Scanning dependencies of target _ftdi1
> [ 22%] Building C object
> python/CMakeFiles/_ftdi1.dir/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c.o
> /home/user/Documents/versioned/libftdi/build/python/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c:
> In function ‘_wrap_read_data’:
> /home/user/Documents/versioned/libftdi/build/python/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c:3842:3:
> warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
>    if(result<0) arg3=0; resultobj =
> SWIG_Python_AppendOutput(resultobj, charp2str((char*)arg2, arg3));
> free(arg2);
>    ^~
> /home/user/Documents/versioned/libftdi/build/python/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c:3842:24:
> note: ...this statement, but the latter is misleadingly indented as if
> it were guarded by the ‘if’
>    if(result<0) arg3=0; resultobj =
> SWIG_Python_AppendOutput(resultobj, charp2str((char*)arg2, arg3));
> free(arg2);
>                         ^~~~~~~~~
> /home/user/Documents/versioned/libftdi/build/python/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c:
> In function ‘_wrap_get_eeprom_buf’:
> /home/user/Documents/versioned/libftdi/build/python/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c:4084:3:
> warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
>    if(result<0) arg3=0; resultobj =
> SWIG_Python_AppendOutput(resultobj, charp2str((char*)arg2, arg3));
> free(arg2);
>    ^~
> /home/user/Documents/versioned/libftdi/build/python/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c:4084:24:
> note: ...this statement, but the latter is misleadingly indented as if
> it were guarded by the ‘if’
>    if(result<0) arg3=0; resultobj =
> SWIG_Python_AppendOutput(resultobj, charp2str((char*)arg2, arg3));
> free(arg2);
>                         ^~~~~~~~~
> 
> The code looking wired indeed i.e. either without parenthesis or indentation.

indeed, this auto-generated code looks very hard to read. May be there is an 
option in SWIG to output "beautified" code, it will be the same on the machine 
level anyway.

I also quickly grepped for "charp2":
    ftdi1.i:inline PyObject* charp2str(const char *v_, long len)

so it should be in the generated code.

On a different note, I'm back in libftdi business after guiding a mass scale
kernel upgrade from 3.14 to 4.19 on way too many different machines.
Let's try to put out a libftdi release in August finally.

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread