From 8816a65cb8e467f0c3d3970000c0403c1cb80f40 Mon Sep 17 00:00:00 2001 From: cgf Date: Mon, 17 Jul 2006 19:30:29 +0000 Subject: [PATCH] GCC 4.1 fixes. * cygheap.h (cygheap_user): Remove unneeded class names from function declaration. * fhandler.h (fhandler_base): Ditto. (fhandler_dev_floppy): Ditto. (fhandler_console): Ditto. * wininfo.h (wininfo): Ditto. * exceptions.cc (sigpacket::process): Avoid compiler errors about gotos and initialization. * fhandler_fifo.cc (fhandler_fifo::open): Ditto. * fhandler_floppy.cc (fhandler_dev_floppy::ioctl): Ditto. * fhandler_tty.cc (fhandler_tty_slave::ioctl): Ditto. * mmap.cc (mmap64): Ditto. * pipe.cc (fhandler_pipe::open): Ditto. * spawn.cc (spawn_guts): Ditto. * sec_helper.cc: Fix some comments. (get_null_sd): Move file-scope static to only function where it is used. --- winsup/cygwin/ChangeLog | 22 ++++++++++++++++++++++ winsup/cygwin/cygheap.h | 2 +- winsup/cygwin/exceptions.cc | 3 ++- winsup/cygwin/fhandler.h | 6 +++--- winsup/cygwin/fhandler_fifo.cc | 3 ++- winsup/cygwin/fhandler_floppy.cc | 3 +-- winsup/cygwin/fhandler_tty.cc | 3 ++- winsup/cygwin/mmap.cc | 5 +++-- winsup/cygwin/pipe.cc | 3 ++- winsup/cygwin/sec_helper.cc | 17 ++++++----------- winsup/cygwin/spawn.cc | 19 +++++++++++++------ winsup/cygwin/wininfo.h | 2 +- 12 files changed, 58 insertions(+), 30 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index cf8ac0a652..fefb7d6ec2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,25 @@ +2006-07-17 Christopher Faylor + + GCC 4.1 fixes. + * cygheap.h (cygheap_user): Remove unneeded class names from function + declaration. + * fhandler.h (fhandler_base): Ditto. + (fhandler_dev_floppy): Ditto. + (fhandler_console): Ditto. + * wininfo.h (wininfo): Ditto. + * exceptions.cc (sigpacket::process): Avoid compiler errors about gotos + and initialization. + * fhandler_fifo.cc (fhandler_fifo::open): Ditto. + * fhandler_floppy.cc (fhandler_dev_floppy::ioctl): Ditto. + * fhandler_tty.cc (fhandler_tty_slave::ioctl): Ditto. + * mmap.cc (mmap64): Ditto. + * pipe.cc (fhandler_pipe::open): Ditto. + * spawn.cc (spawn_guts): Ditto. + + * sec_helper.cc: Fix some comments. + (get_null_sd): Move file-scope static to only function where it is + used. + 2006-07-14 Christopher Faylor * fork.cc (fork): Lock the process before forking to prevent things diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index cb18d3daaf..0afe1620d7 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -216,7 +216,7 @@ public: return strcpy (buf, name ()); } - const char *cygheap_user::test_uid (char *&, const char *, size_t) + const char *test_uid (char *&, const char *, size_t) __attribute__ ((regparm (3))); }; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 12c6e0687b..e5345f13ec 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1118,6 +1118,8 @@ int __stdcall sigpacket::process () { DWORD continue_now; + struct sigaction dummy = global_sigs[SIGSTOP]; + if (si.si_signo != SIGCONT) continue_now = false; else @@ -1235,7 +1237,6 @@ stop: if (ISSTATE (myself, PID_STOPPED)) goto done; handler = (void *) sig_handle_tty_stop; - struct sigaction dummy = global_sigs[SIGSTOP]; thissig = dummy; dosig: diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 313a655ddf..7b637c85a6 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -275,7 +275,7 @@ class fhandler_base __attribute__ ((regparm (3))); int __stdcall fstat_by_handle (struct __stat64 *buf) __attribute__ ((regparm (2))); int __stdcall fstat_by_name (struct __stat64 *buf) __attribute__ ((regparm (2))); - int fhandler_base::utimes_fs (const struct timeval *) __attribute__ ((regparm (2))); + int utimes_fs (const struct timeval *) __attribute__ ((regparm (2))); virtual int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1))); virtual int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2))); virtual int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3))); @@ -601,7 +601,7 @@ class fhandler_dev_floppy: public fhandler_dev_raw IMPLEMENT_STATUS_FLAG (bool, eom_detected) inline _off64_t get_current_position (); - int fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo); + int get_drive_info (struct hd_geometry *geo); BOOL write_file (const void *buf, DWORD to_write, DWORD *written, int *err); BOOL read_file (void *buf, DWORD to_read, DWORD *read, int *err); @@ -928,7 +928,7 @@ class fhandler_console: public fhandler_termios static tty_min *get_tty_stuff (int); bool is_slow () {return 1;} static bool need_invisible (); - static bool fhandler_console::has_a () {return !invisible_console;} + static bool has_a () {return !invisible_console;} }; class fhandler_tty_common: public fhandler_termios diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index 8f1a584776..aa631528ae 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -150,6 +150,7 @@ fhandler_fifo::open (int flags, mode_t) char mutex[CYG_MAX_PATH]; char *emutex = mutex + CYG_MAX_PATH; char *p, *p1; + DWORD resw; /* Generate a semi-unique name to associate with this fifo but try to ensure that it is no larger than CYG_MAX_PATH */ @@ -175,7 +176,7 @@ fhandler_fifo::open (int flags, mode_t) open an fd. */ /* FIXME? Need to wait for signal here? This shouldn't block for long, but... */ - DWORD resw = WaitForSingleObject (h, INFINITE); + resw = WaitForSingleObject (h, INFINITE); lock_process::locker.acquire (); /* Restore the lock */ if (resw != WAIT_OBJECT_0 && resw != WAIT_ABANDONED_0) { diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 9667235ffc..4595e73a32 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -506,8 +506,7 @@ fhandler_dev_floppy::ioctl (unsigned int cmd, void *buf) /* Just check the restriction that blocksize must be a multiple of the sector size of the underlying volume sector size, then fall through to fhandler_dev_raw::ioctl. */ - struct rdop *op = (struct rdop *) buf; - if (op->rd_parm % bytes_per_sector) + if (((struct rdop *) buf)->rd_parm % bytes_per_sector) { SetLastError (ERROR_INVALID_PARAMETER); __seterrno (); diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 9ecba14d94..0121d62b41 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -1021,6 +1021,7 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) get_ttyp ()->cmd = cmd; get_ttyp ()->ioctl_retval = 0; + int val; switch (cmd) { case TIOCGWINSZ: @@ -1052,7 +1053,7 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) } break; case TIOCLINUX: - int val = *(unsigned char *) arg; + val = *(unsigned char *) arg; if (val != 6 || !ioctl_request_event || !ioctl_done_event) get_ttyp ()->ioctl_retval = -EINVAL; else diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 85718eec74..5ace55c0a1 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -977,6 +977,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) caddr_t base = NULL; DWORD pagesize = getpagesize (); + DWORD checkpagesize; fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); @@ -1006,8 +1007,8 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) at least most of the time is, allow 4K aligned addresses in 98, to enable remapping of formerly mapped pages. If no matching free pages exist, check addr again, this time for the real alignment. */ - DWORD checkpagesize = wincap.has_mmap_alignment_bug () ? - getsystempagesize () : pagesize; + checkpagesize = wincap.has_mmap_alignment_bug () ? + getsystempagesize () : pagesize; if (fixed (flags) && ((uintptr_t) addr % checkpagesize)) { set_errno (EINVAL); diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index 183bd18de6..a6171f2f9e 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -46,6 +46,7 @@ fhandler_pipe::open (int flags, mode_t mode) fhandler_pipe *fh = NULL; size_t size; int pid, rwflags = (flags & O_ACCMODE); + bool inh; sscanf (get_name (), "/proc/%d/fd/pipe:[%d]", &pid, (int *) &pipe_hdl); if (pid == myself->pid) @@ -93,7 +94,7 @@ fhandler_pipe::open (int flags, mode_t mode) set_errno (EACCES); goto out; } - bool inh = !(flags & O_NOINHERIT); + inh = !(flags & O_NOINHERIT); if (!DuplicateHandle (proc, pipe_hdl, hMainProc, &nio_hdl, 0, inh, DUPLICATE_SAME_ACCESS)) { diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index d8cd160626..a32dcb8f54 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -443,19 +443,17 @@ set_cygwin_privileges (HANDLE token) set_privilege (token, SE_CHANGE_NOTIFY_PRIV, !allow_traverse); } -/* - * Function to return a common SECURITY_DESCRIPTOR * that - * allows all access. - */ +/* Function to return a common SECURITY_DESCRIPTOR that + allows all access. */ -static NO_COPY SECURITY_DESCRIPTOR *null_sdp = 0; SECURITY_DESCRIPTOR *__stdcall get_null_sd () { static NO_COPY SECURITY_DESCRIPTOR sd; + static NO_COPY SECURITY_DESCRIPTOR *null_sdp; - if (null_sdp == 0) + if (!null_sdp) { InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl (&sd, TRUE, 0, FALSE); @@ -464,11 +462,8 @@ get_null_sd () return null_sdp; } -/* - * Initialize global security attributes. - * - * Called from dcrt0.cc (_dll_crt0). - */ +/* Initialize global security attributes. + Called from dcrt0.cc (_dll_crt0). */ void init_global_security () diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 40a57c0d74..d1ee321e51 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -304,6 +304,11 @@ spawn_guts (const char * prog_arg, const char *const *argv, path_conv real_path; bool reset_sendsig = false; + const char *runpath; + int c_flags; + bool wascygexec; + cygheap_exec_info *moreinfo; + bool null_app_name = false; STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}; int looped = 0; @@ -326,7 +331,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, else chtype = PROC_EXEC; - cygheap_exec_info *moreinfo = (cygheap_exec_info *) ccalloc (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info)); + moreinfo = (cygheap_exec_info *) ccalloc (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info)); moreinfo->old_title = NULL; /* CreateProcess takes one long string that is the command line (sigh). @@ -347,7 +352,8 @@ spawn_guts (const char * prog_arg, const char *const *argv, goto out; } - bool wascygexec = real_path.iscygexec (); + + wascygexec = real_path.iscygexec (); res = newargv.fixup (prog_arg, real_path, ext); if (res) @@ -410,7 +416,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, si.wShowWindow = SW_HIDE; } - int c_flags = GetPriorityClass (hMainProc); + c_flags = GetPriorityClass (hMainProc); sigproc_printf ("priority class %d", c_flags); c_flags |= CREATE_SEPARATE_WOW_VDM; @@ -454,7 +460,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, || cygheap->fdtab.need_fixup_before ())) c_flags |= CREATE_SUSPENDED; - const char *runpath = null_app_name ? NULL : (const char *) real_path; + runpath = null_app_name ? NULL : (const char *) real_path; syscall_printf ("null_app_name %d (%s, %.9500s)", null_app_name, runpath, one_line.buf); @@ -907,6 +913,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) { char *pgm = NULL; char *arg1 = NULL; + char *ptr, *buf; HANDLE h = CreateFile (real_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -927,7 +934,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) } goto err; } - char *buf = (char *) MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0); + buf = (char *) MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0); CloseHandle (hm); if (!buf) goto err; @@ -957,7 +964,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) debug_printf ("%s is possibly a script", (char *) real_path); - char *ptr = buf; + ptr = buf; if (*ptr++ == '#' && *ptr++ == '!') { ptr += strspn (ptr, " \t"); diff --git a/winsup/cygwin/wininfo.h b/winsup/cygwin/wininfo.h index 0247ae9170..f67cf9a4b9 100644 --- a/winsup/cygwin/wininfo.h +++ b/winsup/cygwin/wininfo.h @@ -15,7 +15,7 @@ class wininfo static muto _lock; public: operator HWND (); - int __stdcall wininfo::process (HWND, UINT, WPARAM, LPARAM) + int __stdcall process (HWND, UINT, WPARAM, LPARAM) __attribute__ ((regparm (3))); void lock (); void release (); -- 2.11.0