]> xenbits.xensource.com Git - libvirt.git/commit
nodedev_udev: Refactor udevGetDeviceType
authorOsier Yang <jyang@redhat.com>
Mon, 3 Jun 2013 10:05:31 +0000 (18:05 +0800)
committerOsier Yang <jyang@redhat.com>
Tue, 18 Jun 2013 08:32:14 +0000 (16:32 +0800)
commit1aa0ba3cef61679561206e18bb449f5b0df6166d
treed435d577b888188692bd1c09df6881fafbbd5aa8
parentc4a4603de5b02daa37274c3a5ff299aa50eca12a
nodedev_udev: Refactor udevGetDeviceType

Checking if the "devtype" is NULL along with each "if" statements
is bad. It wastes the performance, and also not good for reading.
And also when the "devtype" is NULL, the logic is also not clear.

This reorgnizes the logic of with "if...else" and a bunch of "else if".

Other changes:
   * Change the function style.
   * Remove the useless debug statement.
   * Get rid of the goto
   * New helper udevDeviceHasProperty to simplify the logic for checking
     if a property is existing for the device.
   * Add comment to clarify "PCI devices don't set the DEVTYPE property"
   * s/sysfs path/sysfs name/, as udev_device_get_sysname returns the
     name instead of the full path. E.g. "sg0"
   * Refactor the comment for setting VIR_NODE_DEV_CAP_NET cap type
     a bit.
src/node_device/node_device_udev.c