All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 09/10] btrfs-progs: Fix the return value of btrfs-map-logical
Date: Thu, 1 Aug 2013 13:35:33 +0800	[thread overview]
Message-ID: <1375335334-32540-9-git-send-email-wangsl.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1375335334-32540-1-git-send-email-wangsl.fnst@cn.fujitsu.com>

From: Qu Wenruo <quwenruo@cn.fujitsu.com>

The ret variant in the main function is not changed so even problems
happen, return value is still 0.
The patch fixs the minor bug and return 1 if any problems happen.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 btrfs-map-logical.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index e46d812..7dc71d3 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -119,7 +119,6 @@ int main(int ac, char **av)
 	int copy = 0;
 	u64 bytes = 0;
 	int out_fd = 0;
-	int err;
 
 	while(1) {
 		int c;
@@ -187,8 +186,9 @@ int main(int ac, char **av)
 			out_fd = open(output_file, O_RDWR | O_CREAT, 0600);
 			if (out_fd < 0)
 				goto close;
-			err = ftruncate(out_fd, 0);
-			if (err) {
+			ret = ftruncate(out_fd, 0);
+			if (ret) {
+				ret = 1;
 				close(out_fd);
 				goto close;
 			}
@@ -205,8 +205,9 @@ int main(int ac, char **av)
 	while (bytes > 0) {
 		eb = debug_read_block(root, logical, root->sectorsize, copy);
 		if (eb && output_file) {
-			err = write(out_fd, eb->data, eb->len);
-			if (err < 0 || err != eb->len) {
+			ret = write(out_fd, eb->data, eb->len);
+			if (ret < 0 || ret != eb->len) {
+				ret = 1;
 				fprintf(stderr, "output file write failed\n");
 				goto out_close_fd;
 			}
-- 
1.8.0.1


  parent reply	other threads:[~2013-08-01  5:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01  5:35 [PATCH 01/10] Btrfs-progs: add missing man page information for btrfsck Wang Shilong
2013-08-01  5:35 ` [PATCH 02/10] Btrfs-progs: add missing man information for btrfs-debug-tree Wang Shilong
2013-08-01  5:35 ` [PATCH 03/10] Btrfs-progs: add missing man page for btrfs-show-super Wang Shilong
2013-08-01  5:35 ` [PATCH 04/10] Btrfs-progs: add man page information for btrfs-find-root Wang Shilong
2013-08-01  5:35 ` [PATCH 05/10] Btrfs-progs: add man page information for btrfs-convert Wang Shilong
2013-08-01  5:35 ` [PATCH 06/10] Btrfs-progs: add missing man page for btrfstune Wang Shilong
2013-08-01  5:35 ` [PATCH 07/10] Btrfs-progs: add missing man page information for btrfs-zero-log Wang Shilong
2013-08-01  5:35 ` [PATCH 08/10] btrfs-progs: Update usage string of btrfs-map-logical Wang Shilong
2013-08-01  5:35 ` Wang Shilong [this message]
2013-08-06 13:48   ` [PATCH 09/10] btrfs-progs: Fix the return value " David Sterba
2013-08-06 13:55     ` Wang Shilong
2013-08-01  5:35 ` [PATCH 10/10] Btrfs-progs: add missing man page for btrfs-map-logical Wang Shilong
2013-08-01  9:43 ` [PATCH 01/10] Btrfs-progs: add missing man page information for btrfsck Stefan Behrens
2013-08-06 15:13 ` 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=1375335334-32540-9-git-send-email-wangsl.fnst@cn.fujitsu.com \
    --to=wangsl.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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.