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:
Philip Withnall 2020-09-23 10:39:45 +00:00
commit cd1b09fe30

View File

@ -982,7 +982,6 @@ g_get_host_name (void)
gchar *utmp;
#ifndef G_OS_WIN32
glong max;
gsize size;
/* 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
@ -994,6 +993,9 @@ g_get_host_name (void)
gchar *tmp;
#ifdef _SC_HOST_NAME_MAX
{
glong max;
max = sysconf (_SC_HOST_NAME_MAX);
if (max > 0 && (gsize) max <= G_MAXSIZE - 1)
size = (gsize) max + 1;
@ -1003,6 +1005,7 @@ g_get_host_name (void)
#else
size = _POSIX_HOST_NAME_MAX + 1;
#endif /* HOST_NAME_MAX */
}
#else
/* Fallback to some reasonable value */
size = 256;