diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-06-04 12:30:06 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-06-04 12:30:06 +0100 |
commit | f9159b97834ba4b4e42a07953a33866e7ac90dbd (patch) | |
tree | acc86d39f7285d1e50ab80c81ee8324d5a6bd8f4 /src | |
parent | a18460b385ae034830e4efbaaed7e0665c53ad9f (diff) | |
download | libpciaccess-f9159b97834ba4b4e42a07953a33866e7ac90dbd.tar.gz libpciaccess-f9159b97834ba4b4e42a07953a33866e7ac90dbd.tar.bz2 libpciaccess-f9159b97834ba4b4e42a07953a33866e7ac90dbd.zip |
linux: Only set errno after an error
errno is only valid after an error, and was being filled with a garbage
value upon eof.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/linux_sysfs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c index 1832ee7..bbd4dfa 100644 --- a/src/linux_sysfs.c +++ b/src/linux_sysfs.c @@ -387,7 +387,9 @@ pci_device_linux_sysfs_read( struct pci_device * dev, void * data, /* If zero bytes were read, then we assume it's the end of the * config file. */ - if ( bytes <= 0 ) { + if (bytes == 0) + break; + if ( bytes < 0 ) { err = errno; break; } @@ -445,7 +447,9 @@ pci_device_linux_sysfs_write( struct pci_device * dev, const void * data, /* If zero bytes were written, then we assume it's the end of the * config file. */ - if ( bytes <= 0 ) { + if ( bytes == 0 ) + break; + if ( bytes < 0 ) { err = errno; break; } |