Whamcloud - gitweb
LU-6081 lib: don't ignore the return of read() 54/13654/2
authorFrank Zago <fzago@cray.com>
Wed, 4 Feb 2015 21:31:31 +0000 (15:31 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 26 Mar 2015 00:12:10 +0000 (00:12 +0000)
The return of read() must be checked on some platform, possibly with a
recent version of glibc. Otherwise this gives an "ignoring return
value of 'read'" warning, which breaks the build. It happens on Ubuntu

Use the return of read() to the random entropy to fix the issue. This
doesn't do much for the entropy, but it doesn't hurt either.

Signed-off-by: frank zago <fzago@cray.com>
Change-Id: Iee7c1bce818e2f163db8f860acf8be075f5a543e
Reviewed-on: http://review.whamcloud.com/13654
Reviewed-by: Patrick Farrell <paf@cray.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>

index 329f0e4..efd9d3c 100644 (file)
@@ -67,9 +67,10 @@ static __attribute__ ((constructor)) void liblustreapi_init(void)
        fd = open("/dev/urandom", O_RDONLY | O_NOFOLLOW);
        if (fd >= 0) {
                unsigned int rnumber;
+               ssize_t ret;
-               (void)read(fd, &rnumber, sizeof(rnumber));
-               seed ^= rnumber;
+               ret = read(fd, &rnumber, sizeof(rnumber));
+               seed ^= rnumber ^ ret;