On 2018/10/12 6:20, Sotirios-Efstathios Maneas wrote:
> The following patch adds a few missing statements related to error checking.
> 
> Signed-off-by: Sotirios-Efstathios Maneas <sman...@cs.toronto.edu>
> ---
>  mkfs/f2fs_format.c       | 10 ++++++++--
>  mkfs/f2fs_format_utils.c |  5 +++++
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index 9b0a0d1..a2685cb 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -991,12 +991,16 @@ static int f2fs_write_super_block(void)
>       u_int8_t *zero_buff;
>  
>       zero_buff = calloc(F2FS_BLKSIZE, 1);
> +     if (zero_buff == NULL) {

I think it will be good to keep the coding style:

if (!zero_buff)

> +             MSG(1, "\tError: Calloc Failed for super_blk_zero_buf!!!\n");
> +             return -1;
> +     }
>  
>       memcpy(zero_buff + F2FS_SUPER_OFFSET, sb, sizeof(*sb));
>       DBG(1, "\tWriting super block, at offset 0x%08x\n", 0);
>       for (index = 0; index < 2; index++) {
>               if (dev_write_block(zero_buff, index)) {
> -                     MSG(1, "\tError: While while writing supe_blk "
> +                     MSG(1, "\tError: While while writing super_blk "

This typo should be fixed in another patch.

>                                       "on disk!!! index : %d\n", index);
>                       free(zero_buff);
>                       return -1;
> @@ -1021,8 +1025,10 @@ static int f2fs_discard_obsolete_dnode(void)
>               return 0;
>  
>       raw_node = calloc(sizeof(struct f2fs_node), 1);
> -     if (!raw_node)
> +     if (raw_node == NULL) {

Coding style.

> +             MSG(1, "\tError: Calloc Failed for discard_raw_node!!!\n");
>               return -1;
> +     }
>  
>       /* avoid power-off-recovery based on roll-forward policy */
>       offset = get_sb(main_blkaddr);
> diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
> index bf9ffbd..36b363a 100644
> --- a/mkfs/f2fs_format_utils.c
> +++ b/mkfs/f2fs_format_utils.c
> @@ -51,6 +51,11 @@ static int trim_device(int i)
>       int fd = dev->fd;
>  
>       stat_buf = malloc(sizeof(struct stat));
> +     if (stat_buf == NULL) {

Ditto.

How about fixing all error handling of calloc/malloc from differnet .c
files in one patch?

Thanks,

> +             MSG(1, "\tError: Malloc Failed for trim_stat_buf!!!\n");
> +             return -1;
> +     }
> +
>       if (fstat(fd, stat_buf) < 0 ) {
>               MSG(1, "\tError: Failed to get the device stat!!!\n");
>               free(stat_buf);
> 



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to