mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 09:46:17 +01:00
Merge branch 'gutils-limit-scope' into 'master'
utils: Limit the scope of the variable `max` See merge request GNOME/glib!1658
This commit is contained in:
commit
cd1b09fe30
@ -982,7 +982,6 @@ g_get_host_name (void)
|
|||||||
gchar *utmp;
|
gchar *utmp;
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
glong max;
|
|
||||||
gsize size;
|
gsize size;
|
||||||
/* The number 256 * 256 is taken from the value of _POSIX_HOST_NAME_MAX,
|
/* The number 256 * 256 is taken from the value of _POSIX_HOST_NAME_MAX,
|
||||||
* which is 255. Since we use _POSIX_HOST_NAME_MAX + 1 (= 256) in the
|
* which is 255. Since we use _POSIX_HOST_NAME_MAX + 1 (= 256) in the
|
||||||
@ -994,15 +993,19 @@ g_get_host_name (void)
|
|||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
|
|
||||||
#ifdef _SC_HOST_NAME_MAX
|
#ifdef _SC_HOST_NAME_MAX
|
||||||
max = sysconf (_SC_HOST_NAME_MAX);
|
{
|
||||||
if (max > 0 && (gsize) max <= G_MAXSIZE - 1)
|
glong max;
|
||||||
size = (gsize) max + 1;
|
|
||||||
else
|
max = sysconf (_SC_HOST_NAME_MAX);
|
||||||
|
if (max > 0 && (gsize) max <= G_MAXSIZE - 1)
|
||||||
|
size = (gsize) max + 1;
|
||||||
|
else
|
||||||
#ifdef HOST_NAME_MAX
|
#ifdef HOST_NAME_MAX
|
||||||
size = HOST_NAME_MAX + 1;
|
size = HOST_NAME_MAX + 1;
|
||||||
#else
|
#else
|
||||||
size = _POSIX_HOST_NAME_MAX + 1;
|
size = _POSIX_HOST_NAME_MAX + 1;
|
||||||
#endif /* HOST_NAME_MAX */
|
#endif /* HOST_NAME_MAX */
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Fallback to some reasonable value */
|
/* Fallback to some reasonable value */
|
||||||
size = 256;
|
size = 256;
|
||||||
|
Loading…
Reference in New Issue
Block a user