Re: [PATCH] jffs2: Don't add summary entry when MTD write fails
From: David Woodhouse
Date: Thu Feb 25 2016 - 06:36:05 EST
On Wed, 2015-11-11 at 21:27 +0100, Thomas Betker wrote:
>
> Âint jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ unsigned long count, loff_t to, size_t *retlen)
> Â{
> +ÂÂÂÂÂÂÂint ret;
> +
> +ÂÂÂÂÂÂÂret = mtd_writev(c->mtd, vecs, count, to, retlen);
> +
> ÂÂÂÂÂÂÂÂif (!jffs2_is_writebuffered(c)) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (jffs2_sum_active()) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint res;
> +
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (ret ||
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ *retlen != iov_length((struct iovec *) vecs, count))
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn ret;
> +
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂres = jffs2_sum_add_kvec(c, vecs, count, (uint32_t) to);
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (res) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn res;
OK... but perhaps we can dispense with the separate 'ret' and 'res'
variables and the rats nest of conditions, and do something like:
 Âint ret;
 Âret = mtd_writev(â);
 Âif (!ret && *retlen == iov_length(â) &&
   Â!jffs2_is_writebuffered(c) && jffs2_sum_active())Â
     ret = jffs2_sum_add_kvec(â);
 Â
 Âreturn ret;
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@xxxxxxxxx Intel Corporation
Attachment:
smime.p7s
Description: S/MIME cryptographic signature