From 52b322820c3cfdc333ae3fdc8f71cc4039ad002f Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Fri, 28 Sep 2018 19:46:57 +0100 Subject: [PATCH] mx_path_probe: export stat info --- mx.c | 17 ++++++++--------- mx.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mx.c b/mx.c index fde6e2ee4..4dd266980 100644 --- a/mx.c +++ b/mx.c @@ -1330,11 +1330,11 @@ bool mx_tags_is_supported(struct Context *ctx) /** * mx_path_probe - Find a mailbox that understands a path - * @param path Path to examine - * @param st stat buffer (for local filesystems) + * @param[in] path Path to examine + * @param[out] st stat buffer (OPTIONAL, for local filesystems) * @retval num Type, e.g. #MUTT_IMAP */ -int mx_path_probe(const char *path, const struct stat *st) +int mx_path_probe(const char *path, struct stat *st) { if (!path) return MUTT_UNKNOWN; @@ -1372,13 +1372,12 @@ int mx_path_probe(const char *path, const struct stat *st) struct stat st2 = { 0 }; if (!st) - { st = &st2; - if (stat(path, &st2) != 0) - { - mutt_debug(1, "unable to stat %s: %s (errno %d).\n", path, strerror(errno), errno); - return MUTT_UNKNOWN; - } + + if (stat(path, st) != 0) + { + mutt_debug(1, "unable to stat %s: %s (errno %d).\n", path, strerror(errno), errno); + return MUTT_UNKNOWN; } for (size_t i = 0; i < mutt_array_size(with_stat); i++) diff --git a/mx.h b/mx.h index 3cba5c200..a2fab1916 100644 --- a/mx.h +++ b/mx.h @@ -246,7 +246,7 @@ int mx_msg_padding_size(struct Context *ctx); int mx_path_canon (char *buf, size_t buflen, const char *folder); int mx_path_parent (char *buf, size_t buflen); int mx_path_pretty (char *buf, size_t buflen, const char *folder); -int mx_path_probe (const char *path, const struct stat *st); +int mx_path_probe (const char *path, struct stat *st); int mx_tags_commit (struct Context *ctx, struct Email *e, char *tags); int mx_tags_edit (struct Context *ctx, const char *tags, char *buf, size_t buflen); -- 2.40.0