From 453f44a8ac3100bb6c1f2fd33d92ac68a1bcca92 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 4 Jan 2016 18:16:45 +0100 Subject: macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blackbody.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/blackbody.c') diff --git a/src/blackbody.c b/src/blackbody.c index acd9afc..26ea52e 100644 --- a/src/blackbody.c +++ b/src/blackbody.c @@ -15,7 +15,7 @@ * along with this program. If not, see . */ #include "blackbody.h" -#include +#include "macros.h" #include #include @@ -120,14 +120,13 @@ get_colour(int fd, long int temp, double *r, double *g, double *b) * unencodeable. */ if (temp > HIGHEST) temp = HIGHEST; /* Things do not glow below 1000 K. Yes, fire is hot! */ - if (temp < LOWEST) return errno = EDOM, -1; + if (temp < LOWEST) t ((errno = EDOM)); /* Read table. */ offset = ((off_t)temp - LOWEST) / DELTA; offset *= (off_t)(5 * sizeof(double)); errno = 0; - if (pread(fd, values, sizeof(values), offset) < (ssize_t)sizeof(values)) - return -1; + xpread(fd, values, sizeof(values), offset); /* Get colour. */ if (temp % DELTA) @@ -144,5 +143,7 @@ get_colour(int fd, long int temp, double *r, double *g, double *b) *b = *b > 0.0 ? *b : 0.0; return 0; +fail: + return -1; } -- cgit v1.2.3-70-g09d2