Re: [libmicrohttpd] How to proper fix error: "ISO C90 does not support ‘long long’"?

2018-03-24 Thread Tim Rühsen
Hi Silvio,


On 24.03.2018 04:30, silvioprog wrote:
> I'm using the following compilers:
>
> 1) clang version 5.0.1-svn325091-1~exp1 (branches/release_50)
>
> 2) arm-linux-androideabi-gcc (Linaro GCC 4.7-2014.04-1~dev) 4.7.4
>
> 3) gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
>
> clang and arm-linux-androideabi-gcc compiles MHD fine, but gcc raises
> the following error:
>

That version of gcc definitely understands 'long long'. So it's likely
you have -std=c89 somewhere in your command line.
Is that what you desperately need / want ?

Regards, Tim



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] How to proper fix error: "ISO C90 does not support ‘long long’"?

2018-03-24 Thread Christian Grothoff
Changing 'long long' will break ABI compatibility. So this is not
something you want to do for a mere warning in response to you trying
out compiler flags to try settings nobody has needed for 20+ years.

On 03/24/2018 04:30 AM, silvioprog wrote:
> Christian,
> 
> I'm using the following compilers:
> 
> 1) clang version 5.0.1-svn325091-1~exp1 (branches/release_50)
> 
> 2) arm-linux-androideabi-gcc (Linaro GCC 4.7-2014.04-1~dev) 4.7.4
> 
> 3) gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
> 
> clang and arm-linux-androideabi-gcc compiles MHD fine, but gcc raises
> the following error:
> 
> [snip]
> /libmicrohttpd/include/microhttpd.h:277:46: error: ISO C90 does not
> support ‘long long’ [-Werror=long-long]
>  #define MHD_UNSIGNED_LONG_LONG unsigned long long
>                                               ^
> /libmicrohttpd/include/microhttpd.h:2348:4: note: in expansion of macro
> ‘MHD_UNSIGNED_LONG_LONG’
>     MHD_UNSIGNED_LONG_LONG *timeout);
>     ^
> cc1: all warnings being treated as errors
> 
> I fixed it using the attached patch, but I'm not sure if it is the
> proper way to fix it.
> 
> WDYT about this change?
> 
> --
> Silvio Clécio



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] How to proper fix error: "ISO C90 does not support ‘long long’"?

2018-03-24 Thread silvioprog
Hello Tim, thanks for answering. 😁

I'm using the following CMake script:

https://github.com/risoflora/libbrook/blob/new_api/cmake/BkFlags.cmake

it seems the error is related to the line 60:

[snip]
53. if (BK_PICKY_COMPILER)
54. if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
55. #-Wsign-conversion - needs to fix (un)signed bugs in utstring.h
56. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wextra
-Wdeclaration-after-statement -Wstrict-prototypes -Wmissing-declarations
-Wredundant-decls -Wnested-externs -Winline")
57. if (NOT ARM)
58. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
59. if (CMAKE_COMPILER_IS_GNUCC)
60. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wc90-c99-compat")
61. endif ()
62. endif ()
63. else ()
64. message(FATAL_ERROR "Unknown C compiler: ${CMAKE_C_COMPILER}")
65. endif ()
66. endif ()

Now I understood why it raises "long long" error only in GCC: I'm passing
-Wc90-c99-compat for it. I've used this option just because I want to raise
"*error C++ style comments are incompatible with C90*" to avoid "*//*"
comments in my sources, but it seems GCC doesn't provide a specific option
for this checking. :-/

On Sat, Mar 24, 2018 at 5:37 AM, Tim Rühsen  wrote:

> Hi Silvio,
>
> On 24.03.2018 04:30, silvioprog wrote:
>
> I'm using the following compilers:
>
> 1) clang version 5.0.1-svn325091-1~exp1 (branches/release_50)
>
> 2) arm-linux-androideabi-gcc (Linaro GCC 4.7-2014.04-1~dev) 4.7.4
>
> 3) gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
>
> clang and arm-linux-androideabi-gcc compiles MHD fine, but gcc raises the
> following error:
>
>
> That version of gcc definitely understands 'long long'. So it's likely you
> have -std=c89 somewhere in your command line.
> Is that what you desperately need / want ?
>
> Regards, Tim
>

-- 
Silvio Clécio


Re: [libmicrohttpd] How to proper fix error: "ISO C90 does not support ‘long long’"?

2018-03-24 Thread silvioprog
Indeed. I forgot to run abi-compliance-checker tool, it reported me shortly
after I send the e-mail. 😅

On Sat, Mar 24, 2018 at 6:07 AM, Christian Grothoff 
wrote:

> Changing 'long long' will break ABI compatibility. So this is not
> something you want to do for a mere warning in response to you trying
> out compiler flags to try settings nobody has needed for 20+ years.
>
> On 03/24/2018 04:30 AM, silvioprog wrote:
> > Christian,
> >
> > I'm using the following compilers:
> >
> > 1) clang version 5.0.1-svn325091-1~exp1 (branches/release_50)
> >
> > 2) arm-linux-androideabi-gcc (Linaro GCC 4.7-2014.04-1~dev) 4.7.4
> >
> > 3) gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
> >
> > clang and arm-linux-androideabi-gcc compiles MHD fine, but gcc raises
> > the following error:
> >
> > [snip]
> > /libmicrohttpd/include/microhttpd.h:277:46: error: ISO C90 does not
> > support ‘long long’ [-Werror=long-long]
> >  #define MHD_UNSIGNED_LONG_LONG unsigned long long
> >   ^
> > /libmicrohttpd/include/microhttpd.h:2348:4: note: in expansion of macro
> > ‘MHD_UNSIGNED_LONG_LONG’
> > MHD_UNSIGNED_LONG_LONG *timeout);
> > ^
> > cc1: all warnings being treated as errors
> >
> > I fixed it using the attached patch, but I'm not sure if it is the
> > proper way to fix it.
> >
> > WDYT about this change?
> >
> > --
> > Silvio Clécio
>

