aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-09-19 15:12:48 +0000
committerChristopher Faylor <me@cgf.cx>2002-09-19 15:12:48 +0000
commit580e99a151bdeea4141a0bf03f1e57f07d288ee7 (patch)
treeaafb0b3d24468b3f08c848b6c018c261267aca30
parent776044d5540355f809ee758580a3235d38084b12 (diff)
downloadnewlib-580e99a151bdeea4141a0bf03f1e57f07d288ee7.zip
newlib-580e99a151bdeea4141a0bf03f1e57f07d288ee7.tar.gz
newlib-580e99a151bdeea4141a0bf03f1e57f07d288ee7.tar.bz2
Cleanup calls to CreateFile throughout.
* dcrt0.cc (__api_fatal): Correctly check for failing return from CreateFile. * assert.cc (__assert): Don't check return value from CreateFile for NULL. * fhandler_console.cc (set_console_state_for_spawn): Ditto. * fork.cc (fork_parent): Ditto.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/assert.cc6
-rw-r--r--winsup/cygwin/dcrt0.cc8
-rw-r--r--winsup/cygwin/fhandler.cc2
-rw-r--r--winsup/cygwin/fhandler_console.cc20
-rw-r--r--winsup/cygwin/fork.cc10
-rw-r--r--winsup/cygwin/ntea.cc11
-rw-r--r--winsup/cygwin/shared.cc10
-rw-r--r--winsup/cygwin/spawn.cc11
-rw-r--r--winsup/cygwin/syscalls.cc23
-rw-r--r--winsup/cygwin/times.cc12
11 files changed, 56 insertions, 65 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 92fd485..9915b3c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2002-09-19 Christopher Faylor <cgf@redhat.com>
+
+ Cleanup calls to CreateFile throughout.
+ * dcrt0.cc (__api_fatal): Correctly check for failing return from CreateFile.
+ * assert.cc (__assert): Don't check return value from CreateFile for NULL.
+ * fhandler_console.cc (set_console_state_for_spawn): Ditto.
+ * fork.cc (fork_parent): Ditto.
+
2002-09-18 Christopher Faylor <cgf@redhat.com>
* cygthread.cc (cygthread::initialized): Avoid copying on fork or some
diff --git a/winsup/cygwin/assert.cc b/winsup/cygwin/assert.cc
index fbce875..063c7b8 100644
--- a/winsup/cygwin/assert.cc
+++ b/winsup/cygwin/assert.cc
@@ -28,9 +28,9 @@ __assert (const char *file, int line, const char *failedexpr)
/* If we don't have a console in a Windows program, then bring up a
message box for the assertion failure. */
- h = CreateFileA ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (h == INVALID_HANDLE_VALUE || h == 0)
+ h = CreateFile ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (h == INVALID_HANDLE_VALUE)
{
char *buf;
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index ee9d42e..52b8202 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -1057,10 +1057,10 @@ __api_fatal (const char *fmt, ...)
a serious error. */
if (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) != FILE_TYPE_CHAR)
{
- HANDLE h = CreateFileA ("CONOUT$", GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_WRITE | FILE_SHARE_WRITE, &sec_none,
- OPEN_EXISTING, 0, 0);
- if (h)
+ HANDLE h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_WRITE | FILE_SHARE_WRITE,
+ &sec_none, OPEN_EXISTING, 0, 0);
+ if (h != INVALID_HANDLE_VALUE)
(void) WriteFile (h, buf, len, &done, 0);
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 0b7bf65..2726a2a 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -436,7 +436,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
x = CreateFile (get_win32_name (), access, shared, &sa, creation_distribution,
file_attributes, 0);
- syscall_printf ("%p = CreateFileA (%s, %p, %p, %p, %p, %p, 0)",
+ syscall_printf ("%p = CreateFile (%s, %p, %p, %p, %p, %p, 0)",
x, get_win32_name (), access, shared, &sa,
creation_distribution, file_attributes);
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 895a98b..6a997f3 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -135,11 +135,11 @@ tty_list::get_tty (int n)
int __stdcall
set_console_state_for_spawn ()
{
- HANDLE h = CreateFileA ("CONIN$", GENERIC_READ, FILE_SHARE_WRITE,
- &sec_none_nih, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE h = CreateFile ("CONIN$", GENERIC_READ, FILE_SHARE_WRITE,
+ &sec_none_nih, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+ NULL);
- if (h == INVALID_HANDLE_VALUE || h == NULL)
+ if (h == INVALID_HANDLE_VALUE)
return 0;
if (shared_console_info != NULL)
@@ -547,9 +547,9 @@ fhandler_console::open (path_conv *, int flags, mode_t)
set_flags ((flags & ~O_TEXT) | O_BINARY);
/* Open the input handle as handle_ */
- h = CreateFileA ("CONIN$", GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
- OPEN_EXISTING, 0, 0);
+ h = CreateFile ("CONIN$", GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
+ OPEN_EXISTING, 0, 0);
if (h == INVALID_HANDLE_VALUE)
{
@@ -559,9 +559,9 @@ fhandler_console::open (path_conv *, int flags, mode_t)
set_io_handle (h);
set_r_no_interrupt (1); // Handled explicitly in read code
- h = CreateFileA ("CONOUT$", GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
- OPEN_EXISTING, 0, 0);
+ h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
+ OPEN_EXISTING, 0, 0);
if (h == INVALID_HANDLE_VALUE)
{
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index dab9ace..673d0d0 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -362,12 +362,12 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
/* If we don't have a console, then don't create a console for the
child either. */
- HANDLE console_handle = CreateFileA ("CONOUT$", GENERIC_WRITE,
- FILE_SHARE_WRITE, &sec_none_nih,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
- NULL);
+ HANDLE console_handle = CreateFile ("CONOUT$", GENERIC_WRITE,
+ FILE_SHARE_WRITE, &sec_none_nih,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+ NULL);
- if (console_handle != INVALID_HANDLE_VALUE && console_handle != 0)
+ if (console_handle != INVALID_HANDLE_VALUE)
CloseHandle (console_handle);
else
c_flags |= DETACHED_PROCESS;
diff --git a/winsup/cygwin/ntea.cc b/winsup/cygwin/ntea.cc
index 224478b..95b5444 100644
--- a/winsup/cygwin/ntea.cc
+++ b/winsup/cygwin/ntea.cc
@@ -91,12 +91,11 @@ NTReadEA (const char *file, const char *attrname, char *attrbuf, int len)
int easize;
hFileSource = CreateFile (file, FILE_READ_EA,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- &sec_none_nih, // sa
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ &sec_none_nih, // sa
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL);
if (hFileSource == INVALID_HANDLE_VALUE)
return 0;
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 3031ae7..5c3beb9 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -60,13 +60,9 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr)
TRUE, mapname);
}
if (!shared_h &&
- !(shared_h = CreateFileMappingA (INVALID_HANDLE_VALUE,
- &sec_all,
- PAGE_READWRITE,
- 0,
- size,
- mapname)))
- api_fatal ("CreateFileMappingA, %E. Terminating.");
+ !(shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, &sec_all,
+ PAGE_READWRITE, 0, size, mapname)))
+ api_fatal ("CreateFileMapping, %E. Terminating.");
}
shared = (shared_info *) MapViewOfFileEx (shared_h,
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 8c1c18a..193f593 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -420,13 +420,10 @@ spawn_guts (const char * prog_arg, const char *const *argv,
that it is NOT a script file */
while (*ext == '\0')
{
- HANDLE hnd = CreateFileA (real_path,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- &sec_none_nih,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- 0);
+ HANDLE hnd = CreateFile (real_path, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ &sec_none_nih, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, 0);
if (hnd == INVALID_HANDLE_VALUE)
{
__seterrno ();
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 8c2b96b..650cad8 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -648,15 +648,10 @@ _link (const char *a, const char *b)
BOOL bSuccess;
- hFileSource = CreateFile (
- real_a,
- FILE_WRITE_ATTRIBUTES,
- FILE_SHARE_READ | FILE_SHARE_WRITE /*| FILE_SHARE_DELETE*/,
- &sec_none_nih, // sa
- OPEN_EXISTING,
- 0,
- NULL
- );
+ hFileSource = CreateFile (real_a, FILE_WRITE_ATTRIBUTES,
+ FILE_SHARE_READ | FILE_SHARE_WRITE /*| FILE_SHARE_DELETE*/,
+ &sec_none_nih, // sa
+ OPEN_EXISTING, 0, NULL);
if (hFileSource == INVALID_HANDLE_VALUE)
{
@@ -2433,12 +2428,10 @@ logout (char *line)
return 0;
ut_fd = CreateFile (win32_path.get_win32 (),
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- &sec_none_nih,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ &sec_none_nih, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
if (ut_fd != INVALID_HANDLE_VALUE)
{
struct utmp *ut;
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index a7dec6a..ed06802 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -471,13 +471,11 @@ utimes (const char *path, struct timeval *tvp)
the times of directories. */
/* Note: It's not documented in MSDN that FILE_WRITE_ATTRIBUTES is
sufficient to change the timestamps... */
- HANDLE h = CreateFileA (win32.get_win32 (),
- FILE_WRITE_ATTRIBUTES,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- &sec_none_nih,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
- 0);
+ HANDLE h = CreateFile (win32, FILE_WRITE_ATTRIBUTES,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ &sec_none_nih, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
+ 0);
if (h == INVALID_HANDLE_VALUE)
{