From f25059c24455a78d3246b5c125b662e9824c23b8 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 30 Jan 2020 19:50:13 +0100 Subject: [PATCH] tweaks: frob a couple of indentations and white lines --- src/files.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/files.c b/src/files.c index 6cce5623..7169d6f5 100644 --- a/src/files.c +++ b/src/files.c @@ -210,7 +210,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd < 0) { statusline(MILD, _("Error writing lock file %s: %s"), - lockfilename, strerror(errno)); + lockfilename, strerror(errno)); goto free_the_data; } @@ -219,7 +219,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi if (filestream == NULL) { statusline(MILD, _("Error writing lock file %s: %s"), - lockfilename, strerror(errno)); + lockfilename, strerror(errno)); goto free_the_data; } @@ -256,16 +256,17 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi lockdata[1007] = 0x55; wroteamt = fwrite(lockdata, sizeof(char), lockdatalen, filestream); + if (wroteamt < lockdatalen) { statusline(MILD, _("Error writing lock file %s: %s"), - lockfilename, ferror(filestream)); + lockfilename, ferror(filestream)); fclose(filestream); goto free_the_data; } if (fclose(filestream) == EOF) { statusline(MILD, _("Error writing lock file %s: %s"), - lockfilename, strerror(errno)); + lockfilename, strerror(errno)); goto free_the_data; } @@ -287,7 +288,7 @@ int delete_lockfile(const char *lockfilename) { if (unlink(lockfilename) < 0 && errno != ENOENT) { statusline(MILD, _("Error deleting lock file %s: %s"), - lockfilename, strerror(errno)); + lockfilename, strerror(errno)); return -1; } return 1; @@ -321,11 +322,12 @@ int do_lockfile(const char *filename, bool ask_the_user) if ((lockfd = open(lockfilename, O_RDONLY)) < 0) { statusline(ALERT, _("Error opening lock file %s: %s"), - lockfilename, strerror(errno)); + lockfilename, strerror(errno)); goto free_the_name; } lockbuf = charalloc(LOCKBUFSIZE); + do { readamt = read(lockfd, &lockbuf[readtot], LOCKBUFSIZE - readtot); readtot += readamt;