From e3778517d9c6409c9c917db83ccac20de1800a29 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 28 May 2004 19:50:07 +0000 Subject: [PATCH] * path.cc (chdir): Always use the normalized_path as posix_cwd, except if it starts with a drive. Also perform whitespace cleanup. --- winsup/cygwin/ChangeLog | 5 ++ winsup/cygwin/cpuid.h | 6 +- winsup/cygwin/cygheap.h | 2 +- winsup/cygwin/cygserver_msg.h | 2 +- winsup/cygwin/cygserver_sem.h | 2 +- winsup/cygwin/dcrt0.cc | 2 +- winsup/cygwin/dir.cc | 16 ++--- winsup/cygwin/environ.cc | 4 +- winsup/cygwin/exceptions.cc | 4 +- winsup/cygwin/external.cc | 10 +-- winsup/cygwin/fhandler.cc | 36 +++++------ winsup/cygwin/fhandler_console.cc | 8 +-- winsup/cygwin/fhandler_disk_file.cc | 20 +++--- winsup/cygwin/fhandler_dsp.cc | 34 +++++----- winsup/cygwin/fhandler_proc.cc | 20 +++--- winsup/cygwin/fhandler_raw.cc | 2 +- winsup/cygwin/fhandler_serial.cc | 2 +- winsup/cygwin/fhandler_socket.cc | 46 +++++++------- winsup/cygwin/fhandler_tape.cc | 96 ++++++++++++++--------------- winsup/cygwin/fhandler_tty.cc | 12 ++-- winsup/cygwin/grp.cc | 6 +- winsup/cygwin/heap.cc | 2 +- winsup/cygwin/init.cc | 2 +- winsup/cygwin/libc/bsdlib.cc | 14 ++--- winsup/cygwin/msg.cc | 26 ++++---- winsup/cygwin/mtinfo.h | 2 +- winsup/cygwin/net.cc | 2 +- winsup/cygwin/passwd.cc | 2 +- winsup/cygwin/path.cc | 46 +++++++------- winsup/cygwin/poll.cc | 2 +- winsup/cygwin/sched.cc | 2 +- winsup/cygwin/sec_helper.cc | 2 +- winsup/cygwin/security.cc | 6 +- winsup/cygwin/sem.cc | 6 +- winsup/cygwin/shared.cc | 4 +- winsup/cygwin/shm.cc | 36 +++++------ winsup/cygwin/sigproc.cc | 4 +- winsup/cygwin/syscalls.cc | 10 +-- winsup/cygwin/sysconf.cc | 6 +- winsup/cygwin/thread.cc | 34 +++++----- winsup/cygwin/thread.h | 8 +-- winsup/cygwin/tty.cc | 8 +-- winsup/cygwin/uinfo.cc | 6 +- winsup/cygwin/wincap.cc | 4 +- 44 files changed, 287 insertions(+), 282 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index edf43778d..ee3e18030 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2004-05-28 Pierre Humblet + + * path.cc (chdir): Always use the normalized_path as posix_cwd, except + if it starts with a drive. + 2004-05-25 Christopher Faylor * winbase.h: Semi-revert previous patch as it caused strange behavior. diff --git a/winsup/cygwin/cpuid.h b/winsup/cygwin/cpuid.h index 1f0cc5006..998bbbf91 100644 --- a/winsup/cygwin/cpuid.h +++ b/winsup/cygwin/cpuid.h @@ -6,9 +6,9 @@ cpuid (unsigned *a, unsigned *b, unsigned *c, unsigned *d, unsigned in) { asm ("cpuid" : "=a" (*a), - "=b" (*b), - "=c" (*c), - "=d" (*d) + "=b" (*b), + "=c" (*c), + "=d" (*d) : "a" (in)); } diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index 15b179ea0..59253b5c7 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -182,7 +182,7 @@ public: } bool has_impersonation_tokens () { return external_token != INVALID_HANDLE_VALUE - || internal_token != INVALID_HANDLE_VALUE + || internal_token != INVALID_HANDLE_VALUE || current_token != INVALID_HANDLE_VALUE; } void close_impersonation_tokens () { diff --git a/winsup/cygwin/cygserver_msg.h b/winsup/cygwin/cygserver_msg.h index 116741e2e..716aaf82b 100644 --- a/winsup/cygwin/cygserver_msg.h +++ b/winsup/cygwin/cygserver_msg.h @@ -48,7 +48,7 @@ private: proc ipcblk; union { - struct msgctl_args ctlargs; + struct msgctl_args ctlargs; struct msgget_args getargs; struct msgrcv_args rcvargs; struct msgsnd_args sndargs; diff --git a/winsup/cygwin/cygserver_sem.h b/winsup/cygwin/cygserver_sem.h index 288a05438..53a5ec570 100644 --- a/winsup/cygwin/cygserver_sem.h +++ b/winsup/cygwin/cygserver_sem.h @@ -47,7 +47,7 @@ private: proc ipcblk; union { - struct semctl_args ctlargs; + struct semctl_args ctlargs; struct semget_args getargs; struct semop_args opargs; }; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 90f6ac8dc..6f99403b0 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -904,7 +904,7 @@ initialize_main_tls (char *padding) UPTR is a pointer to global data that lives on the libc side of the line [if one distinguishes the application from the dll]. */ - + extern "C" void __stdcall _dll_crt0 () { diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index d0a650434..e74498fb0 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -292,7 +292,7 @@ rmdir (const char *dir) (DWORD) real_dir & ~FILE_ATTRIBUTE_READONLY); for (bool is_cwd = false; ; is_cwd = true) - { + { DWORD err; int rc = RemoveDirectory (real_dir); DWORD att = GetFileAttributes (real_dir); @@ -304,8 +304,8 @@ rmdir (const char *dir) /* RemoveDirectory on a samba drive doesn't return an error if the directory can't be removed because it's not empty. Checking for existence afterwards keeps us informed about success. */ - if (att == INVALID_FILE_ATTRIBUTES) - { + if (att == INVALID_FILE_ATTRIBUTES) + { res = 0; break; } @@ -327,19 +327,19 @@ rmdir (const char *dir) SetCurrentDirectory. */ if (strcasematch (real_dir, cygheap->cwd.win32) - && !strcasematch ("c:\\", cygheap->cwd.win32) + && !strcasematch ("c:\\", cygheap->cwd.win32) && !is_cwd && SetCurrentDirectory ("c:\\")) continue; - - /* On 9X ERROR_ACCESS_DENIED is returned + + /* On 9X ERROR_ACCESS_DENIED is returned if you try to remove a non-empty directory. */ if (err == ERROR_ACCESS_DENIED && wincap.access_denied_on_delete ()) err = ERROR_DIR_NOT_EMPTY; - + __seterrno_from_win_error (err); - + /* Directory still exists, restore its characteristics. */ if (real_dir.has_attribute (FILE_ATTRIBUTE_READONLY)) SetFileAttributes (real_dir, real_dir); diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index be4b88408..6fac0994b 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -913,7 +913,7 @@ build_env (const char * const *envp, char *&envblock, int &envc, if (cygheap->user.issetuid ()) for (unsigned i = 0; i < SPENVS_SIZE; i++) if (!saw_spenv[i]) - { + { *dstp = spenvs[i].retrieve (no_envblock); if (*dstp && !no_envblock && *dstp != env_dontadd) { @@ -921,7 +921,7 @@ build_env (const char * const *envp, char *&envblock, int &envc, dstp++; } } - + envc = dstp - newenv; /* Number of entries in newenv */ assert ((size_t) envc <= (n + SPENVS_SIZE)); *dstp = NULL; /* Terminate */ diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 44f37cbbe..66879ee4b 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -830,13 +830,13 @@ ctrl_c_handler (DWORD type) if (myself->ctty != -1) { if (type == CTRL_CLOSE_EVENT) - { + { sig_send (NULL, SIGHUP); saw_close = true; return FALSE; } if (!saw_close && type == CTRL_LOGOFF_EVENT) - { + { /* Check if the process is actually associated with a visible window station, one which actually represents a visible desktop. If not, the CTRL_LOGOFF_EVENT doesn't concern this process. */ diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index b14932426..c6694fa93 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -252,7 +252,7 @@ cygwin_internal (cygwin_getinfo_types t, ...) return check_ntsec (filename); } case CW_GET_ERRNO_FROM_WINERROR: - { + { int error = va_arg (arg, int); int deferrno = va_arg (arg, int); return geterrno_from_win_error (error, deferrno); @@ -270,20 +270,20 @@ cygwin_internal (cygwin_getinfo_types t, ...) memcpy (sd_buf, sd, sd.size ()); psa->lpSecurityDescriptor = sd_buf; return 0; - } + } case CW_GET_SHMLBA: - { + { return getshmlba (); } case CW_GET_UID_FROM_SID: - { + { PSID psid = va_arg (arg, PSID); cygsid sid (psid); struct passwd *pw = internal_getpwsid (sid); return pw ? pw->pw_uid : (__uid32_t)-1; } case CW_GET_GID_FROM_SID: - { + { PSID psid = va_arg (arg, PSID); cygsid sid (psid); struct __group32 *gr = internal_getgrsid (sid); diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index bcc43074a..c481bde29 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -562,19 +562,19 @@ fhandler_base::open (int flags, mode_t mode) switch (query_open ()) { case query_read_control: - access = READ_CONTROL; - create_options = FILE_OPEN_FOR_BACKUP_INTENT; - break; + access = READ_CONTROL; + create_options = FILE_OPEN_FOR_BACKUP_INTENT; + break; case query_stat_control: - access = READ_CONTROL | FILE_READ_ATTRIBUTES; - create_options = FILE_OPEN_FOR_BACKUP_INTENT; - break; + access = READ_CONTROL | FILE_READ_ATTRIBUTES; + create_options = FILE_OPEN_FOR_BACKUP_INTENT; + break; case query_write_control: - access = READ_CONTROL | WRITE_OWNER | WRITE_DAC; - create_options = FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_FOR_RECOVERY; - break; + access = READ_CONTROL | WRITE_OWNER | WRITE_DAC; + create_options = FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_FOR_RECOVERY; + break; default: - create_options = 0; + create_options = 0; if (get_major () == DEV_TAPE_MAJOR && (flags & O_TEXT)) { /* O_TEXT is used to indicate write-through on tape devices */ @@ -636,7 +636,7 @@ fhandler_base::open (int flags, mode_t mode) } status = NtCreateFile (&x, access, &attr, &io, NULL, file_attributes, shared, - create_disposition, create_options, NULL, 0); + create_disposition, create_options, NULL, 0); if (!NT_SUCCESS (status)) { if (!wincap.can_open_directories () && pc.isdir ()) @@ -654,7 +654,7 @@ fhandler_base::open (int flags, mode_t mode) } syscall_printf ("%x = NtCreateFile " - "(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)", + "(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)", status, x, access, get_win32_name (), file_attributes, shared, create_disposition, create_options); @@ -810,22 +810,22 @@ fhandler_base::write (const void *ptr, size_t len) && current_position >= actual_length + (128 * 1024)) { /* If the file systemn supports sparse files and the application - is writing after a long seek beyond EOF, convert the file to + is writing after a long seek beyond EOF, convert the file to a sparse file. */ DWORD dw; HANDLE h = get_output_handle (); BOOL r = DeviceIoControl (h, FSCTL_SET_SPARSE, NULL, 0, NULL, - 0, &dw, NULL); + 0, &dw, NULL); syscall_printf ("%d = DeviceIoControl(%p, FSCTL_SET_SPARSE, " "NULL, 0, NULL, 0, &dw, NULL)", r, h); } else if (wincap.has_lseek_bug ()) { /* Oops, this is the bug case - Win95 uses whatever is on the - disk instead of some known (safe) value, so we must seek + disk instead of some known (safe) value, so we must seek back and fill in the gap with zeros. - DJ - Note: this bug doesn't happen on NT4, even though the - documentation for WriteFile() says that it *may* happen + Note: this bug doesn't happen on NT4, even though the + documentation for WriteFile() says that it *may* happen on any OS. */ char zeros[512]; int number_of_zeros_to_write = current_position - actual_length; @@ -1084,7 +1084,7 @@ fhandler_base::lseek (_off64_t offset, int whence) else { if (poff_high) - res += (_off64_t) *poff_high << 32; + res += (_off64_t) *poff_high << 32; /* When next we write(), we will check to see if *this* seek went beyond the end of the file, and back-seek and fill with zeros if so - DJ */ diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 242182ec3..327219d34 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1112,11 +1112,11 @@ fhandler_console::char_command (char c) case 9: /* dim */ dev_state->intensity = INTENSITY_DIM; break; - case 10: /* end alternate charset */ - dev_state->alternate_charset_active = false; + case 10: /* end alternate charset */ + dev_state->alternate_charset_active = false; break; - case 11: /* start alternate charset */ - dev_state->alternate_charset_active = true; + case 11: /* start alternate charset */ + dev_state->alternate_charset_active = true; break; case 24: dev_state->underline = false; diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 7b4866849..194f64602 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -190,7 +190,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf) if (oret) { /* We now have a valid handle, regardless of the "nohandle" state. - Since fhandler_base::open only calls CloseHandle if !nohandle, + Since fhandler_base::open only calls CloseHandle if !nohandle, we have to set it to false before calling close_fs and restore the state afterwards. */ res = fstat_by_handle (buf); @@ -270,7 +270,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, if (pc.has_attribute (FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_SPARSE_FILE) && get_io_handle () && !NtQueryInformationFile (get_io_handle (), &st, (PVOID) &fci, - sizeof fci, FileCompressionInformation)) + sizeof fci, FileCompressionInformation)) buf->st_blocks = (fci.CompressedSize.QuadPart + S_BLKSIZE - 1) / S_BLKSIZE; else /* Just compute no. of blocks from file size. */ @@ -287,14 +287,14 @@ fhandler_base::fstat_helper (struct __stat64 *buf, /* symlinks are everything for everyone! */ buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; get_file_attribute (pc.has_acls (), get_io_handle (), get_win32_name (), - NULL, &buf->st_uid, &buf->st_gid); + NULL, &buf->st_uid, &buf->st_gid); goto done; } else if (pc.issocket ()) buf->st_mode = S_IFSOCK; if (!get_file_attribute (pc.has_acls (), get_io_handle (), get_win32_name (), - &buf->st_mode, &buf->st_uid, &buf->st_gid)) + &buf->st_mode, &buf->st_uid, &buf->st_gid)) { /* If read-only attribute is set, modify ntsec return value */ if (pc.has_attribute (FILE_ATTRIBUTE_READONLY) && !pc.issymlink ()) @@ -396,7 +396,7 @@ fhandler_disk_file::fchmod (mode_t mode) ILLEGAL_UID, ILLEGAL_GID, mode) && allow_ntsec) res = 0; - + if (oret) close_fs (); } @@ -424,7 +424,7 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid) if (!pc.has_acls () || !allow_ntsec) { /* fake - if not supported, pretend we're like win95 - where it just works */ + where it just works */ return 0; } @@ -459,7 +459,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp) if (!pc.has_acls () || !allow_ntsec) { switch (cmd) - { + { struct __stat64 st; case SETACL: @@ -478,7 +478,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp) if (!(oret = open_fs (O_BINARY, 0))) return -1; } - if (!fstat_by_handle (&st)) + if (!fstat_by_handle (&st)) { aclbufp[0].a_type = USER_OBJ; aclbufp[0].a_id = st.st_uid; @@ -489,7 +489,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp) aclbufp[2].a_type = OTHER_OBJ; aclbufp[2].a_id = ILLEGAL_GID; aclbufp[2].a_perm = st.st_mode & S_IRWXO; - aclbufp[3].a_type = CLASS_OBJ; + aclbufp[3].a_type = CLASS_OBJ; aclbufp[3].a_id = ILLEGAL_GID; aclbufp[3].a_perm = S_IRWXU | S_IRWXG | S_IRWXO; res = MIN_ACL_ENTRIES; @@ -701,7 +701,7 @@ fhandler_disk_file::lock (int cmd, struct __flock64 *fl) if (win32_len == 0) { /* Special case if len == 0 for POSIX means lock to the end of - the entire file (and all future extensions). */ + the entire file (and all future extensions). */ /* CV, 2003-12-03: And yet another Win 9x bugginess. For some reason offset + length must be <= 0x100000000. I'm using 0xffffffff as upper border here, this should be sufficient. */ diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index a872c231e..7044c6686 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -43,7 +43,7 @@ details. */ to the device fails with EBUSY. If different processes open the audio device simultaneously, the results are unpredictable - usually the first one wins. - + 3. The wave device is reserved within a process from the time that the first read or write call has been successful until /dev/dsp has been closed by that process. During this reservation period @@ -93,7 +93,7 @@ class fhandler_dev_dsp::Audio::queue bool send (WAVEHDR *); // queue an item, returns true if successful bool recv (WAVEHDR **); // retrieve an item, returns true if successful - int query (); // return number of items queued + int query (); // return number of items queued private: int head_; @@ -131,7 +131,7 @@ class fhandler_dev_dsp::Audio_out: public Audio queue *Qapp2app_; // empty and unprepared blocks HWAVEOUT dev_; // The wave device int bufferIndex_; // offset into pHdr_->lpData - WAVEHDR *pHdr_; // data to be filled by write + WAVEHDR *pHdr_; // data to be filled by write WAVEHDR wavehdr_[MAX_BLOCKS]; char *bigwavebuffer_; // audio samples only @@ -356,7 +356,7 @@ fhandler_dev_dsp::Audio::blockSize (int rate, int bits, int channels) blockSize = ((bits / 8) * channels * rate) / 8; // approx 125ms per block // round up to multiple of 64 blockSize += 0x3f; - blockSize &= ~0x3f; + blockSize &= ~0x3f; return blockSize; } @@ -414,7 +414,7 @@ fhandler_dev_dsp::Audio_out::start (int rate, int bits, int channels) debug_printf ("freq=%d bits=%d channels=%d %s", rate, bits, channels, (rc != MMSYSERR_NOERROR) ? "FAIL" : "OK"); - + return (rc == MMSYSERR_NOERROR); } @@ -431,8 +431,8 @@ fhandler_dev_dsp::Audio_out::stop (bool immediately) { if (!immediately) { - sendcurrent (); // force out last block whatever size.. - waitforallsent (); // block till finished.. + sendcurrent (); // force out last block whatever size.. + waitforallsent (); // block till finished.. } rc = waveOutReset (dev_); @@ -817,7 +817,7 @@ fhandler_dev_dsp::Audio_in::start (int rate, int bits, int channels) debug_printf ("freq=%d bits=%d channels=%d %s", rate, bits, channels, (rc != MMSYSERR_NOERROR) ? "FAIL" : "OK"); - + return (rc == MMSYSERR_NOERROR); } @@ -920,7 +920,7 @@ fhandler_dev_dsp::Audio_in::read (char *pSampleData, int &nBytes) (this->*convert_) ((unsigned char *)pSampleData, bytes_to_read); nBytes += bytes_to_read; bufferIndex_ += bytes_to_read; - debug_printf ("got %d", bytes_to_read); + debug_printf ("got %d", bytes_to_read); break; // done; use remaining data in next call to read } else @@ -972,7 +972,7 @@ fhandler_dev_dsp::Audio_in::waitfordata () } } pHdr_ = pHdr; - bufferIndex_ = 0; + bufferIndex_ = 0; } void @@ -1069,7 +1069,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode) break; case O_RDONLY: audio_in_ = new Audio_in; - if (!audio_in_->query (audiofreq_, audiobits_, audiochannels_)) + if (!audio_in_->query (audiofreq_, audiobits_, audiochannels_)) { delete audio_in_; audio_in_ = NULL; @@ -1113,7 +1113,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode) set_errno (EIO); } debug_printf ("ACCMODE=0x%08x audio_in=%08x audio_out=%08x, rc=%d", - flags & O_ACCMODE, (int)audio_in_, (int)audio_out_, rc); + flags & O_ACCMODE, (int)audio_in_, (int)audio_out_, rc); return rc; } @@ -1209,8 +1209,8 @@ fhandler_dev_dsp::close (void) { if (exit_state != ES_NOT_EXITING) { // emergency close due to call to exit() or Ctrl-C: - // do not wait for all pending audio to be played - audio_out_->stop (true); + // do not wait for all pending audio to be played + audio_out_->stop (true); } delete audio_out_; audio_out_ = NULL; @@ -1335,7 +1335,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr) CASE (SNDCTL_DSP_SPEED) { if (audio_out_) - { + { RETURN_ERROR_WHEN_BUSY (audio_out_); audio_out_->stop (); if (audio_out_->query (*intptr, audiobits_, audiochannels_)) @@ -1367,7 +1367,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr) int nChannels = *intptr + 1; if (audio_out_) - { + { RETURN_ERROR_WHEN_BUSY (audio_out_); audio_out_->stop (); if (audio_out_->query (audiofreq_, audiobits_, nChannels)) @@ -1399,7 +1399,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr) int nChannels = *intptr; if (audio_out_) - { + { RETURN_ERROR_WHEN_BUSY (audio_out_); audio_out_->stop (); if (audio_out_->query (audiofreq_, audiobits_, nChannels)) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index e79d59d16..0331314e1 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -399,7 +399,7 @@ format_proc_meminfo (char *destbuf, size_t maxsize) ret = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi, size, &size); if (ret == STATUS_INFO_LENGTH_MISMATCH) - { + { free (spi); spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size); if (spi) @@ -416,7 +416,7 @@ format_proc_meminfo (char *destbuf, size_t maxsize) { PSYSTEM_PAGEFILE_INFORMATION spp = spi; do - { + { swap_total += spp->CurrentSize * getpagesize (); swap_free += (spp->CurrentSize - spp->TotalUsed) * getpagesize (); } @@ -711,13 +711,13 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize) cpuid (&cpuid_sig, &extra_info, &features2, &features1, 1); /* unsigned extended_family = (cpuid_sig & 0x0ff00000) >> 20, extended_model = (cpuid_sig & 0x000f0000) >> 16; */ - unsigned type = (cpuid_sig & 0x00003000) >> 12, - family = (cpuid_sig & 0x00000f00) >> 8, - model = (cpuid_sig & 0x000000f0) >> 4, - stepping = cpuid_sig & 0x0000000f; - unsigned brand_id = extra_info & 0x0000000f, - cpu_count = (extra_info & 0x00ff0000) >> 16, - apic_id = (extra_info & 0xff000000) >> 24; + unsigned type = (cpuid_sig & 0x00003000) >> 12, + family = (cpuid_sig & 0x00000f00) >> 8, + model = (cpuid_sig & 0x000000f0) >> 4, + stepping = cpuid_sig & 0x0000000f; + unsigned brand_id = extra_info & 0x0000000f, + cpu_count = (extra_info & 0x00ff0000) >> 16, + apic_id = (extra_info & 0xff000000) >> 24; const char *type_str; switch (type) { @@ -964,7 +964,7 @@ format_proc_partitions (char *destbuf, size_t maxsize) continue; char devname[16]; __small_sprintf (devname, "/dev/sd%c%d", - drive_number + 'a', + drive_number + 'a', partition + 1); device dev; dev.parse (devname); diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 84f657f76..edbae89bd 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -179,7 +179,7 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen) if (is_eom (ret)) set_errno (ENOSPC); else - __seterrno (); + __seterrno (); goto err; } diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 59ac65c5e..0616ff126 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -534,7 +534,7 @@ fhandler_serial::tcflush (int queue) set_errno (EINVAL); return -1; } - + if (!PurgeComm (get_handle (), flags)) { __seterrno (); diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index a0b6727f0..f37b2c9a2 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -631,7 +631,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) { cygheap_fdnew res_fd; if (res_fd >= 0 && fdsock (res_fd, &dev (), res)) - { + { if (get_addr_family () == AF_LOCAL) ((fhandler_socket *) res_fd)->set_sun_path (get_sun_path ()); ((fhandler_socket *) res_fd)->set_addr_family (get_addr_family ()); @@ -724,14 +724,14 @@ fhandler_socket::wait (HANDLE event, int flags) switch (WSAWaitForMultipleEvents (2, ev, FALSE, 10, FALSE)) { case WSA_WAIT_TIMEOUT: - ret = 0; + ret = 0; break; case WSA_WAIT_EVENT_0: if (!WSAEnumNetworkEvents (get_socket (), event, &evts)) { if (!evts.lNetworkEvents) { - ret = 0; + ret = 0; break; } if (evts.lNetworkEvents & FD_OOB) @@ -777,7 +777,7 @@ fhandler_socket::wait (HANDLE event, int flags) } break; case WSA_WAIT_EVENT_0 + 1: - WSASetLastError (WSAEINTR); + WSASetLastError (WSAEINTR); break; default: WSASetLastError (WSAEFAULT); @@ -841,14 +841,14 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags, HANDLE evt; if (prepare (evt, FD_CLOSE | FD_READ | (owner () ? FD_OOB : 0))) { - do - { + do + { DWORD lflags = (DWORD) flags; res = WSARecvFrom (get_socket (), &wsabuf, 1, &ret, &lflags, from, fromlen, NULL, NULL); - } - while (res == SOCKET_ERROR - && WSAGetLastError () == WSAEWOULDBLOCK + } + while (res == SOCKET_ERROR + && WSAGetLastError () == WSAEWOULDBLOCK && !closed () && !(res = wait (evt, flags))); release (evt); @@ -963,13 +963,13 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot) HANDLE evt; if (prepare (evt, FD_CLOSE | FD_READ | (owner () ? FD_OOB : 0))) { - do - { + do + { DWORD lflags = (DWORD) flags; res = WSARecvFrom (get_socket (), wsabuf, iovcnt, &ret, &lflags, from, fromlen, NULL, NULL); - } - while (res == SOCKET_ERROR + } + while (res == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK && !closed () && !(res = wait (evt, flags))); @@ -1040,7 +1040,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags, HANDLE evt; if (prepare (evt, FD_CLOSE | FD_WRITE | (owner () ? FD_OOB : 0))) { - do + do { res = WSASendTo (get_socket (), &wsabuf, 1, &ret, flags & MSG_WINMASK, @@ -1048,7 +1048,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags, tolen, NULL, NULL); } while (res == SOCKET_ERROR - && WSAGetLastError () == WSAEWOULDBLOCK + && WSAGetLastError () == WSAEWOULDBLOCK && !(res = wait (evt, 0)) && !closed ()); release (evt); @@ -1170,17 +1170,17 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot) HANDLE evt; if (prepare (evt, FD_CLOSE | FD_WRITE | (owner () ? FD_OOB : 0))) { - do - { + do + { res = WSASendTo (get_socket (), wsabuf, iovcnt, - &ret, flags, + &ret, flags, (struct sockaddr *) msg->msg_name, msg->msg_namelen, NULL, NULL); - } - while (res == SOCKET_ERROR - && WSAGetLastError () == WSAEWOULDBLOCK + } + while (res == SOCKET_ERROR + && WSAGetLastError () == WSAEWOULDBLOCK && !(res = wait (evt, 0)) - && !closed ()); + && !closed ()); release (evt); } } @@ -1381,7 +1381,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) case FIONREAD: res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p); if (res == SOCKET_ERROR) - set_winsock_errno (); + set_winsock_errno (); break; default: /* We must cancel WSAAsyncSelect (if any) before setting socket to diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index a8d0f3294..1e31ee1b0 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -142,7 +142,7 @@ mtinfo_drive::close (HANDLE mt, bool rewind) if (dirty == async_write_pending) lasterr = async_wait (mt, NULL); if (!lasterr) - { + { /* if last operation was writing, write a filemark */ debug_printf ("writing filemark"); write_marks (mt, TAPE_FILEMARKS, two_fm () ? 2 : 1); @@ -157,7 +157,7 @@ mtinfo_drive::close (HANDLE mt, bool rewind) else if (dirty == has_read && !rewind) { if (sysv ()) - { + { /* Under SYSV semantics, the tape is moved past the next file mark after read. */ if (part (partition)->emark == no_eof) @@ -166,7 +166,7 @@ mtinfo_drive::close (HANDLE mt, bool rewind) part (partition)->emark = eof; } else - { + { /* Under BSD semantics, we must check if the filemark has been inadvertendly crossed. If so cross the filemark backwards and position the tape right before EOF. */ @@ -265,9 +265,9 @@ mtinfo_drive::read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen) else if (IS_EOD (lasterr)) { if (part (partition)->emark == eof) - part (partition)->emark = IS_EOM (lasterr) ? eom : eod; + part (partition)->emark = IS_EOM (lasterr) ? eom : eod; else - { + { part (partition)->emark = IS_EOM (lasterr) ? eom_hit : eod_hit; lasterr = 0; } @@ -278,7 +278,7 @@ mtinfo_drive::read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen) /* This happens if the buffer is too small when in variable block size mode. Linux returns ENOMEM here. We're doing the same. */ if (lasterr == ERROR_MORE_DATA) - lasterr = ERROR_NOT_ENOUGH_MEMORY; + lasterr = ERROR_NOT_ENOUGH_MEMORY; } if (!lasterr) dirty = has_read; @@ -324,7 +324,7 @@ mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len) if (lasterr == ERROR_IO_PENDING) { if (async_writes () && mp ()->BlockSize == 0) - dirty = async_write_pending; + dirty = async_write_pending; else /* Wait for completion if a non-async write. */ lasterr = async_wait (mt, &bytes_written); @@ -349,9 +349,9 @@ mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len) { part (partition)->emark = no_eof; if (!lasterr) - dirty = has_written; + dirty = has_written; else if (lasterr == ERROR_IO_PENDING) - dirty = async_write_pending; + dirty = async_write_pending; } return error ("write"); } @@ -370,9 +370,9 @@ mtinfo_drive::get_pos (HANDLE mt, long *ppartition, long *pblock) partition = (long) p - 1; block = (long) low; if (ppartition) - *ppartition= partition; + *ppartition= partition; if (pblock) - *pblock = block; + *pblock = block; } else { @@ -408,7 +408,7 @@ mtinfo_drive::set_pos (HANDLE mt, int mode, long count, case TAPE_SPACE_RELATIVE_BLOCKS: case TAPE_SPACE_FILEMARKS: case TAPE_SPACE_SETMARKS: - if (!count) + if (!count) { lasterr = 0; goto out; @@ -417,7 +417,7 @@ mtinfo_drive::set_pos (HANDLE mt, int mode, long count, case TAPE_ABSOLUTE_BLOCK: case TAPE_LOGICAL_BLOCK: case TAPE_REWIND: - dont_wait = nowait () ? TRUE : FALSE; + dont_wait = nowait () ? TRUE : FALSE; break; } if (mode == TAPE_SPACE_FILEMARKS) @@ -437,9 +437,9 @@ mtinfo_drive::set_pos (HANDLE mt, int mode, long count, case TAPE_LOGICAL_BLOCK: get_pos (mt); part (partition)->initialize (block); - break; + break; case TAPE_REWIND: - if (!err) + if (!err) { block = 0; part (partition)->initialize (0); @@ -454,7 +454,7 @@ mtinfo_drive::set_pos (HANDLE mt, int mode, long count, get_pos (mt); part (partition)->initialize (block); part (partition)->emark = IS_EOM (err) ? eom : eod; - break; + break; case TAPE_SPACE_FILEMARKS: if (!err || IS_SM (err)) { @@ -469,7 +469,7 @@ mtinfo_drive::set_pos (HANDLE mt, int mode, long count, } else { - if (part (partition)->file >= 0) + if (part (partition)->file >= 0) part (partition)->file += count - undone; part (partition)->fblock = -1; part (partition)->smark = false; @@ -533,17 +533,17 @@ mtinfo_drive::set_pos (HANDLE mt, int mode, long count, block = 0; part (partition)->initialize (0); } - break; + break; case TAPE_SPACE_SETMARKS: get_pos (mt); part (partition)->block = block; - if (!err) + if (!err) { part (partition)->file = -1; part (partition)->fblock = -1; part (partition)->smark = true; } - break; + break; } lasterr = err; out: @@ -563,13 +563,13 @@ mtinfo_drive::create_partitions (HANDLE mt, long count) if (get_feature (TAPE_DRIVE_INITIATOR)) { if (count <= 0) - TAPE_FUNC (CreateTapePartition (mt, TAPE_INITIATOR_PARTITIONS, + TAPE_FUNC (CreateTapePartition (mt, TAPE_INITIATOR_PARTITIONS, count <= 0 ? 0 : 2, (DWORD) count)); } else if (get_feature (TAPE_DRIVE_FIXED)) { /* This is supposed to work for Tandberg SLR drivers up to version - 1.6 which missed to set the TAPE_DRIVE_INITIATOR flag. According + 1.6 which missed to set the TAPE_DRIVE_INITIATOR flag. According to Tandberg, CreateTapePartition(TAPE_FIXED_PARTITIONS) apparently does not ignore the dwCount parameter. Go figure! */ TAPE_FUNC (CreateTapePartition (mt, TAPE_FIXED_PARTITIONS, @@ -600,7 +600,7 @@ mtinfo_drive::set_partition (HANDLE mt, long count) if (sav_partition != partition) { if (partition < MAX_PARTITION_NUM - && part (partition)->block != block) + && part (partition)->block != block) part (partition)->initialize (block); } else if (sav_block != block && partition < MAX_PARTITION_NUM) @@ -608,7 +608,7 @@ mtinfo_drive::set_partition (HANDLE mt, long count) lasterr = err; } else - { + { partition = count; if (part (partition)->block == -1) part (partition)->initialize (0); @@ -710,9 +710,9 @@ mtinfo_drive::prepare (HANDLE mt, int action, bool is_auto) break; case TAPE_LOCK: lock = lasterr ? lock_error : is_auto ? auto_locked : locked; - break; + break; case TAPE_UNLOCK: - lock = lasterr ? lock_error : unlocked; + lock = lasterr ? lock_error : unlocked; break; } return error ("prepare"); @@ -813,12 +813,12 @@ mtinfo_drive::get_status (HANDLE mt, struct mtget *get) else get->mt_gstat |= GMT_EOF (-1); if (part (partition)->emark >= eod_hit) - get->mt_gstat |= GMT_EOD (-1); + get->mt_gstat |= GMT_EOD (-1); if (part (partition)->emark >= eom_hit) - get->mt_gstat |= GMT_EOT (-1); + get->mt_gstat |= GMT_EOT (-1); if (part (partition)->smark) - get->mt_gstat |= GMT_SM (-1); + get->mt_gstat |= GMT_SM (-1); get->mt_gstat |= GMT_ONLINE (-1); @@ -895,7 +895,7 @@ mtinfo_drive::set_options (HANDLE mt, long options) { buffer_writes ((options == 1)); } - break; + break; case MT_ST_BOOLEANS: buffer_writes (!!(options & MT_ST_BUFFER_WRITES)); async_writes (!!(options & MT_ST_ASYNC_WRITES)); @@ -913,10 +913,10 @@ mtinfo_drive::set_options (HANDLE mt, long options) if (sdp.ECC != dp ()->ECC || sdp.DataPadding != dp ()->DataPadding || sdp.ReportSetmarks != dp ()->ReportSetmarks) call_setparams = true; - break; + break; case MT_ST_SETBOOLEANS: case MT_ST_CLEARBOOLEANS: - set = (what == MT_ST_SETBOOLEANS); + set = (what == MT_ST_SETBOOLEANS); if (options & MT_ST_BUFFER_WRITES) buffer_writes (set); if (options & MT_ST_ASYNC_WRITES) @@ -940,7 +940,7 @@ mtinfo_drive::set_options (HANDLE mt, long options) if (sdp.ECC != dp ()->ECC || sdp.DataPadding != dp ()->DataPadding || sdp.ReportSetmarks != dp ()->ReportSetmarks) call_setparams = true; - break; + break; case MT_ST_EOT_WZ_SIZE: if (get_feature (TAPE_DRIVE_SET_EOT_WZ_SIZE)) { @@ -948,14 +948,14 @@ mtinfo_drive::set_options (HANDLE mt, long options) if (sdp.EOTWarningZoneSize != dp ()->EOTWarningZoneSize) call_setparams = true; } - break; + break; } if (call_setparams) { TAPE_FUNC (SetTapeParameters (mt, SET_TAPE_DRIVE_INFORMATION, &sdp)); int err = lasterr; if (!err) - { + { dp ()->ECC = sdp.ECC; dp ()->DataPadding = sdp.DataPadding; dp ()->ReportSetmarks = sdp.ReportSetmarks; @@ -973,10 +973,10 @@ mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf) if (cmd == MTIOCTOP) { if (__check_invalid_read_ptr (buf, sizeof (struct mtop))) - return ERROR_NOACCESS; + return ERROR_NOACCESS; struct mtop *op = (struct mtop *) buf; if (lasterr == ERROR_BUS_RESET) - { + { /* If a bus reset occurs, block further access to this device until the user rewinds, unloads or in any other way tries to maintain a well-known tape position. */ @@ -990,7 +990,7 @@ mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf) debug_printf ("Couldn't relock drive after bus reset."); lock = unlocked; } - } + } switch (op->mt_op) { case MTRESET: @@ -1120,13 +1120,13 @@ mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf) else if (cmd == MTIOCGET) { if (__check_null_invalid_struct (buf, sizeof (struct mtget))) - return ERROR_NOACCESS; + return ERROR_NOACCESS; get_status (mt, (struct mtget *) buf); } else if (cmd == MTIOCPOS) { if (__check_null_invalid_struct (buf, sizeof (struct mtpos))) - return ERROR_NOACCESS; + return ERROR_NOACCESS; if (!get_pos (mt)) ((struct mtpos *) buf)->mt_blkno = block; } @@ -1152,7 +1152,7 @@ mtinfo::initialize (void) magic = MTINFO_MAGIC; version = MTINFO_VERSION; for (unsigned i = 0; i < MAX_DRIVE_NUM; ++i) - drive (i)->initialize (i, true); + drive (i)->initialize (i, true); ReleaseMutex (mtx); CloseHandle (mtx); } @@ -1164,7 +1164,7 @@ mtinfo::initialize (void) api_fatal ("MT magic number screwed up: %lu, should be %lu", magic, MTINFO_MAGIC); if (version != MTINFO_VERSION) - system_printf ("MT version number mismatch: %lu, should be %lu", + system_printf ("MT version number mismatch: %lu, should be %lu", version, MTINFO_VERSION); } } @@ -1297,12 +1297,12 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen) buf += bytes_to_read; devbufstart += bytes_to_read; if (devbufstart == devbufend) - devbufstart = devbufend = 0; + devbufstart = devbufend = 0; /* If a switch to variable block_size occured, just return the buffer - remains until the buffer is empty, then proceed with usual variable + remains until the buffer is empty, then proceed with usual variable block size handling (one block per read call). */ if (!block_size) - len = 0; + len = 0; } if (len > 0) { @@ -1310,7 +1310,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen) debug_printf ("Creating event failed: %E"); size_t block_fit = !block_size ? len : rounddown(len, block_size); if (block_fit) - { + { debug_printf ("read %d bytes from tape (rest %d)", block_fit, len - block_fit); ret = mt->drive (driveno ())->read (get_handle (), mt_evt, buf, @@ -1324,7 +1324,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen) buf += block_fit; /* Only one block in each read call, please. */ if (!block_size) - len = 0; + len = 0; } else { len = 0; @@ -1333,7 +1333,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen) } } if (!ret && len > 0) - { + { debug_printf ("read %d bytes from tape (one block)", block_size); ret = mt->drive (driveno ())->read (get_handle (), mt_evt, devbuf, block_size); diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index bf17e8331..f7831fe9b 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -299,7 +299,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on goto out; /* DISCARD (FLUSHO) and tcflush can finish here. */ if (n == 0 && (get_ttyp ()->ti.c_lflag & FLUSHO || !buf)) - goto out; + goto out; if (n == 0 && is_nonblocking ()) { set_errno (EAGAIN); @@ -587,7 +587,7 @@ fhandler_tty_slave::open (int flags, mode_t) termios_printf ("SetProcessWindowStation %d, %E", b); } b = AllocConsole (); // will cause flashing if workstation - // stuff fails + // stuff fails termios_printf ("%d = AllocConsole (), %E", b); if (b) init_console_handler (); @@ -809,7 +809,7 @@ fhandler_tty_slave::read (void *ptr, size_t& len) /* On first peek determine no. of bytes to flush. */ if (!ptr && len == UINT_MAX) - len = (size_t) bytes_in_pipe; + len = (size_t) bytes_in_pipe; if (ptr && !vmin && !time_to_wait) { @@ -847,7 +847,7 @@ fhandler_tty_slave::read (void *ptr, size_t& len) len -= n; totalread += n; if (ptr) - { + { memcpy (ptr, buf, n); ptr = (char *) ptr + n; } @@ -864,7 +864,7 @@ fhandler_tty_slave::read (void *ptr, size_t& len) if (!bytes_in_pipe) break; continue; - } + } if (get_ttyp ()->read_retval < 0) // read error { @@ -1414,7 +1414,7 @@ fhandler_tty_master::init_console () return -1; console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY); - cygheap->open_fhs--; /* handled when individual fds are opened */ + cygheap->open_fhs--; /* handled when individual fds are opened */ console->uninterruptible_io (true); return 0; } diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index f46cb89d6..4edfc4128 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -185,7 +185,7 @@ getgrgid_r (__gid32_t gid, struct __group32 *grp, char *buffer, size_t bufsize, return ERANGE; struct __group32 *tempgr = internal_getgrgid (gid, true); - pthread_testcancel (); + pthread_testcancel (); if (!tempgr) return 0; @@ -242,7 +242,7 @@ getgrnam_r (const char *nam, struct __group32 *grp, char *buffer, return ERANGE; struct __group32 *tempgr = internal_getgrnam (nam, true); - pthread_testcancel (); + pthread_testcancel (); if (!tempgr) return 0; @@ -373,7 +373,7 @@ internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid) for (DWORD pg = 0; pg < groups->GroupCount; ++pg) if (sid == groups->Groups[pg].Sid && sid != well_known_world_sid) - { + { if (cnt < gidsetsize) grouplist[cnt] = gr->gr_gid; ++cnt; diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index 9ea5d9ba7..9f86f9911 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -145,7 +145,7 @@ sbrk (int n) newbrksize = commitbytes; if ((VirtualAlloc (cygheap->user_heap.top, newbrksize, MEM_RESERVE, PAGE_NOACCESS) - || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes, MEM_RESERVE, PAGE_NOACCESS)) + || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes, MEM_RESERVE, PAGE_NOACCESS)) && VirtualAlloc (cygheap->user_heap.top, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL) { cygheap->user_heap.max = (char *) cygheap->user_heap.max + pround (newbrksize); diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index 9ba585ecb..e42698e36 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -81,7 +81,7 @@ munge_threadfunc () /* no need for the overhead */; else { - for (i = 0; threadfunc_ix[i]; i++) + for (i = 0; threadfunc_ix[i]; i++) ebp[threadfunc_ix[i]] = (char *) threadfunc_fe; ((char **) _tlsbase)[OLDFUNC_OFFSET] = threadfunc; } diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index 4de52f230..71393fb87 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * CV 2003-09-10: Cygwin specific changes applied. Code simplified just - * for Cygwin alone. + * for Cygwin alone. */ #include "winsup.h" @@ -96,11 +96,11 @@ login_tty (int fd) if ((fdname = ttyname (fd))) { if (fd != STDIN_FILENO) - close (STDIN_FILENO); + close (STDIN_FILENO); if (fd != STDOUT_FILENO) - close (STDOUT_FILENO); + close (STDOUT_FILENO); if (fd != STDERR_FILENO) - close (STDERR_FILENO); + close (STDERR_FILENO); newfd = open (fdname, O_RDWR); close (newfd); } @@ -126,7 +126,7 @@ openpty (int *amaster, int *aslave, char *name, struct termios *termp, strcpy (pts, ptsname (master)); revoke (pts); if ((slave = open (pts, O_RDWR | O_NOCTTY)) >= 0) - { + { if (amaster) *amaster = master; if (aslave) @@ -251,11 +251,11 @@ setprogname (const char *newprogname) if (!check_null_str_errno (newprogname)) { /* Per BSD man page, setprogname keeps a pointer to the last - path component of the argument. It does *not* copy the + path component of the argument. It does *not* copy the argument before. */ __progname = strrchr (newprogname, '/'); if (__progname) - ++__progname; + ++__progname; else __progname = (char *)newprogname; } diff --git a/winsup/cygwin/msg.cc b/winsup/cygwin/msg.cc index 7e80f669b..d226cc0c0 100644 --- a/winsup/cygwin/msg.cc +++ b/winsup/cygwin/msg.cc @@ -105,29 +105,29 @@ msgctl (int msqid, int cmd, struct msqid_ds *buf) case IPC_STAT: if (__check_null_invalid_struct_errno (buf, sizeof *buf)) return -1; - break; + break; case IPC_SET: if (__check_invalid_read_ptr_errno (buf, sizeof *buf)) return -1; - break; + break; case IPC_RMID: - break; + break; case IPC_INFO: /* msqid == 0: Request for msginfo struct. */ if (!msqid && __check_null_invalid_struct_errno (buf, sizeof (struct msginfo))) return -1; /* Otherwise, request msqid entries from internal msqid_ds array. */ - if (msqid) + if (msqid) if (__check_null_invalid_struct_errno (buf, msqid * sizeof (struct msqid_ds))) return -1; - break; + break; case MSG_INFO: - if (__check_null_invalid_struct_errno (buf, sizeof (struct msg_info))) + if (__check_null_invalid_struct_errno (buf, sizeof (struct msg_info))) return -1; - break; + break; default: - syscall_printf ("-1 [%d] = msgctl ()", EINVAL); + syscall_printf ("-1 [%d] = msgctl ()", EINVAL); set_errno (EINVAL); return -1; } @@ -137,7 +137,7 @@ msgctl (int msqid, int cmd, struct msqid_ds *buf) syscall_printf ("-1 [%d] = msgctl ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.retval (); @@ -159,7 +159,7 @@ msgget (key_t key, int msgflg) syscall_printf ("-1 [%d] = msgget ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.retval (); @@ -175,7 +175,7 @@ msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) { #ifdef USE_SERVER syscall_printf ("msgrcv (msqid = %d, msgp = %p, msgsz = %d, " - "msgtyp = %d, msgflg = 0x%x)", + "msgtyp = %d, msgflg = 0x%x)", msqid, msgp, msgsz, msgtyp, msgflg); if (__check_null_invalid_struct_errno (msgp, msgsz)) return -1; @@ -185,7 +185,7 @@ msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) syscall_printf ("-1 [%d] = msgrcv ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.rcvval (); @@ -210,7 +210,7 @@ msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) syscall_printf ("-1 [%d] = msgsnd ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.retval (); diff --git a/winsup/cygwin/mtinfo.h b/winsup/cygwin/mtinfo.h index 52dd6b24f..cf694964e 100644 --- a/winsup/cygwin/mtinfo.h +++ b/winsup/cygwin/mtinfo.h @@ -84,7 +84,7 @@ class mtinfo_drive inline int error (const char *str) { if (lasterr) - debug_printf ("%s: Win32 error %d", lasterr); + debug_printf ("%s: Win32 error %d", lasterr); return lasterr; } inline bool get_feature (DWORD parm) diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 58c3a9fab..b958e4365 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1953,7 +1953,7 @@ cygwin_rresvport (int *port) cygheap_fdnew res_fd; if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res)) - res = res_fd; + res = res_fd; else res = -1; } diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index 536f4ae90..3175d92aa 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -78,7 +78,7 @@ pwdgrp::read_passwd () !internal_getpwuid (myself->uid)))) { static char linebuf[1024]; // must be static and - // should not be NO_COPY + // should not be NO_COPY (void) cygheap->user.ontherange (CH_HOME, NULL); snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh", cygheap->user.name (), diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 6ab938bd1..102f51338 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -461,20 +461,20 @@ path_conv::set_normalized_path (const char *path_copy) PUNICODE_STRING path_conv::get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath) { - if (path[0] != '\\') /* X:\... or NUL, etc. */ + if (path[0] != '\\') /* X:\... or NUL, etc. */ { str2buf2uni (upath, wpath, "\\??\\"); str2buf2uni_cat (upath, path); } - else if (path[1] != '\\') /* \Device\... */ + else if (path[1] != '\\') /* \Device\... */ str2buf2uni (upath, wpath, path); - else if (path[2] != '.' - || path[3] != '\\') /* \\server\share\... */ + else if (path[2] != '.' + || path[3] != '\\') /* \\server\share\... */ { str2buf2uni (upath, wpath, "\\??\\UNC\\"); str2buf2uni_cat (upath, path + 2); - } - else /* \\.\device */ + } + else /* \\.\device */ { str2buf2uni (upath, wpath, "\\??\\"); str2buf2uni_cat (upath, path + 4); @@ -550,21 +550,21 @@ path_conv::check (const char *src, unsigned opt, into account during processing */ if (tail > path_copy + 1) { - if (isslash (tail[-1])) - { + if (isslash (tail[-1])) + { need_directory = 1; tail--; } - /* Remove trailing dots and spaces which are ignored by Win32 functions but + /* Remove trailing dots and spaces which are ignored by Win32 functions but not by native NT functions. */ - while (tail[-1] == '.' || tail[-1] == ' ') + while (tail[-1] == '.' || tail[-1] == ' ') tail--; - if (tail > path_copy + 1 && isslash (tail[-1])) - { + if (tail > path_copy + 1 && isslash (tail[-1])) + { error = ENOENT; - return; + return; } - } + } path_end = tail; *tail = '\0'; @@ -1017,7 +1017,7 @@ normalize_win32_path (const char *src, char *dst, char **tail) else if (src[0] == '.' && src[1] == '.' /* dst must be greater than dst_start */ && dst[-1] == '\\') - { + { if (isdirsep (src[2]) || src[2] == 0) { /* Back up over /, but not if it's the first one. */ @@ -3316,7 +3316,7 @@ chdir (const char *in_dir) defeat the Windows 95 (i.e. MS-DOS) tendency of returning to the last directory visited on the given drive. */ if (isdrive (native_dir) && !native_dir[2]) - { + { path.get_win32 ()[2] = '\\'; path.get_win32 ()[3] = '\0'; } @@ -3325,7 +3325,7 @@ chdir (const char *in_dir) The posix_cwd is just path.normalized_path. In other cases we let cwd.set obtain the Posix path through the mount table. */ - if (!path.has_symlinks () && !isabspath (in_dir)) + if (!isdrive(path.normalized_path)) posix_cwd = path.normalized_path; res = 0; doit = true; @@ -3674,10 +3674,10 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit) { cwd_lock->acquire (); if (doit && !SetCurrentDirectory (win32_cwd)) - { - __seterrno (); - goto out; - } + { + __seterrno (); + goto out; + } } /* If there is no win32 path or it has the form c:xxx, get the value */ if (!win32_cwd || (isdrive (win32_cwd) && win32_cwd[2] != '\\')) @@ -3685,13 +3685,13 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit) int i; DWORD len, dlen; for (i = 0, dlen = CYG_MAX_PATH/3; i < 2; i++, dlen = len) - { + { win32 = (char *) crealloc (win32, dlen); if ((len = GetCurrentDirectoryA (dlen, win32)) < dlen) break; } if (len == 0) - { + { __seterrno (); debug_printf ("GetCurrentDirectory, %E"); win32_cwd = pathbuf; /* Force lock release */ diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc index 8f9bda911..4afbac858 100644 --- a/winsup/cygwin/poll.cc +++ b/winsup/cygwin/poll.cc @@ -104,7 +104,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout) { case -1: /* Something weird happened */ /* When select returns that data is available, - that could mean that the socket is in + that could mean that the socket is in listen mode and a client tries to connect. Unfortunately, recvfrom() doesn't make much sense then. It returns WSAENOTCONN in that diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc index 548c65957..0f4b2fec7 100644 --- a/winsup/cygwin/sched.cc +++ b/winsup/cygwin/sched.cc @@ -284,7 +284,7 @@ sched_rr_get_interval (pid_t pid, struct timespec *interval) forprocid = 0; reg_key reg (HKEY_LOCAL_MACHINE, KEY_READ, "SYSTEM", "CurrentControlSet", - "Control", "PriorityControl", NULL); + "Control", "PriorityControl", NULL); if (reg.error ()) { set_errno (ESRCH); diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index b97dcd028..852ef5b52 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -385,7 +385,7 @@ enable_restore_privilege () { int res = 2 + set_process_privilege (SE_RESTORE_NAME, true, issetuid); if (!issetuid) - saved_res = res; + saved_res = res; } } diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 29dd0a056..6ae52e9ff 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1077,7 +1077,7 @@ out: of the SD on success. Unfortunately NT returns 0 in `len' on success, while W2K returns the correct size! - + 2003-11-26: Now the function allocates the space needed by itself so it knows the real size and returns it in the security_descriptor object. */ @@ -1142,7 +1142,7 @@ write_sd (HANDLE fh, const char *file, security_descriptor &sd) NULL)) == INVALID_HANDLE_VALUE) break; if (fh && (ret = NtSetSecurityObject (fh, - DACL_SECURITY_INFORMATION + DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION, sd)) == STATUS_SUCCESS) @@ -1768,7 +1768,7 @@ set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa, InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)psa->lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); psa->lpSecurityDescriptor = alloc_sd (geteuid32 (), getegid32 (), - attribute, sd); + attribute, sd); } static int diff --git a/winsup/cygwin/sem.cc b/winsup/cygwin/sem.cc index c623db122..1d7f53c67 100644 --- a/winsup/cygwin/sem.cc +++ b/winsup/cygwin/sem.cc @@ -116,7 +116,7 @@ semctl (int semid, int semnum, int cmd, ...) syscall_printf ("-1 [%d] = semctl ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.retval (); @@ -139,7 +139,7 @@ semget (key_t key, int nsems, int semflg) syscall_printf ("-1 [%d] = semget ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.retval (); @@ -164,7 +164,7 @@ semop (int semid, struct sembuf *sops, size_t nsops) syscall_printf ("-1 [%d] = semop ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } return request.retval (); diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 42beb54f9..65adc3e27 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -97,7 +97,7 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, if (!name) mapname = NULL; else - mapname = shared_name (map_buf, name, n); + mapname = shared_name (map_buf, name, n); if (!(shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, psa, PAGE_READWRITE, 0, size, mapname))) api_fatal ("CreateFileMapping %s, %E. Terminating.", mapname); @@ -163,7 +163,7 @@ user_shared_initialize (bool reinit) if (!cygwin_user_h) { if (wincap.has_security ()) - { + { cygpsid tu (cygheap->user.sid ()); tu.string (name); } diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc index 4bae7b2d2..a5fbe3a71 100644 --- a/winsup/cygwin/shm.cc +++ b/winsup/cygwin/shm.cc @@ -133,9 +133,9 @@ fixup_shms_after_fork () SLIST_FOREACH (sph_entry, &sph_list, sph_next) { vm_object_t ptr = MapViewOfFileEx(sph_entry->hdl, sph_entry->access, - 0, 0, sph_entry->size, sph_entry->ptr); + 0, 0, sph_entry->size, sph_entry->ptr); if (ptr != sph_entry->ptr) - api_fatal ("MapViewOfFileEx (%p), %E. Terminating.", sph_entry->ptr); + api_fatal ("MapViewOfFileEx (%p), %E. Terminating.", sph_entry->ptr); } return 0; } @@ -161,13 +161,13 @@ shmat (int shmid, const void *shmaddr, int shmflg) if (!ssh_entry) { /* The shmid is unknown to this process so far. Try to get it from - the server if it exists. Use special internal call to shmget, + the server if it exists. Use special internal call to shmget, which interprets the key as a shmid and only returns a valid shmid if one exists. Since shmctl inserts a new entry for this shmid into ssh_list automatically, we just have to go through that list again. If that still fails, well, bad luck. */ if (shmid && shmget ((key_t) shmid, 0, IPC_KEY_IS_SHMID) != -1) - { + { SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) { if (ssh_entry->shmid == shmid) @@ -175,7 +175,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) } } if (!ssh_entry) - { + { /* Invalid shmid */ set_errno (EINVAL); return (void *) -1; @@ -185,11 +185,11 @@ shmat (int shmid, const void *shmaddr, int shmflg) if (shmaddr) { if (shmflg & SHM_RND) - attach_va = (vm_object_t)((vm_offset_t)shmaddr & ~(SHMLBA-1)); + attach_va = (vm_object_t)((vm_offset_t)shmaddr & ~(SHMLBA-1)); else attach_va = (vm_object_t)shmaddr; /* Don't even bother to call anything if shmaddr is NULL or - not aligned. */ + not aligned. */ if (!attach_va || (vm_offset_t)attach_va % SHMLBA) { set_errno (EINVAL); @@ -222,7 +222,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) delete sph_entry; set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return (void *) -1; } sph_entry->ptr = ptr; @@ -250,7 +250,7 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf) case IPC_SET: if (__check_null_invalid_struct_errno (buf, sizeof (struct shmid_ds))) return -1; - break; + break; case IPC_INFO: /* shmid == 0: Request for shminfo struct. */ if (!shmid @@ -260,11 +260,11 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf) if (shmid) if (__check_null_invalid_struct_errno (buf, shmid * sizeof (struct shmid_ds))) return -1; - break; + break; case SHM_INFO: - if (__check_null_invalid_struct_errno (buf, sizeof (struct shm_info))) + if (__check_null_invalid_struct_errno (buf, sizeof (struct shm_info))) return -1; - break; + break; } client_request_shm request (shmid, cmd, buf); if (request.make_request () == -1 || request.retval () == -1) @@ -272,7 +272,7 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf) syscall_printf ("-1 [%d] = shmctl ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } if (cmd == IPC_RMID) @@ -280,7 +280,7 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf) /* The process must cleanup its own storage... */ shm_shmid_list *ssh_entry, *ssh_next_entry; SLIST_FOREACH_SAFE (ssh_entry, &ssh_list, ssh_next, ssh_next_entry) - { + { if (ssh_entry->shmid == shmid) { SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); @@ -310,7 +310,7 @@ shmdt (const void *shmaddr) syscall_printf ("-1 [%d] = shmdt ()", request.error_code ()); set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } shm_attached_list *sph_entry, *sph_next_entry; @@ -318,7 +318,7 @@ shmdt (const void *shmaddr) SLIST_FOREACH_SAFE (sph_entry, &sph_list, sph_next, sph_next_entry) { if (sph_entry->ptr == shmaddr) - { + { SLIST_REMOVE (&sph_list, sph_entry, shm_attached_list, sph_next); /* ...and unmap view. */ UnmapViewOfFile (sph_entry->ptr); @@ -354,7 +354,7 @@ shmget (key_t key, size_t size, int shmflg) delete ssh_new_entry; set_errno (request.error_code ()); if (request.error_code () == ENOSYS) - raise (SIGSYS); + raise (SIGSYS); return -1; } int shmid = request.retval (); /* Shared mem ID */ @@ -363,7 +363,7 @@ shmget (key_t key, size_t size, int shmflg) SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) { if (ssh_entry->shmid == shmid) - { + { /* We already maintain an entry for this shmid. That means, the hdl returned by cygserver is a superfluous duplicate of the original hdl maintained by cygserver. We can safely diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 055029979..47096f086 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -426,7 +426,7 @@ proc_subproc (DWORD what, DWORD val) scan_wait: /* Scan the linked list of wait()ing threads. If a wait's parameters - match this pid, then activate it. */ + match this pid, then activate it. */ for (w = &waitq_head; w->next != NULL; w = w->next) { if ((potential_match = checkstate (w)) > 0) @@ -759,7 +759,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) if (!WriteFile (sendsig, &pack, sizeof (pack), &nb, NULL) || nb != sizeof (pack)) { /* Couldn't send to the pipe. This probably means that the - process is exiting. */ + process is exiting. */ if (!its_me) { sigproc_printf ("WriteFile for pipe %p failed, %E", sendsig); diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index e7a698bb7..b524e61f3 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -916,7 +916,7 @@ chmod (const char *path, mode_t mode) fhandler_base *fh; if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW, stat_suffixes))) goto error; - + if (fh->error ()) { debug_printf ("got %d error from build_fh_name", fh->error ()); @@ -1058,10 +1058,10 @@ stat_worker (const char *name, struct __stat64 *buf, int nofollow) if (check_null_invalid_struct_errno (buf)) goto error; - if (!(fh = build_fh_name (name, NULL, nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, + if (!(fh = build_fh_name (name, NULL, nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, stat_suffixes))) goto error; - + if (fh->error ()) { debug_printf ("got %d error from build_fh_name", fh->error ()); @@ -1162,7 +1162,7 @@ access (const char *fn, int flags) { fhandler_base *fh = build_fh_name (fn, NULL, PC_SYM_FOLLOW, stat_suffixes); if (fh) - { + { res = fh->fhaccess (flags); delete fh; } @@ -1492,7 +1492,7 @@ ttyname_r (int fd, char *buf, size_t buflen) else if (buflen < strlen (cfd->ttyname ()) + 1) ret = ERANGE; else - strcpy (buf, cfd->ttyname ()); + strcpy (buf, cfd->ttyname ()); } debug_printf ("returning %d tty: %s", ret, ret ? "NULL" : buf); return ret; diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 4de8d8738..66e4fc441 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -52,7 +52,7 @@ sysconf (int in) case _SC_SAVED_IDS: return _POSIX_SAVED_IDS; case _SC_LOGIN_NAME_MAX: - return LOGIN_NAME_MAX; + return LOGIN_NAME_MAX; case _SC_GETPW_R_SIZE_MAX: case _SC_GETGR_R_SIZE_MAX: return 16*1024; @@ -104,7 +104,7 @@ sysconf (int in) } break; case _SC_AVPHYS_PAGES: - if (wincap.supports_smp ()) + if (wincap.supports_smp ()) { NTSTATUS ret; SYSTEM_PERFORMANCE_INFORMATION spi; @@ -124,7 +124,7 @@ sysconf (int in) case _SC_RTSIG_MAX: return RTSIG_MAX; case _SC_TTY_NAME_MAX: - return TTY_NAME_MAX; + return TTY_NAME_MAX; } /* Invalid input or unimplemented sysconf name */ diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 8c36dfbce..4cac624b8 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -173,7 +173,7 @@ pthread::init_mainthread () { thread = new pthread (); if (!thread) - api_fatal ("failed to create mainthread object"); + api_fatal ("failed to create mainthread object"); } set_tls_self_pointer (thread); @@ -1436,9 +1436,9 @@ bool pthread_mutex::is_good_initializer (pthread_mutex_t const *mutex) { if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) != VALID_STATIC_OBJECT) + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, + PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) != VALID_STATIC_OBJECT) return false; return true; } @@ -1447,9 +1447,9 @@ bool pthread_mutex::is_good_initializer_or_object (pthread_mutex_t const *mutex) { if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == INVALID_OBJECT) + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, + PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == INVALID_OBJECT) return false; return true; } @@ -1458,9 +1458,9 @@ bool pthread_mutex::is_good_initializer_or_bad_object (pthread_mutex_t const *mutex) { if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == VALID_OBJECT) + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, + PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == VALID_OBJECT) return false; return true; } @@ -1662,7 +1662,7 @@ semaphore::semaphore (const char *sem_name, int oflag, mode_t mode, unsigned int value) : verifyable_object (SEM_MAGIC), shared (PTHREAD_PROCESS_SHARED), - currentvalue (value), /* Unused for named semaphores. */ + currentvalue (value), /* Unused for named semaphores. */ name (NULL) { if (oflag & O_CREAT) @@ -1853,7 +1853,7 @@ check_valid_pointer (void const *pointer) verifyable_object_state verifyable_object_isvalid (void const * objectptr, long magic, void *static_ptr1, - void *static_ptr2, void *static_ptr3) + void *static_ptr2, void *static_ptr3) { verifyable_object **object = (verifyable_object **)objectptr; if (check_valid_pointer (object)) @@ -2880,8 +2880,8 @@ pthread_equal (pthread_t t1, pthread_t t2) int pthread_mutex::init (pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr, - const pthread_mutex_t initializer) + const pthread_mutexattr_t *attr, + const pthread_mutex_t initializer) { pthread_mutex_t new_mutex; @@ -2907,11 +2907,11 @@ pthread_mutex::init (pthread_mutex_t *mutex, if (!attr && initializer) { if (initializer == PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) - new_mutex->type = PTHREAD_MUTEX_RECURSIVE; + new_mutex->type = PTHREAD_MUTEX_RECURSIVE; else if (initializer == PTHREAD_NORMAL_MUTEX_INITIALIZER_NP) - new_mutex->type = PTHREAD_MUTEX_NORMAL; + new_mutex->type = PTHREAD_MUTEX_NORMAL; else if (initializer == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) - new_mutex->type = PTHREAD_MUTEX_ERRORCHECK; + new_mutex->type = PTHREAD_MUTEX_ERRORCHECK; } *mutex = new_mutex; diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index b560f73dd..712e36f03 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -121,9 +121,9 @@ typedef enum } verifyable_object_state; verifyable_object_state verifyable_object_isvalid (void const * objectptr, long magic, - void *static_ptr1 = NULL, - void *static_ptr2 = NULL, - void *static_ptr3 = NULL); + void *static_ptr1 = NULL, + void *static_ptr2 = NULL, + void *static_ptr3 = NULL); template inline void List_insert (list_node *&head, list_node *node) @@ -279,7 +279,7 @@ public: static bool can_be_unlocked (pthread_mutex_t const *mutex); static void init_mutex (); static int init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr, - const pthread_mutex_t initializer = NULL); + const pthread_mutex_t initializer = NULL); unsigned long lock_counter; HANDLE win32_obj_id; diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index e374acb7c..eea5ec42e 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -325,19 +325,19 @@ tty::alive (const char *fmt) return ev != NULL; } -HANDLE +HANDLE tty::open_output_mutex () { return open_mutex (OUTPUT_MUTEX); -} +} HANDLE tty::open_input_mutex () { return open_mutex (INPUT_MUTEX); -} +} -HANDLE +HANDLE tty::open_mutex (const char *mutex) { char buf[CYG_MAX_PATH]; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 2bf164ff6..4c9dacb8f 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -75,7 +75,7 @@ cygheap_user::init () BOOL acl_exists, dummy; TOKEN_DEFAULT_DACL dacl; - if (GetSecurityDescriptorDacl (psd, &acl_exists, + if (GetSecurityDescriptorDacl (psd, &acl_exists, &dacl.DefaultDacl, &dummy) && acl_exists && dacl.DefaultDacl) { @@ -118,7 +118,7 @@ internal_getlogin (cygheap_user &user) HANDLE ptok; if (gsid != user.groups.pgsid && OpenProcessToken (hMainProc, TOKEN_ADJUST_DEFAULT, &ptok)) - { + { /* Set primary group to the group in /etc/passwd. */ if (!SetTokenInformation (ptok, TokenPrimaryGroup, &gsid, sizeof gsid)) @@ -148,7 +148,7 @@ uinfo_init () /* Conditions must match those in spawn to allow starting child processes with ruid != euid and rgid != egid. */ else if (cygheap->user.issetuid () - && cygheap->user.saved_uid == cygheap->user.real_uid + && cygheap->user.saved_uid == cygheap->user.real_uid && cygheap->user.saved_gid == cygheap->user.real_gid && !cygheap->user.groups.issetgroups ()) { diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 4018a6e62..0a9307068 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -581,7 +581,7 @@ wincapc::init () if (strcmp (version.szCSDVersion, "Service Pack 4") < 0) caps = &wincap_nt4; else - { + { caps = &wincap_nt4sp4; if (strcmp (version.szCSDVersion, "Service Pack 6") >= 0) has_osversioninfoex = true; @@ -591,7 +591,7 @@ wincapc::init () os = "NT"; has_osversioninfoex = true; switch (version.dwMinorVersion) - { + { case 0: caps = &wincap_2000; break;