Commit aca07187 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

cloud_policy_util: IWYU: HOST_NAME_MAX needs limits.h.

Stop relying on the header being included implicitly. This fixes the build
with libstdc++ after b1303e03 ("Add support in CloudPolicyClient for
machine enrollment and reporting"):

    ../../components/policy/core/common/cloud/cloud_policy_util.cc: In function ‘std::__cxx11::string policy::GetMachineName()’:
    ../../components/policy/core/common/cloud/cloud_policy_util.cc:33:17: error: ‘HOST_NAME_MAX’ was not declared in this scope
       char hostname[HOST_NAME_MAX];
                     ^~~~~~~~~~~~~
    ../../components/policy/core/common/cloud/cloud_policy_util.cc:33:17: note: suggested alternative: ‘_SC_HOST_NAME_MAX’
       char hostname[HOST_NAME_MAX];
                     ^~~~~~~~~~~~~
                     _SC_HOST_NAME_MAX
    ../../components/policy/core/common/cloud/cloud_policy_util.cc:34:19: error: ‘hostname’ was not declared in this scope
       if (gethostname(hostname, HOST_NAME_MAX) == 0)  // Success.
                       ^~~~~~~~
    ../../components/policy/core/common/cloud/cloud_policy_util.cc:34:19: note: suggested alternative: ‘basename’
       if (gethostname(hostname, HOST_NAME_MAX) == 0)  // Success.
                       ^~~~~~~~
                       basename

While HOST_NAME_MAX is only used in the Linux code path, it should be
harmless to include the header unconditionally.

BUG=812641

Change-Id: I6769792efe188ff437753e4cb1ba134c341c20e9
Reviewed-on: https://chromium-review.googlesource.com/987895Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#548370}
parent e81fab49
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "build/build_config.h" #include "build/build_config.h"
#include <limits.h>
#if defined(OS_WIN) #if defined(OS_WIN)
#include <Windows.h> // For GetComputerNameW() #include <Windows.h> // For GetComputerNameW()
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment