Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / fileio / tngio.cpp
index 31447ee6d395433836a97be0379f80998d581975..20932d54c37627bcd7e91c4f145d2701f3058619 100644 (file)
@@ -152,10 +152,12 @@ void gmx_tng_open(const char       *filename,
 
 #ifdef HAVE_UNISTD_H
         char username[256];
-        getlogin_r(username, 256);
-        if (mode == 'w')
+        if (!getlogin_r(username, 256))
         {
-            tng_first_user_name_set(*tng, username);
+            if (mode == 'w')
+            {
+                tng_first_user_name_set(*tng, username);
+            }
         }
 /* TODO: This should be implemented when the above fixme is done (adding data to
  * the header). */