1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibCore: Remove usage of a hardcoded constant in gethostname()

This commit is contained in:
Lucas CHOLLET 2022-01-14 00:32:55 +01:00 committed by Idan Horowitz
parent 63466d385c
commit 8153282923
Notes: sideshowbarker 2024-07-17 22:01:16 +09:00

View file

@ -10,6 +10,7 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <LibSystem/syscall.h> #include <LibSystem/syscall.h>
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -25,6 +26,14 @@
namespace Core::System { namespace Core::System {
#ifndef HOST_NAME_MAX
# ifdef __APPLE__
# define HOST_NAME_MAX 255
# else
# define HOST_NAME_MAX 64
# endif
#endif
#ifdef __serenity__ #ifdef __serenity__
ErrorOr<void> beep() ErrorOr<void> beep()
@ -336,7 +345,7 @@ ErrorOr<String> ptsname(int fd)
ErrorOr<String> gethostname() ErrorOr<String> gethostname()
{ {
char hostname[256]; char hostname[HOST_NAME_MAX];
int rc = ::gethostname(hostname, sizeof(hostname)); int rc = ::gethostname(hostname, sizeof(hostname));
if (rc < 0) if (rc < 0)
return Error::from_syscall("gethostname"sv, -errno); return Error::from_syscall("gethostname"sv, -errno);