-- 
Silvio Clécio


Re: [libmicrohttpd] How to proper fix error: "ISO C90 does not support ‘long long’"?

2018-03-24 Thread silvioprog
Oops...

On Sat, Mar 24, 2018 at 1:11 PM, silvioprog  wrote:

> ... it seems GCC doesn't provide a specific option for this checking.
>

I meant "it seems -Wcomment/-Wcomments works only in 'C<=90'".

-- 
Silvio Clécio


Re: [libmicrohttpd] How to proper fix error: "ISO C90 does not support ‘long long’"?

2018-03-24 Thread Tim Rühsen
On 24.03.2018 17:24, silvioprog wrote:
> Oops...
>
> On Sat, Mar 24, 2018 at 1:11 PM, silvioprog  > wrote:
>
> ... it seems GCC doesn't provide a specific option for this checking.
>
>
> I meant "it seems -Wcomment/-Wcomments works only in 'C<=90'".
>

And that makes sense since C>=99 allows these type of comments.
And if the source uses 'long long' it is C99 anyways, so I don't
understand your problem.

Regards, Tim



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] MHD and PVS-Studio Analysis

2018-03-24 Thread silvioprog
Finally I made a step by step to reproduce the full report (total warnings
[general analysis]: 36). Firstly, take a look at this new generated report:

https://duallsistemas.com.br/download/pvs_mhd/fullhtml2

The steps:

Download the free PVS-Studio binary from:

https://github.com/viva64/how-to-use-pvs-studio-free/releases

Now, run the following commands:

# clone MHD from trunk
git clone https://gnunet.org/git/libmicrohttpd.git
# enter into its folder
cd libmicrohttpd/
# create the boostrap scripts
./bootstrap
# configure the building environment
./configure
# mark all source for analysis
how-to-use-pvs-studio-free -c 2 -m src
# build MHD
pvs-studio-analyzer trace -- make
# analyze the code
pvs-studio-analyzer analyze
# generate the HTML report from generated log
plog-converter -a GA:1,2 -t fullhtml PVS-Studio.log -o fullhtml

Now, take a look at "fullhtml" folder, you may get an "index.html"
containing all reported issues (like the link I showed above).

Result for my environment / MHD copy:

Total messages: 47
Filtered messages: 36

I would like to help to fix those issues.

On Thu, Feb 1, 2018 at 6:11 AM, Christian Grothoff 
wrote:

> Hi silvioprog,
>
> One of the issues was clearly real (fixed in Git), the other three I
> don't get.  Looking at the code, the flag can clearly go in either
> direction, and the incremented dest pointer cannot be NULL (was checked
> just a few lines above).
>
> Regardless, running such tools is always a good idea and generally
> helpful, so I would definitively appreciate a full run and reports (or
> patches, if the reports turn out to be well-founded).
>
> Happy hacking!
>
> Christian
>
> On 01/31/2018 11:30 PM, silvioprog wrote:
> > Hi dudes.
> >
> > PVS-Studio [1]  is a Russian tool
> > (Windows/Linux) for bug detection in the source code of programs written
> > in C/C++.
> >
> > The tool have been issued bugs in many popular projects like LLVM/GCC,
> > cURL, OpenSSL, Doxygen, OpenCV, GTK, glibc, tor etc. The full list is
> > available at PVS-Studio's inspections page [2]
> > . It has helped the authors to
> > fix the reported issues [3]
> > .
> >
> > I have been using the free version of PVS-Studio for analyzing open
> > source projects I use, then it reported issues [4]
> >  in "Medium
> > level" in four MHD files
> > . The attached
> > tar.gz contains a few pictures showing the testing result and text files
> > containing respective links to access each issue explanation.
> >
> > If you agree with fixing those issues, I can run a full test in all MHD
> > files and share all the reported issues (I fix the ones possible for me).
> >
> > [1] PVS-Studio page, < https://www.viva64.com/en/pvs-studio
> >  >
> > [2] PVS-Studio inspections, < https://www.viva64.com/en/
> > inspections
> >  >
> > [3] cURL fixes based on PVS-Studio issuing,
> > < https://github.com/curl/curl/search?q=pvs&type=Issues
> >  >
> > [4] first MHD report using PVS-Studio free for open source projects,
> > < https://duallsistemas.com.br/download/pvs_mhd/fullhtml
> >  >
> >
> > --
> > Silvio Clécio
>

-- 
Silvio Clécio


[libmicrohttpd] New project: microhttpd.h or microhttpd2.h?

2018-03-24 Thread silvioprog
Hello.

I'm going to create a new project from scratch that uses MHD as main HTTP
library, so I'm free to choose a new API. However, I have some questions
that may help me to choose between microhttpd.h and microhttpd2.h:

* can I use the new API in production? (I'm following MHD changes, but I'm
not sure about the new API development status)
* will the previous API still receiving new features and updates?
(specially for websockets)
* is there a tutorial or reference to study the new API? (this two
documents of the previous API helped me a lot: 1
 / 2
)
* is there examples or tests (even drafts) showing how to use the new API?

I'm OK to study (and contribute) the new API and I'm inclined to choose it
because its simpler/friendly functions, MHD_Action etc., but if you don't
recommend to use it for while I'm happy using the current stable API
anyway. ;-)

Thank you!

-- 
Silvio Clécio