Merge "Add missing null checks after allocations."
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index c503558..e59a96a 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -770,8 +770,7 @@
cmd += " " + escape_arg(*argv++);
}
- send_shell_command(transport, serial, cmd);
- return 0;
+ return send_shell_command(transport, serial, cmd);
}
static int mkdirs(const char *path)
@@ -1609,8 +1608,7 @@
cmd += " " + escape_arg(*argv++);
}
- send_shell_command(transport, serial, cmd);
- return 0;
+ return send_shell_command(transport, serial, cmd);
}
static int uninstall_app(transport_type transport, const char* serial, int argc,
@@ -1635,8 +1633,7 @@
static int delete_file(transport_type transport, const char* serial, char* filename)
{
std::string cmd = "shell:rm -f " + escape_arg(filename);
- send_shell_command(transport, serial, cmd);
- return 0;
+ return send_shell_command(transport, serial, cmd);
}
static const char* get_basename(const char* filename)
@@ -1697,7 +1694,7 @@
argv[last_apk] = apk_dest; /* destination name, not source location */
}
- pm_command(transport, serial, argc, argv);
+ err = pm_command(transport, serial, argc, argv);
cleanup_apk:
delete_file(transport, serial, apk_dest);
diff --git a/include/memtrack/memtrack.h b/include/memtrack/memtrack.h
index 0f1f85e..3917300 100644
--- a/include/memtrack/memtrack.h
+++ b/include/memtrack/memtrack.h
@@ -121,7 +121,7 @@
ssize_t memtrack_proc_gl_pss(struct memtrack_proc *p);
/**
- * memtrack_proc_gl_total
+ * memtrack_proc_other_total
*
* Same as memtrack_proc_graphics_total, but counts miscellaneous memory
* not tracked by gl or graphics calls above.
@@ -131,7 +131,7 @@
ssize_t memtrack_proc_other_total(struct memtrack_proc *p);
/**
- * memtrack_proc_gl_pss
+ * memtrack_proc_other_pss
*
* Same as memtrack_proc_graphics_total, but counts miscellaneous memory
* not tracked by gl or graphics calls above.
diff --git a/libnetutils/Android.mk b/libnetutils/Android.mk
index 1f61511..2060df4 100644
--- a/libnetutils/Android.mk
+++ b/libnetutils/Android.mk
@@ -17,3 +17,10 @@
LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := dhcptool.c
+LOCAL_SHARED_LIBRARIES := libnetutils
+LOCAL_MODULE := dhcptool
+LOCAL_MODULE_TAGS := debug
+include $(BUILD_EXECUTABLE)
diff --git a/libnetutils/dhcptool.c b/libnetutils/dhcptool.c
new file mode 100644
index 0000000..352ac5e
--- /dev/null
+++ b/libnetutils/dhcptool.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <error.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <netutils/dhcp.h>
+#include <netutils/ifc.h>
+
+int main(int argc, char* argv[]) {
+ if (argc != 2) {
+ error(EXIT_FAILURE, 0, "usage: %s INTERFACE", argv[0]);
+ }
+
+ char* interface = argv[1];
+ if (ifc_init()) {
+ error(EXIT_FAILURE, errno, "dhcptool %s: ifc_init failed", interface);
+ }
+
+ int rc = do_dhcp(interface);
+ if (rc) {
+ error(0, errno, "dhcptool %s: do_dhcp failed", interface);
+ }
+
+ ifc_close();
+
+ return rc ? EXIT_FAILURE : EXIT_SUCCESS;
+}