public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind@infradead.org>
To: Corentin Chary <corentincj@iksaif.net>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/2] mkfs.ubifs: use libubi to format UBI volume
Date: Mon, 25 May 2009 10:58:43 +0300	[thread overview]
Message-ID: <1243238323.21646.64.camel@localhost.localdomain> (raw)
In-Reply-To: <1243232787-29108-3-git-send-email-corentincj@iksaif.net>

Few more things :-)

On Mon, 2009-05-25 at 08:26 +0200, Corentin Chary wrote:

> +/**
> + * open_ubi - open the UBI volume.
> + * @node: name of the UBI volume character device to fetch information about
> + *
> + * Returns %0 in case of success and %-1 in case of failure
> + */
> +static int open_ubi(const char *node)
> +{
> +	struct stat st;
> +
> +	if (stat(node, &st) || !S_ISCHR(st.st_mode))
> +		return -1;
> +
> +	ubi = libubi_open();
> +	if (!ubi)
> +		return -1;
> +	if (ubi_get_vol_info(ubi, node, &c->vi))
> +		return -1;
> +	if (ubi_get_dev_info1(ubi, c->vi.dev_num, &c->di))
> +		return -1;
> +	return 0;
> +}

I know this is nit-picking, but would be nicer to close libubi
in case of errors. Namely, in the second and third checks.
 
> +static int write_empty_leb(int lnum, int dtype)
>  {
> -	return write_leb(lnum, 0, leb_buf);
> +  return write_leb(lnum, 0, leb_buf, dtype);
>  }

You screwed the indentation here a bit.

>  /**
> @@ -790,8 +838,9 @@ static int do_pad(void *buf, int len)
>   * @node: node
>   * @len: node length
>   * @lnum: LEB number
> + * @dtype: expected data type
>   */
> -static int write_node(void *node, int len, int lnum)
> +static int write_node(void *node, int len, int lnum, int dtype)
>  {
>  	prepare_node(node, len);
>  
> @@ -799,7 +848,7 @@ static int write_node(void *node, int len, int lnum)
>  
>  	len = do_pad(leb_buf, len);
>  
> -	return write_leb(lnum, len, leb_buf);
> +	return write_leb(lnum, len, leb_buf, dtype);
>  }
>  
>  /**
> @@ -909,7 +958,7 @@ static int flush_nodes(void)
>  	if (!head_offs)
>  		return 0;
>  	len = do_pad(leb_buf, head_offs);
> -	err = write_leb(head_lnum, len, leb_buf);
> +	err = write_leb(head_lnum, len, leb_buf, UBI_UNKNOWN);
>  	if (err)
>  		return err;
>  	set_lprops(head_lnum, head_offs, head_flags);
> @@ -1581,14 +1630,20 @@ static int write_data(void)
>  {
>  	int err;
>  
> -	err = stat(root, &root_st);
> -	if (err)
> -		return sys_err_msg("bad root file-system directory '%s'", root);
> +	if (root) {
> +		err = stat(root, &root_st);
> +		if (err)
> +			return sys_err_msg("bad root file-system directory '%s'"
> +					   , root);

This is a little ugly. Could you please leave the comma at close to the
" symbol, and move "root" to the second line. This is just how the rest
of the code is written. Let's be consistent.

You are probably irritated by this, sorry. The whole code is not that
ideal in general, but while I'm on it, I tell about every single nit I
see :-)

> --- a/mkfs.ubifs/ubifs.h
> +++ b/mkfs.ubifs/ubifs.h
> @@ -366,6 +366,9 @@ struct ubifs_info
>  	int dead_wm;
>  	int dark_wm;
>  
> +	struct ubi_dev_info di;
> +	struct ubi_vol_info vi;

For consistency, you should probably comment these new fields.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

  reply	other threads:[~2009-05-25  7:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-25  6:26 [PATCH 0/2] mkfs.ubifs updates Corentin Chary
2009-05-25  6:26 ` [PATCH 1/2] mkfs.ubifs: remove duplicated code Corentin Chary
2009-05-25  6:26   ` [PATCH 2/2] mkfs.ubifs: use libubi to format UBI volume Corentin Chary
2009-05-25  7:58     ` Artem Bityutskiy [this message]
2009-05-25  8:23       ` Corentin Chary
2009-05-25  8:40         ` Artem Bityutskiy
2009-05-26 13:08           ` [PATCH] " Corentin Chary
2009-05-27 12:21             ` Artem Bityutskiy
2009-05-27 13:19               ` Corentin Chary
2009-05-27 13:21                 ` Artem Bityutskiy
2009-06-02  9:26                 ` Artem Bityutskiy
2009-05-27 11:29           ` [PATCH 2/2] " Corentin Chary
2009-05-27 11:33             ` Artem Bityutskiy
2009-05-25  7:49   ` [PATCH 1/2] mkfs.ubifs: remove duplicated code Artem Bityutskiy

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=1243238323.21646.64.camel@localhost.localdomain \
    --to=dedekind@infradead.org \
    --cc=corentincj@iksaif.net \
    --cc=linux-mtd@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox