FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 07-08-2010, 05:11 PM
"Brian C. Lane"
 
Default Handle 16 digit hex strings for ID_SERIAL_SHORT (#611554)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/08/2010 08:22 AM, David Cantrell wrote:
> Modification to udev_device_get_wwid() patch from Masahiro Matsuya
> <mmatsuya@redhat.com> to handle 16 digit hex strings for
> ID_SERIAL_SHORT.
> ---
> storage/udev.py | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/storage/udev.py b/storage/udev.py
> index 738cea0..f780c09 100644
> --- a/storage/udev.py
> +++ b/storage/udev.py
> @@ -267,10 +267,11 @@ def udev_device_get_wwid(udev_info):
> """ The WWID of a device is typically just its serial number, but with
> colons in the name to make it more readable. """
> serial = udev_device_get_serial(udev_info)
> + serial_len = len(serial)
>
> - if serial and len(serial) == 32:
> + if serial and (serial_len == 32 or serial_len == 16):
> retval = ""
> - for i in range(0, 16):
> + for i in range(0, (serial_len / 2)):
> retval += serial[i*2:i*2+2] + ":"
>
> return retval[0:-1]

It would be more readable to do:

for i in range(0, serial_len, 2):
retval += serial[i:i+2] + ":"

I'd also be tempted to generalize it to any even length instead of 16 or
32 just so that it doesn't need any more changes in the future.

- --
Brian C. Lane <bcl@redhat.com>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBTDYGyRF+jBaO/jp/AQJAgwf+Nxp5t47FNCk25VzRVsSLlSfyE/jUbqzm
v3a6nr3UEVuZUs+3i4H9f6mUE6KCn5NUNqDPvRsSC/1JSyCUSj8FSJEXumOAGowc
qwJ+CzhUaG6I1yvOqmtevM6vDH09sIH9byoTMwFurPpbX/O9XQfboXSe6sVVaAP0
2BBrsZmD9eqNq6OHu/D7p6S+hBg6jKlLQuKAWfgoALYTEsvUXXX0xzWOaz2dc72Y
dIUrotq2zvpmhgDofsSz59YPk9Sis+9yOalRs9CENhwXRlP7ke Njbt5xzpOkn3C5
n3+o/SpRVyCVkccvgTmNaVXVvb+8KhDf6xoKdkT4Kca6DQhFwWhk9A= =
=f/qi
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-08-2010, 05:27 PM
Chris Lumens
 
Default Handle 16 digit hex strings for ID_SERIAL_SHORT (#611554)

> I'd also be tempted to generalize it to any even length instead of 16 or
> 32 just so that it doesn't need any more changes in the future.

There's a reason for this length restriction that I do not remember.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 04:13 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org