Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] erofs-utils: Add missing error code handling.
@ 2019-07-24  4:55 Pratik Shinde
  2019-07-24  7:06 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Pratik Shinde @ 2019-07-24  4:55 UTC (permalink / raw)


Handling error conditions that are missed in few scenarios.
also, mkfs command should return 1 on failure and 0 on success.

Signed-off-by: Pratik Shinde <pratikshinde320 at gmail.com>
---
 lib/inode.c | 10 ++++++++--
 mkfs/main.c |  8 +++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 179aa26..08d38c0 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -752,8 +752,14 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
 	}
 	closedir(_dir);
 
-	erofs_prepare_dir_file(dir);
-	erofs_prepare_inode_buffer(dir);
+	ret = erofs_prepare_dir_file(dir);
+	if(!ret)
+		goto err_closedir;
+
+	ret = erofs_prepare_inode_buffer(dir);
+	if(!ret)
+		goto err_closedir;
+
 	if (IS_ROOT(dir))
 		erofs_fixup_meta_blkaddr(dir);
 
diff --git a/mkfs/main.c b/mkfs/main.c
index 1348587..f73eb10 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -212,6 +212,12 @@ int main(int argc, char **argv)
 	erofs_show_config();
 
 	sb_bh = erofs_buffer_init();
+	if(IS_ERR(sb_bh)) {
+		err = PTR_ERR(sb_bh);
+		erofs_err("Failed to initialize super block buffer head : %s",
+			  erofs_strerror(err));
+		goto exit;
+	}
 	err = erofs_bh_balloon(sb_bh, EROFS_SUPER_END);
 	if (err < 0) {
 		erofs_err("Failed to balloon erofs_super_block: %s",
@@ -254,5 +260,5 @@ exit:
 			  erofs_strerror(err));
 		return 1;
 	}
-	return err;
+	return 0;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] erofs-utils: Add missing error code handling.
  2019-07-24  4:55 [PATCH v2] erofs-utils: Add missing error code handling Pratik Shinde
@ 2019-07-24  7:06 ` Gao Xiang
  2019-07-24  9:11   ` Pratik Shinde
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Xiang @ 2019-07-24  7:06 UTC (permalink / raw)


Hi Pratik,

On 2019/7/24 12:55, Pratik Shinde wrote:
> Handling error conditions that are missed in few scenarios.
> also, mkfs command should return 1 on failure and 0 on success.
> 
> Signed-off-by: Pratik Shinde <pratikshinde320 at gmail.com>
> ---
>  lib/inode.c | 10 ++++++++--
>  mkfs/main.c |  8 +++++++-
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index 179aa26..08d38c0 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -752,8 +752,14 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
>  	}
>  	closedir(_dir);
>  
> -	erofs_prepare_dir_file(dir);
> -	erofs_prepare_inode_buffer(dir);
> +	ret = erofs_prepare_dir_file(dir);
> +	if(!ret)
> +		goto err_closedir;

Maybe it should be "if (ret)"? Have you use this patch to generate some images?

if(!ret)
  ^   --- no space here

> +
> +	ret = erofs_prepare_inode_buffer(dir);
> +	if(!ret)
> +		goto err_closedir;

ditto.

> +
>  	if (IS_ROOT(dir))
>  		erofs_fixup_meta_blkaddr(dir);
>  
> diff --git a/mkfs/main.c b/mkfs/main.c
> index 1348587..f73eb10 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -212,6 +212,12 @@ int main(int argc, char **argv)
>  	erofs_show_config();
>  
>  	sb_bh = erofs_buffer_init();
> +	if(IS_ERR(sb_bh)) {
> +		err = PTR_ERR(sb_bh);
> +		erofs_err("Failed to initialize super block buffer head : %s",

erofs_err("Failed to initialize buffers: %s",

Thanks,
Gao Xiang

> +			  erofs_strerror(err));
> +		goto exit;
> +	}
>  	err = erofs_bh_balloon(sb_bh, EROFS_SUPER_END);
>  	if (err < 0) {
>  		erofs_err("Failed to balloon erofs_super_block: %s",
> @@ -254,5 +260,5 @@ exit:
>  			  erofs_strerror(err));
>  		return 1;
>  	}
> -	return err;
> +	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] erofs-utils: Add missing error code handling.
  2019-07-24  7:06 ` Gao Xiang
@ 2019-07-24  9:11   ` Pratik Shinde
  0 siblings, 0 replies; 3+ messages in thread
From: Pratik Shinde @ 2019-07-24  9:11 UTC (permalink / raw)


Hi Gao,

Thanks. and yes, the condition should be 'if (ret)' . Corrected it and few
others too. With the new patch I am able to create erofs image. Will send a
new patch with bumped up version.

-Pratik

On Wed, 24 Jul, 2019, 12:39 PM Gao Xiang, <gaoxiang25@huawei.com> wrote:

> Hi Pratik,
>
> On 2019/7/24 12:55, Pratik Shinde wrote:
> > Handling error conditions that are missed in few scenarios.
> > also, mkfs command should return 1 on failure and 0 on success.
> >
> > Signed-off-by: Pratik Shinde <pratikshinde320 at gmail.com>
> > ---
> >  lib/inode.c | 10 ++++++++--
> >  mkfs/main.c |  8 +++++++-
> >  2 files changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/inode.c b/lib/inode.c
> > index 179aa26..08d38c0 100644
> > --- a/lib/inode.c
> > +++ b/lib/inode.c
> > @@ -752,8 +752,14 @@ struct erofs_inode *erofs_mkfs_build_tree(struct
> erofs_inode *dir)
> >       }
> >       closedir(_dir);
> >
> > -     erofs_prepare_dir_file(dir);
> > -     erofs_prepare_inode_buffer(dir);
> > +     ret = erofs_prepare_dir_file(dir);
> > +     if(!ret)
> > +             goto err_closedir;
>
> Maybe it should be "if (ret)"? Have you use this patch to generate some
> images?
>
> if(!ret)
>   ^   --- no space here
>
> > +
> > +     ret = erofs_prepare_inode_buffer(dir);
> > +     if(!ret)
> > +             goto err_closedir;
>
> ditto.
>
> > +
> >       if (IS_ROOT(dir))
> >               erofs_fixup_meta_blkaddr(dir);
> >
> > diff --git a/mkfs/main.c b/mkfs/main.c
> > index 1348587..f73eb10 100644
> > --- a/mkfs/main.c
> > +++ b/mkfs/main.c
> > @@ -212,6 +212,12 @@ int main(int argc, char **argv)
> >       erofs_show_config();
> >
> >       sb_bh = erofs_buffer_init();
> > +     if(IS_ERR(sb_bh)) {
> > +             err = PTR_ERR(sb_bh);
> > +             erofs_err("Failed to initialize super block buffer head :
> %s",
>
> erofs_err("Failed to initialize buffers: %s",
>
> Thanks,
> Gao Xiang
>
> > +                       erofs_strerror(err));
> > +             goto exit;
> > +     }
> >       err = erofs_bh_balloon(sb_bh, EROFS_SUPER_END);
> >       if (err < 0) {
> >               erofs_err("Failed to balloon erofs_super_block: %s",
> > @@ -254,5 +260,5 @@ exit:
> >                         erofs_strerror(err));
> >               return 1;
> >       }
> > -     return err;
> > +     return 0;
> >  }
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20190724/99f3fb74/attachment.htm>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-24  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-24  4:55 [PATCH v2] erofs-utils: Add missing error code handling Pratik Shinde
2019-07-24  7:06 ` Gao Xiang
2019-07-24  9:11   ` Pratik Shinde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox