Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: src/platform/update_engine/subprocess.cc

Issue 1599029: update engine: 32- and 64-bit compile (Closed)
Patch Set: int32->int32_t, PRIi64, 80 cols for review Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/platform/update_engine/subprocess.cc
diff --git a/src/platform/update_engine/subprocess.cc b/src/platform/update_engine/subprocess.cc
index 89b6cadd03fd56fa88ecf875d78a6040cedee9ca..3a6597eb193bdfc6d0f761c674411d3180d1a431 100644
--- a/src/platform/update_engine/subprocess.cc
+++ b/src/platform/update_engine/subprocess.cc
@@ -9,6 +9,7 @@
#include <vector>
#include "chromeos/obsolete_logging.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
using std::string;
using std::vector;
@@ -18,7 +19,7 @@ namespace chromeos_update_engine {
void Subprocess::GChildExitedCallback(GPid pid, gint status, gpointer data) {
COMPILE_ASSERT(sizeof(guint) == sizeof(uint32),
guint_uint32_size_mismatch);
- guint *tag = reinterpret_cast<guint*>(data);
+ guint* tag = reinterpret_cast<guint*>(data);
const SubprocessCallbackRecord& record = Get().callback_records_[*tag];
if (record.callback)
record.callback(status, record.callback_data);
@@ -38,16 +39,22 @@ void FreeArgv(char** argv) {
uint32 Subprocess::Exec(const std::vector<std::string>& cmd,
ExecCallback callback,
- void *p) {
+ void* p) {
GPid child_pid;
- GError *err;
- scoped_array<char *> argv(new char*[cmd.size() + 1]);
+ GError* err;
+ scoped_array<char*> argv(new char*[cmd.size() + 1]);
for (unsigned int i = 0; i < cmd.size(); i++) {
argv[i] = strdup(cmd[i].c_str());
}
argv[cmd.size()] = NULL;
- char *argp[1];
- argp[0] = NULL;
+
+ scoped_array<char*> argp(new char*[2]);
+ argp[0] = argp[1] = NULL;
+ const char* kLdLibraryPathKey = "LD_LIBRARY_PATH";
+ if (getenv(kLdLibraryPathKey)) {
+ argp[0] = strdup(StringPrintf("%s=%s", kLdLibraryPathKey,
+ getenv(kLdLibraryPathKey)).c_str());
+ }
SubprocessCallbackRecord callback_record;
callback_record.callback = callback;
@@ -55,7 +62,7 @@ uint32 Subprocess::Exec(const std::vector<std::string>& cmd,
bool success = g_spawn_async(NULL, // working directory
argv.get(),
- argp,
+ argp.get(),
G_SPAWN_DO_NOT_REAP_CHILD, // flags
NULL, // child setup function
NULL, // child setup data pointer
@@ -66,7 +73,7 @@ uint32 Subprocess::Exec(const std::vector<std::string>& cmd,
LOG(ERROR) << "g_spawn_async failed";
return 0;
}
- guint *tag = new guint;
+ guint* tag = new guint;
*tag = g_child_watch_add(child_pid, GChildExitedCallback, tag);
callback_records_[*tag] = callback_record;
return *tag;
@@ -80,13 +87,13 @@ void Subprocess::CancelExec(uint32 tag) {
bool Subprocess::SynchronousExec(const std::vector<std::string>& cmd,
int* return_code) {
- GError *err = NULL;
- scoped_array<char *> argv(new char*[cmd.size() + 1]);
+ GError* err = NULL;
+ scoped_array<char*> argv(new char*[cmd.size() + 1]);
for (unsigned int i = 0; i < cmd.size(); i++) {
argv[i] = strdup(cmd[i].c_str());
}
argv[cmd.size()] = NULL;
- char *argp[1];
+ char* argp[1];
argp[0] = NULL;
bool success = g_spawn_sync(NULL, // working directory

Powered by Google App Engine
This is Rietveld 408576698