Re: [U-Boot] [PATCH v2 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool

2019-01-31 Thread Chee, Tien Fong
On Thu, 2019-01-31 at 15:23 +0100, Marek Vasut wrote:
> On 1/31/19 1:42 PM, tien.fong.c...@intel.com wrote:
> > 
> > From: Tien Fong Chee 
> > 
> > Release cluster block immediately when no longer use would help to
> > reduce
> > 64KiB memory allocated to the memory pool.
> > 
> > Signed-off-by: Tien Fong Chee 
> > 
> > ---
> > 
> > changes for v2
> > - Assigned NULL to itr after free.
> > - Added NULL checking to itr, avoid freeing twice.
> > ---
> >  fs/fat/fat.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> > index 347787e..fa846ff 100644
> > --- a/fs/fat/fat.c
> > +++ b/fs/fat/fat.c
> > @@ -1152,12 +1152,21 @@ int file_fat_read_at(const char *filename,
> > loff_t pos, void *buffer,
> >     goto out_free_both;
> >  
> >     debug("reading %s at pos %llu\n", filename, pos);
> > -   ret = get_contents(&fsdata, itr->dent, pos, buffer,
> > maxsize, actread);
> > +
> > +   /* For saving default max clustersize memory allocated to
> > malloc pool */
> > +   dir_entry *dentptr = itr->dent;
> > +
> > +   free(itr);
> > +
> > +   itr = NULL;
> > +
> > +   ret = get_contents(&fsdata, dentptr, pos, buffer, maxsize,
> > actread);
> >  
> >  out_free_both:
> >     free(fsdata.fatbuf);
> >  out_free_itr:
> > -   free(itr);
> > +   if (itr)
> > +   free(itr);
> free(NULL) is valid, so you can drop the if conditional.
Noted.
> 
> > 
> >     return ret;
> >  }
> >  
> > 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool

2019-01-31 Thread Marek Vasut
On 1/31/19 1:42 PM, tien.fong.c...@intel.com wrote:
> From: Tien Fong Chee 
> 
> Release cluster block immediately when no longer use would help to reduce
> 64KiB memory allocated to the memory pool.
> 
> Signed-off-by: Tien Fong Chee 
> 
> ---
> 
> changes for v2
> - Assigned NULL to itr after free.
> - Added NULL checking to itr, avoid freeing twice.
> ---
>  fs/fat/fat.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index 347787e..fa846ff 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -1152,12 +1152,21 @@ int file_fat_read_at(const char *filename, loff_t 
> pos, void *buffer,
>   goto out_free_both;
>  
>   debug("reading %s at pos %llu\n", filename, pos);
> - ret = get_contents(&fsdata, itr->dent, pos, buffer, maxsize, actread);
> +
> + /* For saving default max clustersize memory allocated to malloc pool */
> + dir_entry *dentptr = itr->dent;
> +
> + free(itr);
> +
> + itr = NULL;
> +
> + ret = get_contents(&fsdata, dentptr, pos, buffer, maxsize, actread);
>  
>  out_free_both:
>   free(fsdata.fatbuf);
>  out_free_itr:
> - free(itr);
> + if (itr)
> + free(itr);

free(NULL) is valid, so you can drop the if conditional.

>   return ret;
>  }
>  
> 


-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Release cluster block immediately when no longer use would help to reduce
64KiB memory allocated to the memory pool.

Signed-off-by: Tien Fong Chee 

---

changes for v2
- Assigned NULL to itr after free.
- Added NULL checking to itr, avoid freeing twice.
---
 fs/fat/fat.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 347787e..fa846ff 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1152,12 +1152,21 @@ int file_fat_read_at(const char *filename, loff_t pos, 
void *buffer,
goto out_free_both;
 
debug("reading %s at pos %llu\n", filename, pos);
-   ret = get_contents(&fsdata, itr->dent, pos, buffer, maxsize, actread);
+
+   /* For saving default max clustersize memory allocated to malloc pool */
+   dir_entry *dentptr = itr->dent;
+
+   free(itr);
+
+   itr = NULL;
+
+   ret = get_contents(&fsdata, dentptr, pos, buffer, maxsize, actread);
 
 out_free_both:
free(fsdata.fatbuf);
 out_free_itr:
-   free(itr);
+   if (itr)
+   free(itr);
return ret;
 }
 
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot