From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3 2/4] btrfs-progs: introduce new send-dump object
Date: Tue, 1 Nov 2016 11:22:09 +0100 [thread overview]
Message-ID: <20161101102209.GW12522@suse.cz> (raw)
In-Reply-To: <20161101080147.13163-3-quwenruo@cn.fujitsu.com>
On Tue, Nov 01, 2016 at 04:01:44PM +0800, Qu Wenruo wrote:
> +/*
> + * Underlying PRINT_DUMP, the only difference is how we handle
> + * the full path.
> + */
> +static int __print_dump(int subvol, void *user, const char *path,
> + const char *title, const char *fmt, ...)
printf-like the __attribute__ ((format (printf, ...)))
> +{
> + struct btrfs_dump_send_args *r = user;
> + char real_title[TITLE_WIDTH + 1] = { 0 };
> + char full_path[PATH_MAX] = {0};
> + char *out_path;
> + va_list args;
> + int ret;
> +
> + if (subvol) {
> + PATH_CAT_OR_RET(title, r->full_subvol_path, r->root_path, path, ret);
> + out_path = r->full_subvol_path;
> + } else {
> + PATH_CAT_OR_RET(title, full_path, r->full_subvol_path, path, ret);
> + out_path = full_path;
> + }
> + string_escape_inplace(out_path, " \n\t\\");
> +
> + /* Append ':' to title */
> + strncpy(real_title, title, TITLE_WIDTH - 1);
> + strncat(real_title, ":", TITLE_WIDTH);
I'd rather avoid such string operations, ':', just print everything.
> +
> + /* Unified header, */
> + printf("%-*s%-*s", TITLE_WIDTH, real_title, PATH_WIDTH, out_path);
PATH_WIDTH is used only here, please hardcode it into the format string.
The rest of the patch looks good. I think I've seen some artifacts in
the output, but we can tune this later.
> + ret = strftime(dest, max_size, "%Y-%m-%d %H:%M:%S", tm);
We should use the RFC 3339 format, as it's standardized and also is a
string without whitespace.
next prev parent reply other threads:[~2016-11-01 10:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-01 8:01 [PATCH v3 0/4] Introduce dump option for btrfs-receive Qu Wenruo
2016-11-01 8:01 ` [PATCH v3 1/4] btrfs-progs: utils: Introduce function to escape characters Qu Wenruo
2016-11-01 10:08 ` David Sterba
2016-11-02 1:19 ` Qu Wenruo
2016-11-02 10:55 ` David Sterba
2016-11-03 0:24 ` Qu Wenruo
2016-11-03 1:14 ` Qu Wenruo
2016-11-01 8:01 ` [PATCH v3 2/4] btrfs-progs: introduce new send-dump object Qu Wenruo
2016-11-01 10:22 ` David Sterba [this message]
2016-11-02 0:37 ` Qu Wenruo
2016-11-02 10:52 ` David Sterba
2016-11-03 0:21 ` Qu Wenruo
2016-11-01 8:01 ` [PATCH v3 3/4] btrfs-progs: receive: introduce option to dump send stream Qu Wenruo
2016-11-01 8:01 ` [PATCH v3 4/4] btrfs-progs: remove send-test tool Qu Wenruo
2016-11-02 14:59 ` David Sterba
2016-11-01 8:01 ` [PATCH 5/5] btrfs-progs: misc-test: Add send stream dump test Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161101102209.GW12522@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.