From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01C52C433EF for ; Tue, 12 Apr 2022 06:59:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 253988394A; Tue, 12 Apr 2022 08:59:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="IVm+iNLh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB0E683B74; Tue, 12 Apr 2022 08:59:45 +0200 (CEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9D773837E2 for ; Tue, 12 Apr 2022 08:59:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=miquel.raynal@bootlin.com Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B9EE860007; Tue, 12 Apr 2022 06:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1649746782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sycl8fKt/ifA2icm4ZQLdbAIAMkUyjdbV/GrXwZaa/k=; b=IVm+iNLh3vBczEj7TQg+fHEuIyowi/HnKJTqGyLi2d0yy5J63IBfknrAIBaZ6pr3bPZU55 TAsHH8+Qi9C+D2i5+p9hNQVNeTNaw0DEoIMx0b7RswpJbh119fpGIVO5Y4cDD74WvBKZGm aUM2DQlu2BWzj8WHKpuqVsHLoXLudOAWDB0frF3n6ZWmm91bmiLigrJlHwaCFdecf3Z2MK 6pYMZvWz/T78aZsoExohWV4XN7F41Gm6asbQBH3L0yJj+vJzmmKpbx6+ahZywXp+IZTTdJ jnihNGnaBHRFL3kIL5OOLkL6zIrxUBLdgDCDY2JtHGDDF8qOvVXQWoHAUJj6Lg== Date: Tue, 12 Apr 2022 08:59:40 +0200 From: Miquel Raynal To: Heinrich Schuchardt Cc: Joao Marcos Costa , Thomas Petazzoni , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] fs/squashfs: simplify sqfs_read() Message-ID: <20220412085940.55820b05@xps13> In-Reply-To: <20220411205444.50898-1-heinrich.schuchardt@canonical.com> References: <20220411205444.50898-1-heinrich.schuchardt@canonical.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Hi Heinrich, heinrich.schuchardt@canonical.com wrote on Mon, 11 Apr 2022 22:54:44 +0200: > * Don't check argument of free(). Free does this itself. > * Reduce scope of data_buffer. Remove duplicate free(). > * Avoid superfluous NULL assignment. >=20 > Signed-off-by: Heinrich Schuchardt Reviewed-by: Miquel Raynal > --- > fs/squashfs/sqfs.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) >=20 > diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c > index 5d9c52af80..b07c41e911 100644 > --- a/fs/squashfs/sqfs.c > +++ b/fs/squashfs/sqfs.c > @@ -1310,7 +1310,7 @@ static int sqfs_get_lregfile_info(struct squashfs_l= reg_inode *lreg, > int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, > loff_t *actread) > { > - char *dir =3D NULL, *fragment_block, *datablock =3D NULL, *data_buffer = =3D NULL; > + char *dir =3D NULL, *fragment_block, *datablock =3D NULL; > char *fragment =3D NULL, *file =3D NULL, *resolved, *data; > u64 start, n_blks, table_size, data_offset, table_offset, sparse_size; > int ret, j, i_number, datablk_count =3D 0; > @@ -1440,6 +1440,8 @@ int sqfs_read(const char *filename, void *buf, loff= _t offset, loff_t len, > } > =20 > for (j =3D 0; j < datablk_count; j++) { > + char *data_buffer; > + > start =3D data_offset / ctxt.cur_dev->blksz; > table_size =3D SQFS_BLOCK_SIZE(finfo.blk_sizes[j]); > table_offset =3D data_offset - (start * ctxt.cur_dev->blksz); > @@ -1501,9 +1503,7 @@ int sqfs_read(const char *filename, void *buf, loff= _t offset, loff_t len, > } > =20 > data_offset +=3D table_size; > - if (data_buffer) > - free(data_buffer); > - data_buffer =3D NULL; > + free(data_buffer); > if (*actread >=3D len) > break; > } > @@ -1563,10 +1563,7 @@ int sqfs_read(const char *filename, void *buf, lof= f_t offset, loff_t len, > =20 > out: > free(fragment); > - if (datablk_count) { > - free(data_buffer); > - free(datablock); > - } > + free(datablock); > free(file); > free(dir); > free(finfo.blk_sizes); Thanks, Miqu=C3=A8l