Project

General

Profile

Backport #2247

Fixing compiler warnings

Added by kot (Міхаіл T.) almost 11 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:26217]

Description

=begin
When debugging a problem, gratuitous compiler warnings often get in the way by obscuring real problems.

This is why projects should try to eliminate them -- so that when a new one pops up, such as when new code is added, or the build is performed on a new platform -- the issue can attract its due attention.

The attached patch fixes warnings, that I observed compiling with ``-Wall -Werror'' on RHEL-5.4/x86_64 system. Please, consider merging these changes in.

The addressed problems are:

  • rb_thread_join was not declared (intern.h) with the rest of the rb_thread functions. Private declarations existed in some C-files...
  • The PUSH_FRAME duly defined the local variable _frame as volatile. However, when the value of _frame was assigned to the global ruby_frame, this qualifier was lost. There were as many warnings about this, as there are invocations of the PUSH_FRAME macro.
  • The little thread_timer() function MUST be declared as returning void*, because it is passed to pthread_create(). Compiler warned, that a non-void function lacked the return-statement. I added one...
  • regex.c in its error reporting tried to print ptrdiff_t value as int. On 64-bit platforms ptrdiff_t is, usually, long int, but that's an impossibly large value for a regular expression's length. Explicit casting of the pointer-difference down to int should be fine.
  • parse.y defined an unused static function arg_prepend()

Also, when compiling with a recent gcc at optimization level -O2 (or higher), util.c throws a number of warnings about breaking strict-aliasing rules. There is no /easy/ fix for this, but the work-around is to simply compile that one file with -fno-strict-aliasing (or whatever flag is needed for this with non-gcc compilers). A /sample/ patch for this issue is attached separately.

Thanks! Yours,

     -mi

=end


Files

patch-warnings (2.42 KB) patch-warnings Silence compiler warnings kot (Міхаіл T.), 10/22/2009 12:59 AM
patch-Makefile.in (484 Bytes) patch-Makefile.in Work-around strict-aliasing violations in util.c kot (Міхаіл T.), 10/22/2009 12:59 AM
patch-ruby-openssl (31.2 KB) patch-ruby-openssl Fix most of the warnings in OpenSSL-extensions kot (Міхаіл T.), 10/29/2009 06:10 AM

Also available in: Atom PDF