Re: [PATCH] Staging: gasket: Use temporaries to reduce line length.

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

 



On Mon, 2019-09-09 at 22:28 +0200, Sandro Volery wrote:
> Using temporaries for gasket_page_table entries to remove scnprintf()
> statements and reduce line length, as suggested by Joe Perches. Thanks!

nak.  Slow down.  You broke the code.

Please be _way_ more careful and verify for yourself
the code you submit _before_ you submit it.

compile/test/verify, twice if necessary.

You also should have cc'd me on this patch.

> diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c
[]
> @@ -524,29 +526,25 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr,
>  	}
>  
>  	type = (enum sysfs_attribute_type)gasket_attr->data.attr_type;
> +	gpt = gasket_dev->page_table[0];
>  	switch (type) {
>  	case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE:
> -		ret = scnprintf(buf, PAGE_SIZE, "%u\n",
> -				gasket_page_table_num_entries(
> -					gasket_dev->page_table[0]));
> +		val = gasket_page_table_num_simple_entries(gpt);

You likely duplicated this line via copy/paste.
This should be:
		val = gasket_page_table_num_entries(gpt);

>  		break;
>  	case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE:
> -		ret = scnprintf(buf, PAGE_SIZE, "%u\n",
> -				gasket_page_table_num_simple_entries(
> -					gasket_dev->page_table[0]));
> +		val = gasket_page_table_num_simple_entries(gpt);

 		break;
>  	case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES:
> -		ret = scnprintf(buf, PAGE_SIZE, "%u\n",
> -				gasket_page_table_num_active_pages(
> -					gasket_dev->page_table[0]));
> +		val = gasket_page_table_num_active_pages(gpt);
>  		break;
>  	default:
>  		dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
>  			attr->attr.name);
>  		ret = 0;
> -		break;
> +		goto exit;
>  	}
> -
> +	ret = scnprintf(buf, PAGE_SIZE, "%u\n", val);
> +exit:
>  	gasket_sysfs_put_attr(device, gasket_attr);
>  	gasket_sysfs_put_device_data(device, gasket_dev);
>  	return ret;

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux