Ryan Johnson | 29 Mar 2012 16:36
Picon
Picon
Favicon

Compiler warnings when building latest cygwin cvs with gcc-4.6 (0/2)

Hi all

While trying to build the cygwin dll from source, I accidentally left my 
home-built gcc-4.6 in PATH... and it complains loudly about all kinds of 
things, some of which might actually be of interest. I'll follow up 
shortly with two patches that fix those problems in a backwards 
compatible way, in case this provides a improvement in code quality (and 
future-proofing for when we upgrade cygwin's gcc4).

The patched code compiles cleanly under both cygwin's gcc4 and my 
gcc-4.6.2, but the latter produces a broken cygwin1.dll. I haven't tried 
to figure out what goes wrong, since I don't know what changes went into 
cygwin's gcc4 to make it work properly in the first place. It could be 
something as simple as PATH/LD_LIBRARY_PATH...

Patch 1: fix function attribute conflicts
Patch 2: fix compiler misc. warnings

NOTE: the warnings patch applies safely, but with fuzz, if the 
attributes patch has already been applied. If you're paranoid, apply the 
warnings patch first.

Overview of changes:

1a. Conflicting function definition errors, due to functions declared 
with __attribute__((regparm(...))) and later defined without it. AFAIK, 
if both declaration and definition exist for a function, the definition 
must either give no attributes or all must match the declaration. This 
includes the __stdcall attribute...

(Continue reading)

Ryan Johnson | 29 Mar 2012 16:38
Picon
Picon
Favicon

Re: Compiler warnings when building latest cygwin cvs with gcc-4.6 (1/2)

On 29/03/2012 10:36 AM, Ryan Johnson wrote:
> Patch 1: fix function attribute conflicts
         * dcrt0.cc (getstack): Simplify function attribute declarations.
         (do_exit): Remove conflicting function attributes.
         * environ.cc (various): Ditto.
         * errno.cc (various): Ditto.
         * exceptions.cc (_cygtls::interrupt_setup): Ditto.
         (sigpacket::process): Ditto.
         (rtl_unwind): Simplify function attribute declarations.
         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Ditto.
         (various): Remove conflicting function attributes.
         * fhandler.h (various fhandler_*): Correct miscounted regparm
         attribute for fchmod/fchown.
         * fhandler_clipboard.cc (various): Remove conflicting function
         attributes.
         * fhandler_console.cc (various): Ditto.
         * fhandler_disk_file.cc (various): Ditto.
         * fhandler_dsp.cc (various): Ditto.
         * fhandler_fifo.cc (various): Ditto.
         * fhandler_floppy.cc (various): Ditto.
         * fhandler_mailslot.cc (various): Ditto.
         * fhandler_mem.cc (various): Ditto.
         * fhandler_procsys.cc (various): Ditto.
         * fhandler_random.cc (various): Ditto.
         * fhandler_raw.cc (various): Ditto.
         * fhandler_serial.cc (various): Ditto.
         * fhandler_tape.cc (various): Ditto.
         * fhandler_tty.cc (various): Ditto.
         * fhandler_virtual.cc (various): Ditto.
         * fhandler_windows.cc (various): Ditto.
(Continue reading)

Christopher Faylor | 29 Mar 2012 16:45
Favicon

Re: Compiler warnings when building latest cygwin cvs with gcc-4.6 (1/2)

On Thu, Mar 29, 2012 at 10:38:54AM -0400, Ryan Johnson wrote:
>On 29/03/2012 10:36 AM, Ryan Johnson wrote:
>> Patch 1: fix function attribute conflicts

Sorry, I appreciate the effort but I'd rather deal with these types of
issues when we have a newer version of gcc available.  If we don't have
that we can only take your word for it that things are fixed.  And, it
it is tedious to inspect each change individually to see if you've done
things the way I think they should be done or if there should be a more
global change.

I routinely sweep through the sources when we have a new version of gcc
available.  I'll do the same when we have a new version of gcc.

cgf

Ryan Johnson | 29 Mar 2012 16:40
Picon
Picon
Favicon

Re: Compiler warnings when building latest cygwin cvs with gcc-4.6 (2/2)

On 29/03/2012 10:36 AM, Ryan Johnson wrote:
> Patch 2: fix compiler misc. warnings
         * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix harmless
         out of bounds array access.
         * hookapi.cc (find_first_notloaded_dll): Remove write-only
         variable.
         * net.cc (inet_ntop6): Initialize possibly-uninitialized
         variables; probably a spurious warning from gcc-4.6.
         * path.cc (symlink_info::check): Remove write-only variable.
         (cygwin_conv_path_list): Ditto.
         * pinfo.cc (pinfo::init): Ditto.
         (_pinfo::commune_request): Ditto.
         * sched.cc (sched_setparam): Mark write-only variable unused.
         * sec_acl.cc (aclcheck32): Ditto.
         * sigproc.cc (proc_subproc): Remove write-only variable.
         * spawn.cc (child_info_spawn::worker): Ditto.

? winsup/cygwin/cscope.out
Index: winsup/cygwin/fhandler_disk_file.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.373
diff -u -r1.373 fhandler_disk_file.cc
--- winsup/cygwin/fhandler_disk_file.cc	16 Feb 2012 11:02:05 -0000	1.373
+++ winsup/cygwin/fhandler_disk_file.cc	29 Mar 2012 13:26:18 -0000
 <at>  <at>  -809,8 +809,7  <at>  <at> 
       ffei_buf.ffei.EaNameLength = sizeof (NFS_V3_ATTR) - 1;
       ffei_buf.ffei.EaValueLength = sizeof (fattr3);
(Continue reading)


Gmane