bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 14/17] ext2fs: refactor add a method for dupplicated code


From: Samuel Thibault
Subject: Re: [PATCH 14/17] ext2fs: refactor add a method for dupplicated code
Date: Sun, 23 Jan 2022 12:08:32 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Applied, thanks!

Etienne Brateau, le dim. 23 janv. 2022 05:17:12 +0100, a ecrit:
>   * xattr: introduce xattr_header_valid method
> ---
>  ext2fs/xattr.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/ext2fs/xattr.c b/ext2fs/xattr.c
> index 0c855616..45f7febe 100644
> --- a/ext2fs/xattr.c
> +++ b/ext2fs/xattr.c
> @@ -413,6 +413,16 @@ xattr_entry_replace (struct ext2_xattr_header *header,
>  
>  }
>  
> +/* Given a xattr header, return 1 if the header is a valid xattr header
> + * and 0 if the header is not valid.
> + */
> +static int
> +xattr_header_valid(struct ext2_xattr_header *header)
> +{
> +  return header->h_magic != htole32 (EXT2_XATTR_BLOCK_MAGIC)
> +    || header->h_blocks != htole32 (1);
> +}
> +
>  
>  /*
>   * Given a node, free extended attributes block associated with
> @@ -450,8 +460,7 @@ ext2_free_xattr_block (struct node *np)
>    block = disk_cache_block_ref (blkno);
>    header = EXT2_XATTR_HEADER (block);
>  
> -  if (header->h_magic != htole32 (EXT2_XATTR_BLOCK_MAGIC)
> -      || header->h_blocks != htole32 (1))
> +  if (xattr_header_valid(header))
>      {
>        ext2_warning ("Invalid extended attribute block.");
>        err = EIO;
> @@ -536,8 +545,7 @@ ext2_list_xattr (struct node *np, char *buffer, size_t 
> *len)
>    block = disk_cache_block_ref (blkno);
>  
>    header = EXT2_XATTR_HEADER (block);
> -  if (header->h_magic != htole32 (EXT2_XATTR_BLOCK_MAGIC)
> -      || header->h_blocks != htole32 (1))
> +  if (xattr_header_valid(header))
>      {
>        ext2_warning ("Invalid extended attribute block.");
>        err = EIO;
> @@ -611,8 +619,7 @@ ext2_get_xattr (struct node *np, const char *name, char 
> *value, size_t *len)
>    dino_deref (ei);
>  
>    header = EXT2_XATTR_HEADER (block);
> -  if (header->h_magic != htole32 (EXT2_XATTR_BLOCK_MAGIC)
> -      || header->h_blocks != htole32 (1))
> +  if (xattr_header_valid(header))
>      {
>        ext2_warning ("Invalid extended attribute block.");
>        err = EIO;
> @@ -724,8 +731,7 @@ ext2_set_xattr (struct node *np, const char *name, const 
> char *value,
>      {
>        block = disk_cache_block_ref (blkno);
>        header = EXT2_XATTR_HEADER (block);
> -      if (header->h_magic != htole32 (EXT2_XATTR_BLOCK_MAGIC)
> -          || header->h_blocks != htole32 (1))
> +      if (xattr_header_valid(header))
>          {
>            ext2_warning ("Invalid extended attribute block.");
>            err = EIO;
> -- 
> 2.34.1
> 
> 

-- 
Samuel
        /* Amuse the user in a SPARC fashion */
        if (err) printk(
KERN_CRIT "      _______________________________ \n"
KERN_CRIT "     < Your System ate a SPARC! Gah! >\n"
KERN_CRIT "      ------------------------------- \n"
KERN_CRIT "             \\   ^__^\n"
KERN_CRIT "              \\  (xx)\\_______\n"
KERN_CRIT "                 (__)\\       )\\/\\\n"
KERN_CRIT "                  U  ||----w |\n"
KERN_CRIT "                     ||     ||\n");
(From linux/arch/parisc/kernel/traps.c:die_if_kernel())



reply via email to

[Prev in Thread] Current Thread [Next in Thread]