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