mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-19 04:01:57 +02:00
Rewrite not to look at errno' if library call succeeds, since
errno' is
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]: Rewrite not to look at `errno' if library call succeeds, since `errno' is not reset to 0.
This commit is contained in:
parent
d041a48618
commit
c9e92e124e
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
1999-01-23 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init) [HAVE_GETPWUID_R]:
|
||||||
|
Rewrite not to look at `errno' if library call succeeds, since
|
||||||
|
`errno' is not reset to 0.
|
||||||
|
|
||||||
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
Sat Jan 23 16:17:04 1999 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glibconfig.h.win32: Update the magic values for
|
* glibconfig.h.win32: Update the magic values for
|
||||||
|
@ -443,29 +443,42 @@ g_get_any_init (void)
|
|||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R
|
# ifdef HAVE_GETPWUID_R
|
||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
guint bufsize = 1; // sizeof (struct passwd);
|
guint bufsize = 1; /* sizeof (struct passwd); */
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
do
|
pw_retry:
|
||||||
{
|
buffer = g_malloc (bufsize);
|
||||||
g_free (buffer);
|
|
||||||
buffer = g_malloc (bufsize);
|
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R_POSIX
|
# ifdef HAVE_GETPWUID_R_POSIX
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
error = error ? errno : 0;
|
if (!error)
|
||||||
|
goto pw_out;
|
||||||
|
/* error = errno; According to the Solaris man page,
|
||||||
|
this is not necessary. */
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R_POSIX */
|
# else /* !HAVE_GETPWUID_R_POSIX */
|
||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
error = errno;
|
if (pw == NULL)
|
||||||
|
goto pw_out;
|
||||||
|
error = errno;
|
||||||
# endif /* !HAVE_GETPWUID_R_POSIX */
|
# endif /* !HAVE_GETPWUID_R_POSIX */
|
||||||
|
|
||||||
|
/* If it came here, there's some kind of error. */
|
||||||
|
g_free (buffer);
|
||||||
|
|
||||||
|
if (error == ERANGE)
|
||||||
|
{
|
||||||
bufsize *= 2;
|
bufsize *= 2;
|
||||||
|
goto pw_retry;
|
||||||
}
|
}
|
||||||
while (error == ERANGE);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
|
||||||
|
|
||||||
|
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
||||||
|
/* Make any subsequent g_free (buffer) a no-op. */
|
||||||
|
buffer = NULL;
|
||||||
|
|
||||||
|
pw_out:
|
||||||
|
;
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R */
|
# else /* !HAVE_GETPWUID_R */
|
||||||
|
|
||||||
# ifdef G_THREADS_ENABLED
|
# ifdef G_THREADS_ENABLED
|
||||||
|
41
gutils.c
41
gutils.c
@ -443,29 +443,42 @@ g_get_any_init (void)
|
|||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R
|
# ifdef HAVE_GETPWUID_R
|
||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
guint bufsize = 1; // sizeof (struct passwd);
|
guint bufsize = 1; /* sizeof (struct passwd); */
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
do
|
pw_retry:
|
||||||
{
|
buffer = g_malloc (bufsize);
|
||||||
g_free (buffer);
|
|
||||||
buffer = g_malloc (bufsize);
|
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R_POSIX
|
# ifdef HAVE_GETPWUID_R_POSIX
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
error = error ? errno : 0;
|
if (!error)
|
||||||
|
goto pw_out;
|
||||||
|
/* error = errno; According to the Solaris man page,
|
||||||
|
this is not necessary. */
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R_POSIX */
|
# else /* !HAVE_GETPWUID_R_POSIX */
|
||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
error = errno;
|
if (pw == NULL)
|
||||||
|
goto pw_out;
|
||||||
|
error = errno;
|
||||||
# endif /* !HAVE_GETPWUID_R_POSIX */
|
# endif /* !HAVE_GETPWUID_R_POSIX */
|
||||||
|
|
||||||
|
/* If it came here, there's some kind of error. */
|
||||||
|
g_free (buffer);
|
||||||
|
|
||||||
|
if (error == ERANGE)
|
||||||
|
{
|
||||||
bufsize *= 2;
|
bufsize *= 2;
|
||||||
|
goto pw_retry;
|
||||||
}
|
}
|
||||||
while (error == ERANGE);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
|
||||||
|
|
||||||
|
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
||||||
|
/* Make any subsequent g_free (buffer) a no-op. */
|
||||||
|
buffer = NULL;
|
||||||
|
|
||||||
|
pw_out:
|
||||||
|
;
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R */
|
# else /* !HAVE_GETPWUID_R */
|
||||||
|
|
||||||
# ifdef G_THREADS_ENABLED
|
# ifdef G_THREADS_ENABLED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user