Re: [PATCH v2 4/6] libmultipath: factor out code to get vpd page data

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

 



On Wed, 2020-11-04 at 00:54 -0600, Benjamin Marzinski wrote:
> A future patch will reuse the code to get the vpd page data, so
> factor
> it out from get_vpd_sgio().
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
> ---
>  libmultipath/discovery.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index a97d2998..95ddbbbd 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -1319,11 +1319,10 @@ get_vpd_sysfs (struct udev_device *parent,
> int pg, char * str, int maxlen)
>  	return len;
>  }
>  
> -int
> -get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
> +static int
> +fetch_vpd_page(int fd, int pg, unsigned char *buff)
>  {
> -	int len, buff_len;
> -	unsigned char buff[4096];
> +	int buff_len;
>  
>  	memset(buff, 0x0, 4096);

I don't know ... I think we shouldn't write any new functions making
assumptions about the size of buffers passed to them, even if the
caller is directly next to them in the code.

>  	if (sgio_get_vpd(buff, 4096, fd, pg) < 0) {
> @@ -1344,6 +1343,18 @@ get_vpd_sgio (int fd, int pg, int vend_id,
> char * str, int maxlen)
>  		condlog(3, "vpd pg%02x page truncated", pg);
>  		buff_len = 4096;
>  	}
> +	return buff_len;
> +}
> +
> +int
> +get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
> +{
> +	int len, buff_len;
> +	unsigned char buff[4096];
> +
> +	buff_len = fetch_vpd_page(fd, pg, buff);
> +	if (buff_len < 0)
> +		return buff_len;
>  	if (pg == 0x80)
>  		len = parse_vpd_pg80(buff, str, maxlen);
>  	else if (pg == 0x83)

-- 
Dr. Martin Wilck <mwilck@xxxxxxxx>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer



--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux