linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Lei <zhaolei@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Zhao Lei <zhaolei@cn.fujitsu.com>, Qu Wenruo <quwenruo@cn.fujitsu.com>
Subject: [PATCH v3 0/2] btrfs-progs: Introduce warning and error for common use
Date: Mon, 28 Sep 2015 21:58:12 +0800	[thread overview]
Message-ID: <cover.1443448527.git.zhaolei@cn.fujitsu.com> (raw)

Current code use fprintf(stderr, "...") to output warnning and
error information.

The error message have different style, as:
 # grep fprintf *.c
 fprintf(stderr, "Open ctree failed\n");
 fprintf(stderr, "%s: open ctree failed\n", __func__);
 fprintf(stderr, "ERROR: cannot open ctree\n");
 ...

And sometimes, we forgot add tailed '\n', or use printf instead,
as in current code:
 printf("warning, device %llu is missing\n",

This patch introduce warning() and error() as common function,
to make:
1: Each warning and error information have same format
2: Easy to search/change all error message
3: Easy to modify function's internal for debug or other requirement,
   for example:
   print function/linenumber in error()
   dumpstack in error()
   add some trace for some style of message
   add support for -v, -vv, ...
   support for locales
   custom output functions
   support some special device/tty

Converting all source is a big work, this patch convert cmds-scrub.c
We'll convert others these days, and new code can use these function
directly.

Changelog v2->v3:
 1: Put variable definition to top of function
 2: Move __veprintf() to warning()/error()'s internal
 All suggested-by: David Sterba <dsterba@suse.cz>

Changelog v1->v2:
 1: Rename following functions:
    warningon() -> warning_on()
    erroron() -> error_on()
    Suggested-by: David Sterba <dsterba@suse.cz>
 2: Use static inline instead of macro
    Suggested-by: David Sterba <dsterba@suse.cz>
 3: Add return value of warning/error_on()
    Suggested-by: Qu Wenruo <quwenruo@cn.fujitsu.com>

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>

Zhao Lei (2):
  btrfs-progs: Introduce warning and error for common use
  btrfs-progs: use common warning/error for cmds-scrub.c

 cmds-scrub.c | 176 +++++++++++++++++++++++++++++------------------------------
 utils.h      |  51 +++++++++++++++++
 2 files changed, 138 insertions(+), 89 deletions(-)

-- 
1.8.5.1


             reply	other threads:[~2015-09-28 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28 13:58 Zhao Lei [this message]
2015-09-28 13:58 ` [PATCH v3 1/2] btrfs-progs: Introduce warning and error for common use Zhao Lei
2015-09-30 16:20   ` David Sterba
2015-09-28 13:58 ` [PATCH v3 2/2] btrfs-progs: use common warning/error for cmds-scrub.c Zhao Lei
2015-09-30 16:43 ` [PATCH v3 0/2] btrfs-progs: Introduce warning and error for common use David Sterba

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=cover.1443448527.git.zhaolei@cn.fujitsu.com \
    --to=zhaolei@cn.fujitsu.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).