Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2008-12-14 00:05:31 +0300
committerChristopher Faylor <me@cgf.cx>2008-12-14 00:05:31 +0300
commit9fe25af7a67193be17ccb58191694f504a805cf0 (patch)
tree569ac5bd2b7eea81c2b17ced60751b6d128f59e6 /winsup/cygwin/fhandler_registry.cc
parenta1631dba6c9dfa4b64927d5e8750d6b65e84de8c (diff)
* cygheap.cc (cygheap_user::~cygheap_user): Remove unneeded if 0'ed code.
* fhandler_registry.cc (fhandler_registry::exists): Recode goto as if/else to avoid a gcc4 compiler warning. (fhandler_registry::open): Ditto. Use one goto rather than two. * gentls_offsets: Fix compiler warning in generated output. * tlsoffsets.h: Regenerate. * mount.cc (fillout_mntent): slashify native paths returned via getmntent.
Diffstat (limited to 'winsup/cygwin/fhandler_registry.cc')
-rw-r--r--winsup/cygwin/fhandler_registry.cc174
1 files changed, 87 insertions, 87 deletions
diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc
index 4efe48e6f..63da374c8 100644
--- a/winsup/cygwin/fhandler_registry.cc
+++ b/winsup/cygwin/fhandler_registry.cc
@@ -147,7 +147,7 @@ decode_regname (char * dst, const char * src, int len = -1)
char *p;
c = strtoul (s, &p, 16);
if (!(must_encode (c) ||
- (c == '.' && si == 0 && (len == 3 || (src[3] == '.' && len == 4)))))
+ (c == '.' && si == 0 && (len == 3 || (src[3] == '.' && len == 4)))))
return -1;
dst[di++] = c;
si += 2;
@@ -237,72 +237,72 @@ fhandler_registry::exists ()
file++;
if (file == path)
- {
- for (int i = 0; registry_listing[i]; i++)
- if (path_prefix_p (registry_listing[i], path,
- strlen (registry_listing[i]), true))
- {
- file_type = 1;
- goto out;
- }
- goto out;
- }
-
- char dec_file[NAME_MAX + 1];
- int val_only = decode_regname (dec_file, file);
- if (val_only < 0)
- goto out;
-
- if (!val_only)
- hKey = open_key (path, KEY_READ, wow64, false);
- if (hKey != (HKEY) INVALID_HANDLE_VALUE)
- file_type = 1;
+ for (int i = 0; registry_listing[i]; i++)
+ if (path_prefix_p (registry_listing[i], path,
+ strlen (registry_listing[i]), true))
+ {
+ file_type = 1;
+ break;
+ }
else
{
- hKey = open_key (path, KEY_READ, wow64, true);
- if (hKey == (HKEY) INVALID_HANDLE_VALUE)
- return 0;
+ char dec_file[NAME_MAX + 1];
+
+ int val_only = decode_regname (dec_file, file);
+ if (val_only < 0)
+ goto out;
if (!val_only)
+ hKey = open_key (path, KEY_READ, wow64, false);
+ if (hKey != (HKEY) INVALID_HANDLE_VALUE)
+ file_type = 1;
+ else
{
+ hKey = open_key (path, KEY_READ, wow64, true);
+ if (hKey == (HKEY) INVALID_HANDLE_VALUE)
+ return 0;
+
+ if (!val_only)
+ {
+ while (ERROR_SUCCESS ==
+ (error = RegEnumKeyEx (hKey, index++, buf, &buf_size,
+ NULL, NULL, NULL, NULL))
+ || (error == ERROR_MORE_DATA))
+ {
+ if (strcasematch (buf, dec_file))
+ {
+ file_type = 1;
+ goto out;
+ }
+ buf_size = NAME_MAX + 1;
+ }
+ if (error != ERROR_NO_MORE_ITEMS)
+ {
+ seterrno_from_win_error (__FILE__, __LINE__, error);
+ goto out;
+ }
+ index = 0;
+ buf_size = NAME_MAX + 1;
+ }
+
while (ERROR_SUCCESS ==
- (error = RegEnumKeyEx (hKey, index++, buf, &buf_size,
- NULL, NULL, NULL, NULL))
+ (error = RegEnumValue (hKey, index++, buf, &buf_size, NULL, NULL,
+ NULL, NULL))
|| (error == ERROR_MORE_DATA))
{
- if (strcasematch (buf, dec_file))
+ if ( (buf[0] == '\0' && strcasematch (file, DEFAULT_VALUE_NAME))
+ || strcasematch (buf, dec_file))
{
- file_type = 1;
+ file_type = -1;
goto out;
}
- buf_size = NAME_MAX + 1;
+ buf_size = NAME_MAX + 1;
}
if (error != ERROR_NO_MORE_ITEMS)
{
seterrno_from_win_error (__FILE__, __LINE__, error);
goto out;
}
- index = 0;
- buf_size = NAME_MAX + 1;
- }
-
- while (ERROR_SUCCESS ==
- (error = RegEnumValue (hKey, index++, buf, &buf_size, NULL, NULL,
- NULL, NULL))
- || (error == ERROR_MORE_DATA))
- {
- if ( (buf[0] == '\0' && strcasematch (file, DEFAULT_VALUE_NAME))
- || strcasematch (buf, dec_file))
- {
- file_type = -1;
- goto out;
- }
- buf_size = NAME_MAX + 1;
- }
- if (error != ERROR_NO_MORE_ITEMS)
- {
- seterrno_from_win_error (__FILE__, __LINE__, error);
- goto out;
}
}
out:
@@ -649,64 +649,64 @@ fhandler_registry::open (int flags, mode_t mode)
{
set_errno (EROFS);
res = 0;
- goto out;
}
else
{
set_errno (ENOENT);
res = 0;
- goto out;
}
+ goto out;
}
if (flags & O_WRONLY)
{
set_errno (EROFS);
res = 0;
- goto out;
}
-
- char dec_file[NAME_MAX + 1];
- int val_only = decode_regname (dec_file, file);
- if (val_only < 0)
- {
- set_errno (EINVAL);
- res = 0;
- goto out;
- }
-
- if (!val_only)
- handle = open_key (path, KEY_READ, wow64, false);
- if (handle == (HKEY) INVALID_HANDLE_VALUE)
+ else
{
- handle = open_key (path, KEY_READ, wow64, true);
- if (handle == (HKEY) INVALID_HANDLE_VALUE)
+ char dec_file[NAME_MAX + 1];
+ int val_only = decode_regname (dec_file, file);
+ if (val_only < 0)
{
+ set_errno (EINVAL);
res = 0;
goto out;
}
- }
- else
- flags |= O_DIROPEN;
- set_io_handle (handle);
+ if (!val_only)
+ handle = open_key (path, KEY_READ, wow64, false);
+ if (handle == (HKEY) INVALID_HANDLE_VALUE)
+ {
+ handle = open_key (path, KEY_READ, wow64, true);
+ if (handle == (HKEY) INVALID_HANDLE_VALUE)
+ {
+ res = 0;
+ goto out;
+ }
+ }
+ else
+ flags |= O_DIROPEN;
- if (strcasematch (dec_file, DEFAULT_VALUE_NAME))
- value_name = cstrdup ("");
- else
- value_name = cstrdup (dec_file);
+ set_io_handle (handle);
- if (!(flags & O_DIROPEN) && !fill_filebuf ())
- {
- RegCloseKey (handle);
- res = 0;
- goto out;
- }
+ if (strcasematch (dec_file, DEFAULT_VALUE_NAME))
+ value_name = cstrdup ("");
+ else
+ value_name = cstrdup (dec_file);
- if (flags & O_APPEND)
- position = filesize;
- else
- position = 0;
+ if (!(flags & O_DIROPEN) && !fill_filebuf ())
+ {
+ RegCloseKey (handle);
+ res = 0;
+ goto out;
+ }
+
+ if (flags & O_APPEND)
+ position = filesize;
+ else
+ position = 0;
+ }
success:
res = 1;
@@ -834,7 +834,7 @@ open_key (const char *name, REGSAM access, DWORD wow64, bool isValue)
name++;
int val_only = decode_regname (component, anchor, name - anchor);
if (val_only < 0)
- {
+ {
set_errno (EINVAL);
if (parentOpened)
RegCloseKey (hParentKey);