mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibCore: Remove usage of a hardcoded constant in gethostname()
This commit is contained in:
parent
63466d385c
commit
8153282923
Notes:
sideshowbarker
2024-07-17 22:01:16 +09:00
Author: https://github.com/LucasChollet
Commit: 8153282923
Pull-request: https://github.com/SerenityOS/serenity/pull/11880
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/mjz19910
1 changed files with 10 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibSystem/syscall.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
|
@ -25,6 +26,14 @@
|
|||
|
||||
namespace Core::System {
|
||||
|
||||
#ifndef HOST_NAME_MAX
|
||||
# ifdef __APPLE__
|
||||
# define HOST_NAME_MAX 255
|
||||
# else
|
||||
# define HOST_NAME_MAX 64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __serenity__
|
||||
|
||||
ErrorOr<void> beep()
|
||||
|
@ -336,7 +345,7 @@ ErrorOr<String> ptsname(int fd)
|
|||
|
||||
ErrorOr<String> gethostname()
|
||||
{
|
||||
char hostname[256];
|
||||
char hostname[HOST_NAME_MAX];
|
||||
int rc = ::gethostname(hostname, sizeof(hostname));
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("gethostname"sv, -errno);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue