diff options
author | Josh Stone <jistone@redhat.com> | 2009-09-28 18:49:51 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-09-28 18:49:51 -0700 |
commit | e16dc041ec7dbcc83c64533ee4cf8759f6ae0be5 (patch) | |
tree | 2e5a018c8057e930bcdf27afcc290effb0b25593 /cache.cxx | |
parent | 55e50c24c9176f1b3d15af94e145456a68e7ecf6 (diff) | |
download | systemtap-steved-e16dc041ec7dbcc83c64533ee4cf8759f6ae0be5.tar.gz systemtap-steved-e16dc041ec7dbcc83c64533ee4cf8759f6ae0be5.tar.xz systemtap-steved-e16dc041ec7dbcc83c64533ee4cf8759f6ae0be5.zip |
Simplify copy_file calls
Every single copy_file call we had was converting strings to char*,
printing the same error message, and optionally printing the same
verbose string. Let's canonicalize that.
* util.cxx (copy_file): Take string filenames, add a verbose flag, and
consolidate the message printing.
* cache.cxx (add_to_cache): Pass strings and remove message printing.
(get_from_cache): Ditto.
* main.cxx (main): Ditto.
* tapsets.cxx (tracepoint_builder::get_tracequery_module): Ditto.
(dwarf_cast_expanding_visitor::filter_special_modules): Ditto.
Diffstat (limited to 'cache.cxx')
-rw-r--r-- | cache.cxx | 34 |
1 files changed, 8 insertions, 26 deletions
@@ -48,29 +48,23 @@ static void clean_cache(systemtap_session& s); void add_to_cache(systemtap_session& s) { + bool verbose = s.verbose > 1; + // PR10543: clean the cache *before* we try putting something new into it. // We don't want to risk having the brand new contents being erased again. clean_cache(s); string stapconf_src_path = s.tmpdir + "/" + s.stapconf_name; - if (s.verbose > 1) - clog << "Copying " << stapconf_src_path << " to " << s.stapconf_path << endl; - if (copy_file(stapconf_src_path.c_str(), s.stapconf_path.c_str()) != 0) + if (!copy_file(stapconf_src_path, s.stapconf_path, verbose)) { - cerr << "Copy failed (\"" << stapconf_src_path << "\" to \"" - << s.stapconf_path << "\"): " << strerror(errno) << endl; s.use_cache = false; return; } string module_src_path = s.tmpdir + "/" + s.module_name + ".ko"; STAP_PROBE2(stap, cache__add__module, module_src_path.c_str(), s.hash_path.c_str()); - if (s.verbose > 1) - clog << "Copying " << module_src_path << " to " << s.hash_path << endl; - if (copy_file(module_src_path.c_str(), s.hash_path.c_str()) != 0) + if (!copy_file(module_src_path, s.hash_path, verbose)) { - cerr << "Copy failed (\"" << module_src_path << "\" to \"" - << s.hash_path << "\"): " << strerror(errno) << endl; s.use_cache = false; return; } @@ -81,14 +75,8 @@ add_to_cache(systemtap_session& s) c_dest_path += ".c"; STAP_PROBE2(stap, cache__add__source, s.translated_source.c_str(), c_dest_path.c_str()); - if (s.verbose > 1) - clog << "Copying " << s.translated_source << " to " << c_dest_path - << endl; - if (copy_file(s.translated_source.c_str(), c_dest_path.c_str()) != 0) + if (!copy_file(s.translated_source, c_dest_path, verbose)) { - if (s.verbose > 1) - cerr << "Copy failed (\"" << s.translated_source << "\" to \"" - << c_dest_path << "\"): " << strerror(errno) << endl; // NB: this is not so severe as to prevent reuse of the .ko // already copied. // @@ -118,10 +106,8 @@ get_from_cache(systemtap_session& s) } // Copy the stapconf header file to the destination - if (copy_file(s.stapconf_path.c_str(), stapconf_dest_path.c_str()) != 0) + if (!copy_file(s.stapconf_path, stapconf_dest_path)) { - cerr << "Copy failed (\"" << s.stapconf_path << "\" to \"" - << stapconf_dest_path << "\"): " << strerror(errno) << endl; close(fd_stapconf); return false; } @@ -152,10 +138,8 @@ get_from_cache(systemtap_session& s) } // Copy the cached C file to the destination - if (copy_file(c_src_path.c_str(), s.translated_source.c_str()) != 0) + if (!copy_file(c_src_path, s.translated_source)) { - cerr << "Copy failed (\"" << c_src_path << "\" to \"" - << s.translated_source << "\"): " << strerror(errno) << endl; close(fd_module); close(fd_c); return false; @@ -164,10 +148,8 @@ get_from_cache(systemtap_session& s) // Copy the cached module to the destination (if needed) if (s.last_pass != 3) { - if (copy_file(s.hash_path.c_str(), module_dest_path.c_str()) != 0) + if (!copy_file(s.hash_path, module_dest_path)) { - cerr << "Copy failed (\"" << s.hash_path << "\" to \"" - << module_dest_path << "\"): " << strerror(errno) << endl; unlink(c_src_path.c_str()); close(fd_module); close(fd_c); |