From 5b4d2350e688e32702b3d6a3f89a23624f095d11 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 10 Feb 2020 09:40:12 +0100 Subject: [PATCH] tweaks: condense two fragments of code --- src/files.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/files.c b/src/files.c index 17d6f119..ca43818d 100644 --- a/src/files.c +++ b/src/files.c @@ -165,13 +165,11 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie return FALSE; } - if (gethostname(myhostname, 31) < 0) { - if (errno != ENAMETOOLONG) { - statusline(MILD, _("Couldn't determine hostname: %s"), strerror(errno)); - return FALSE; - } else - myhostname[31] = '\0'; - } + if (gethostname(myhostname, 31) < 0 && errno != ENAMETOOLONG) { + statusline(MILD, _("Couldn't determine hostname: %s"), strerror(errno)); + return FALSE; + } else + myhostname[31] = '\0'; /* If the lockfile exists, try to delete it. */ if (stat(lockfilename, &fileinfo) != -1) @@ -1855,8 +1853,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp, if (openfile->lock_filename != NULL) { delete_lockfile(openfile->lock_filename); free(openfile->lock_filename); - openfile->lock_filename = NULL; - do_lockfile(realname, FALSE); + openfile->lock_filename = do_lockfile(realname, FALSE); } #endif #ifdef ENABLE_COLOR