Re: [PATCH] block: Fix the wrong format specifier

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

 



On 12/4/24 06:45, liujing wrote:
> Make a minor change to eliminate a static checker warning. The type
> of 'size' is unsigned int, so the correct format specifier should be
> %u instead of %d.
>
> Signed-off-by: liujing <liujing@xxxxxxxxxxxxxxxxxxxx>
>
> diff --git a/block/bio.c b/block/bio.c
> index ac4d77c88932..3a75de450799 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -89,7 +89,7 @@ static struct bio_slab *create_bio_slab(unsigned int size)
>   	if (!bslab)
>   		return NULL;
>   
> -	snprintf(bslab->name, sizeof(bslab->name), "bio-%d", size);
> +	snprintf(bslab->name, sizeof(bslab->name), "bio-%u", size);
>   	bslab->slab = kmem_cache_create(bslab->name, size,
>   			ARCH_KMALLOC_MINALIGN,
>   			SLAB_HWCACHE_ALIGN | SLAB_TYPESAFE_BY_RCU, NULL);

Indeed, looks good, but patch format looks little bit different ...

Reviewed-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>

-ck


static struct bio_slab *create_bio_slab(unsigned int size)
{
         struct bio_slab *bslab = kzalloc(sizeof(*bslab), GFP_KERNEL);

         if (!bslab)
                 return NULL;

         snprintf(bslab->name, sizeof(bslab->name), "bio-%d", size);
         bslab->slab = kmem_cache_create(bslab->name, size,
                         ARCH_KMALLOC_MINALIGN,
                         SLAB_HWCACHE_ALIGN | SLAB_TYPESAFE_BY_RCU, NULL);
         if (!bslab->slab)
                 goto fail_alloc_slab;

         bslab->slab_ref = 1;
         bslab->slab_size = size;

         if (!xa_err(xa_store(&bio_slabs, size, bslab, GFP_KERNEL)))
                 return bslab;

         kmem_cache_destroy(bslab->slab);

fail_alloc_slab:
         kfree(bslab);
         return NULL;
}




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux