[Home]

Summary:ASTERISK-03825: [patch] Compiling libpri with GCC 4
Reporter:Jeffrey C. Ollie (jcollie)Labels:
Date Opened:2005-03-31 13:53:15.000-0600Date Closed:2005-04-04 02:28:33
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) libpri-gcc4-head-1.diff.txt
( 1) libpri-gcc4-stable-1.diff.txt
Description:If you try to compile libpri with GCC 4 you get numerous warnings about signed/unsigned chars.  Since the makefile calls GCC with -Werror the compilation fails. Patch attached has not been tested, but does compile.  Compilation was tested on Fedora Core 4 Test 1 fully updated to 2005-03-31.

****** ADDITIONAL INFORMATION ******

Disclaimer on file.
Comments:By: Kevin P. Fleming (kpfleming) 2005-03-31 14:05:08.000-0600

Hmm, those casts look kind of ugly :-)

By: Jeffrey C. Ollie (jcollie) 2005-03-31 14:11:58.000-0600

Uploaded version of the patch against stable branch and renamed the patch for CVS HEAD.

By: Jeffrey C. Ollie (jcollie) 2005-03-31 14:40:34.000-0600

Yes, the casts are ugly, but I'm not sure that there's a better way.  The casts are mostly needed because libpri is storing raw data off of the network in unsigned char buffers.  Then, information from those buffers needs to be extracted from those buffers and stored in C strings for display and further manipulation.  In certain cases, the best tool to perform the job are the str* (strncpy, strlen, etc.) functions which only accept signed char pointers.  I suppose that you could re-implement strncpy and strlen with versions that use unsigned char pointers, but  I like that less than using the casts.

By: Kevin P. Fleming (kpfleming) 2005-03-31 14:44:13.000-0600

As dwmw2 pointed out on IRC, disallowing "unsigned char *" arguments to the str* functions is going to be a big pain in the arse :-)

By: Mark Spencer (markster) 2005-04-02 15:04:35.000-0600

What if we just add -Wno-sign-compare to the compiler flags?  Does that also fix it without any further patching?

By: Kevin P. Fleming (kpfleming) 2005-04-02 15:09:54.000-0600

Yeah, although it breaks other parts of the code where we really _do_ want a warning when signed/unsigned are mixed (like in the flags macros, for example).

I think the best solution is going to be moving to the use of plain 'char' whenever 'unsigned char' is not absolutely necessary.

By: Mark Spencer (markster) 2005-04-03 13:00:03

this is libpri though, not asterisk.  Not an issue on Asterisk of course because we don't compile with -Werror!

By: Kevin P. Fleming (kpfleming) 2005-04-03 18:15:24

Committed to CVS, thanks!

By: Russell Bryant (russell) 2005-04-04 02:28:33

fixed in 1.0