From: Artem Bityutskiy <dedekind@infradead.org>
To: Timo Lindhorst <lindhors@linux.vnet.ibm.com>
Cc: MTD list <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] [MTD] UBI: Fix counting of ec value
Date: Mon, 12 Feb 2007 11:52:39 +0200 [thread overview]
Message-ID: <1171273959.17314.16.camel@sauron> (raw)
In-Reply-To: <200702121016.40516.lindhors@linux.vnet.ibm.com>
Hi Timo,
thanks for the patches. The comment-fixing one is fine - applied. This
one is fine in general, but i have questions.
On Mon, 2007-02-12 at 10:16 +0100, Timo Lindhorst wrote:
> static int sync_erase(const struct ubi_info *ubi, struct ubi_wl_entry *e,
> int torture)
> {
> - int err;
> + int err, ret;
> struct ubi_ec_hdr *ec_hdr;
> struct ubi_wl_info *wl = ubi->wl;
> - uint64_t ec = e->ec + 1;
> + uint64_t ec = e->ec;
>
> - dbg_wl("erase PEB %d, new EC %lld", e->pnum, (long long)ec);
> + dbg_wl("erase PEB %d, old EC %lld", e->pnum, (long long)ec);
>
> err = paranoid_check_ec(ubi, e->pnum, e->ec);
> if (unlikely(err > 0))
> return -EINVAL;
>
> + ec_hdr = ubi_zalloc_ec_hdr(ubi);
> + if (unlikely(!ec_hdr))
> + return -ENOMEM;
So why have you moved this memory allocation here?
> +
> + ret = err = ubi_io_sync_erase(ubi, e->pnum, torture);
> + if (unlikely(err < 0))
> + goto out_free;
> +
> + ec += ret;
What's the point in the new 'ret' variable? Why ec += err does not work?
> if (unlikely(ec > UBI_MAX_ERASECOUNTER)) {
> /*
> * Erase counter overflow. Upgrade UBI and use 64-bit
> * erase counters internally.
> */
> ubi_err("erase counter overflow at PEB %d, EC %d",
> - e->pnum, e->ec);
> + e->pnum, ec);
> return -EINVAL;
And now you do not free memory. Please do not move the allocation if it
is not really necessary.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
next prev parent reply other threads:[~2007-02-12 10:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-12 9:16 [PATCH] [MTD] UBI: Fix counting of ec value Timo Lindhorst
2007-02-12 9:52 ` Artem Bityutskiy [this message]
2007-02-12 10:48 ` Timo Lindhorst
2007-02-12 11:38 ` 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=1171273959.17314.16.camel@sauron \
--to=dedekind@infradead.org \
--cc=lindhors@linux.vnet.ibm.com \
--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 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.