A commit which is almost all trivial change.

- m_main: if --log-file-qualifier applies, do not add ".pid"
  at the end of the name

- Fix the logic which detected whether the just-devised name
  already existed.  This was broken (by me) because it could not
  distinguish the reasons for failing to open the logfile.

  Doing this required changing the return type of VG_(open)
  from Int to SysRes (to make failure reasons visible) and 
  that's the cause of most of the changes.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4228 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index 4f0bef4..73d05a4 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -807,6 +807,7 @@
 static void fprint_CC_table_and_calc_totals(void)
 {
    Int     fd;
+   SysRes  sres;
    Char    buf[512];
    fileCC *curr_fileCC;
    fnCC   *curr_fnCC;
@@ -815,9 +816,9 @@
 
    VGP_PUSHCC(VgpCacheResults);
 
-   fd = VG_(open)(cachegrind_out_file, VKI_O_CREAT|VKI_O_TRUNC|VKI_O_WRONLY,
-                                       VKI_S_IRUSR|VKI_S_IWUSR);
-   if (fd < 0) {
+   sres = VG_(open)(cachegrind_out_file, VKI_O_CREAT|VKI_O_TRUNC|VKI_O_WRONLY,
+                                         VKI_S_IRUSR|VKI_S_IWUSR);
+   if (sres.isError) {
       // If the file can't be opened for whatever reason (conflict
       // between multiple cachegrinded processes?), give up now.
       VG_(message)(Vg_UserMsg,
@@ -826,6 +827,8 @@
       VG_(message)(Vg_UserMsg,
          "       ... so simulation results will be missing.");
       return;
+   } else {
+      fd = sres.val;
    }
 
    // "desc:" lines (giving I1/D1/L2 cache configuration).  The spaces after