commit 5b4d2350e688e32702b3d6a3f89a23624f095d11
parent cbeea859c2e6a71bab086719bf10d151278c60e0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 10 Feb 2020 09:40:12 +0100
tweaks: condense two fragments of code
Diffstat:
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git 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