Skip to content

Commit

Permalink
added error messages when writing group file
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Aug 16, 2024
1 parent ffe868f commit 3ae7f8b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/view-serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <json-c/json.h>
#include "flock/flock-common.h"
#include "flock/flock-group-view.h"
Expand All @@ -23,13 +24,15 @@ static inline void file_serializer(void* uargs, const char* content, size_t size
FILE* file = fopen(filename, "w");
if(!file) {
// LCOV_EXCL_START
margo_error(NULL, "[flock] Could not open %s: %s", filename, strerror(errno));
data->ret = FLOCK_ERR_ALLOCATION;
goto finish;
// LCOV_EXCL_STOP
}
size_t written = fwrite(content, 1, size, file);
if(written != size) {
// LCOV_EXCL_START
margo_error(NULL, "[flock] Could not write file %s: %s", filename, strerror(errno));
data->ret = FLOCK_ERR_OTHER;
goto finish;
// LCOV_EXCL_STOP
Expand All @@ -38,6 +41,8 @@ static inline void file_serializer(void* uargs, const char* content, size_t size
file = NULL;
if(rename(filename, data->filename) != 0) {
// LCOV_EXCL_START
margo_error(NULL, "[flock] Could not rename file %s into %s: %s",
filename, data->filename, strerror(errno));
data->ret = FLOCK_ERR_OTHER;
goto finish;
// LCOV_EXCL_STOP
Expand Down

0 comments on commit 3ae7f8b

Please sign in to comment.