Commit 810329d5 authored by thestig's avatar thestig Committed by Commit bot

Minor cleanup in SandboxIPCHandler and ZygoteMain.

Review-Url: https://codereview.chromium.org/2255013002
Cr-Commit-Position: refs/heads/master@{#412752}
parent d2fd447c
......@@ -221,11 +221,7 @@ void SandboxIPCHandler::HandleFontOpenRequest(
const int result_fd = open(paths_[index].c_str(), O_RDONLY);
base::Pickle reply;
if (result_fd == -1) {
reply.WriteBool(false);
} else {
reply.WriteBool(true);
}
reply.WriteBool(result_fd != -1);
// The receiver will have its own access to the file, so we will close it
// after this send.
......@@ -271,7 +267,8 @@ void SandboxIPCHandler::HandleGetStyleForStrike(
base::PickleIterator iter,
const std::vector<base::ScopedFD>& fds) {
std::string family;
bool bold, italic;
bool bold;
bool italic;
uint16_t pixel_size;
if (!iter.ReadString(&family) ||
......@@ -286,7 +283,7 @@ void SandboxIPCHandler::HandleGetStyleForStrike(
query.pixel_size = pixel_size;
query.style = italic ? gfx::Font::ITALIC : 0;
query.weight = bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL;
const gfx::FontRenderParams params = gfx::GetFontRenderParams(query, NULL);
const gfx::FontRenderParams params = gfx::GetFontRenderParams(query, nullptr);
// These are passed as ints since they're interpreted as tri-state chars in
// Blink.
......@@ -320,7 +317,7 @@ void SandboxIPCHandler::HandleLocaltime(
std::string result_string;
const char* time_zone_string = "";
if (expanded_time != NULL) {
if (expanded_time) {
result_string = std::string(reinterpret_cast<const char*>(expanded_time),
sizeof(struct tm));
time_zone_string = expanded_time->tm_zone;
......@@ -356,8 +353,10 @@ void SandboxIPCHandler::HandleMatchWithFallback(
base::PickleIterator iter,
const std::vector<base::ScopedFD>& fds) {
std::string face;
bool is_bold, is_italic;
uint32_t charset, fallback_family;
bool is_bold;
bool is_italic;
uint32_t charset;
uint32_t fallback_family;
if (!iter.ReadString(&face) || face.empty() ||
!iter.ReadBool(&is_bold) ||
......
......@@ -223,16 +223,16 @@ struct tm* localtime_override(const time_t* timep) {
ProxyLocaltimeCallToBrowser(*timep, &time_struct, timezone_string,
sizeof(timezone_string));
return &time_struct;
} else {
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime(timep);
}
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime(timep);
#if defined(MEMORY_SANITIZER)
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
#endif
return res;
}
return res;
}
// Use same trick to override localtime64(), localtime_r() and localtime64_r().
......@@ -247,16 +247,16 @@ struct tm* localtime64_override(const time_t* timep) {
ProxyLocaltimeCallToBrowser(*timep, &time_struct, timezone_string,
sizeof(timezone_string));
return &time_struct;
} else {
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime64(timep);
}
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime64(timep);
#if defined(MEMORY_SANITIZER)
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
#endif
return res;
}
return res;
}
__attribute__ ((__visibility__("default")))
......@@ -268,16 +268,16 @@ struct tm* localtime_r_override(const time_t* timep, struct tm* result) {
if (g_am_zygote_or_renderer) {
ProxyLocaltimeCallToBrowser(*timep, result, NULL, 0);
return result;
} else {
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime_r(timep, result);
}
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime_r(timep, result);
#if defined(MEMORY_SANITIZER)
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
#endif
return res;
}
return res;
}
__attribute__ ((__visibility__("default")))
......@@ -289,16 +289,16 @@ struct tm* localtime64_r_override(const time_t* timep, struct tm* result) {
if (g_am_zygote_or_renderer) {
ProxyLocaltimeCallToBrowser(*timep, result, NULL, 0);
return result;
} else {
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime64_r(timep, result);
}
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime64_r(timep, result);
#if defined(MEMORY_SANITIZER)
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
#endif
return res;
}
return res;
}
#if defined(ENABLE_PLUGINS)
......@@ -308,13 +308,13 @@ struct tm* localtime64_r_override(const time_t* timep, struct tm* result) {
void PreloadPepperPlugins() {
std::vector<PepperPluginInfo> plugins;
ComputePepperPluginList(&plugins);
for (size_t i = 0; i < plugins.size(); ++i) {
if (!plugins[i].is_internal) {
for (const auto& plugin : plugins) {
if (!plugin.is_internal) {
base::NativeLibraryLoadError error;
base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path,
base::NativeLibrary library = base::LoadNativeLibrary(plugin.path,
&error);
VLOG_IF(1, !library) << "Unable to load plugin "
<< plugins[i].path.value() << " "
<< plugin.path.value() << " "
<< error.ToString();
(void)library; // Prevent release-mode warning.
......
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