diff options
| author | Dan Albert <danalbert@google.com> | 2015-07-08 13:50:42 -0700 |
|---|---|---|
| committer | Dan Albert <danalbert@google.com> | 2015-07-09 10:47:24 -0700 |
| commit | 459df8f3a14d4c614f0211049800cf7cad6d30ad (patch) | |
| tree | 29b1d8281e4355d70bf32b4efffa5e5a9350da2b /adb/commandline.cpp | |
| parent | a6241a0298de5e773ef113626ca4686f9c038868 (diff) | |
Turn on -Wformat-nonliteral.
Apparently there are two classes of this warning in clang.
-Wformat-security is only emitted for cases of
`func(nonliteral_fmt_string)` (no args), and -Wformat-nonliteral is
emitted for cases *with* arguments. For whatever reason, the latter
isn't included in -Wextra and must be manually enabled.
To make this more easily portable to Windows, move the existing
gnu_printf/__printf__ decision into base/macros.h as ATTRIBUTE_FORMAT.
Change-Id: I3b0990e1d1f0a2e9c13b32f5cd60478946cb5fc6
Diffstat (limited to 'adb/commandline.cpp')
| -rw-r--r-- | adb/commandline.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/adb/commandline.cpp b/adb/commandline.cpp index 4adac373ba..59e0807306 100644 --- a/adb/commandline.cpp +++ b/adb/commandline.cpp @@ -1447,7 +1447,8 @@ static int uninstall_app(TransportType transport, const char* serial, int argc, return pm_command(transport, serial, argc, argv); } -static int delete_file(TransportType transport, const char* serial, char* filename) { +static int delete_file(TransportType transport, const char* serial, + const char* filename) { std::string cmd = "shell:rm -f " + escape_arg(filename); return send_shell_command(transport, serial, cmd); } @@ -1464,8 +1465,8 @@ static const char* get_basename(const char* filename) } static int install_app(TransportType transport, const char* serial, int argc, const char** argv) { - static const char *const DATA_DEST = "/data/local/tmp/%s"; - static const char *const SD_DEST = "/sdcard/tmp/%s"; + static const char *const DATA_DEST = "/data/local/tmp"; + static const char *const SD_DEST = "/sdcard/tmp"; const char* where = DATA_DEST; int i; struct stat sb; @@ -1499,19 +1500,20 @@ static int install_app(TransportType transport, const char* serial, int argc, co } const char* apk_file = argv[last_apk]; - char apk_dest[PATH_MAX]; - snprintf(apk_dest, sizeof apk_dest, where, get_basename(apk_file)); - int err = do_sync_push(apk_file, apk_dest, 0 /* no show progress */); + const std::string apk_dest = + android::base::StringPrintf("%s/%s", where, get_basename(apk_file)); + int err = do_sync_push(apk_file, apk_dest.c_str(), /* show_progress = */ 0); if (err) { goto cleanup_apk; } else { - argv[last_apk] = apk_dest; /* destination name, not source location */ + // Destination name, not source location. + argv[last_apk] = apk_dest.c_str(); } err = pm_command(transport, serial, argc, argv); cleanup_apk: - delete_file(transport, serial, apk_dest); + delete_file(transport, serial, apk_dest.c_str()); return err; } |
