summaryrefslogtreecommitdiff
path: root/src/pstore
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-22 11:08:06 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-22 14:31:21 +0900
commit6bf18debddbe1b231f783617e054cc194bb36d1e (patch)
tree96945587fe74aad0b6465642115af40410d093b2 /src/pstore
parent03c5f6cc02648eeff3179b2b762d46b9e1889bb1 (diff)
downloadsystemd-6bf18debddbe1b231f783617e054cc194bb36d1e.tar.gz
pstore: do not add FILE= journal entry if content_size == 0
Diffstat (limited to 'src/pstore')
-rw-r--r--src/pstore/pstore.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
index dfa95742d3..47301b1280 100644
--- a/src/pstore/pstore.c
+++ b/src/pstore/pstore.c
@@ -117,10 +117,8 @@ static int compare_pstore_entries(const void *_a, const void *_b) {
static int move_file(PStoreEntry *pe, const char *subdir) {
_cleanup_free_ char *ifd_path = NULL, *ofd_path = NULL;
- _cleanup_free_ void *field = NULL;
+ const char *suffix, *message;
struct iovec iovec[2];
- const char *suffix;
- size_t field_size;
int n_iovec = 0, r;
if (pe->handled)
@@ -136,15 +134,20 @@ static int move_file(PStoreEntry *pe, const char *subdir) {
/* Always log to the journal */
suffix = arg_storage == PSTORE_STORAGE_EXTERNAL ? strjoina(" moved to ", ofd_path) : (char *)".";
- field = strjoina("MESSAGE=PStore ", pe->dirent.d_name, suffix);
- iovec[n_iovec++] = IOVEC_MAKE_STRING(field);
+ message = strjoina("MESSAGE=PStore ", pe->dirent.d_name, suffix);
+ iovec[n_iovec++] = IOVEC_MAKE_STRING(message);
- field_size = strlen("FILE=") + pe->content_size;
- field = malloc(field_size);
- if (!field)
- return log_oom();
- memcpy(stpcpy(field, "FILE="), pe->content, pe->content_size);
- iovec[n_iovec++] = IOVEC_MAKE(field, field_size);
+ if (pe->content_size > 0) {
+ _cleanup_free_ void *field = NULL;
+ size_t field_size;
+
+ field_size = strlen("FILE=") + pe->content_size;
+ field = malloc(field_size);
+ if (!field)
+ return log_oom();
+ memcpy(stpcpy(field, "FILE="), pe->content, pe->content_size);
+ iovec[n_iovec++] = IOVEC_MAKE(field, field_size);
+ }
r = sd_journal_sendv(iovec, n_iovec);
if (r < 0)