aboutsummaryrefslogtreecommitdiffstats
path: root/src/blackbody.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-04 18:16:45 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-04 18:16:45 +0100
commit453f44a8ac3100bb6c1f2fd33d92ac68a1bcca92 (patch)
tree9ff6c365f5b17a8ca3b05bb70245922618a5e94f /src/blackbody.c
parentinitialise partitions (diff)
downloadradharc-453f44a8ac3100bb6c1f2fd33d92ac68a1bcca92.tar.gz
radharc-453f44a8ac3100bb6c1f2fd33d92ac68a1bcca92.tar.bz2
radharc-453f44a8ac3100bb6c1f2fd33d92ac68a1bcca92.tar.xz
macros
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src/blackbody.c')
-rw-r--r--src/blackbody.c9
1 files changed, 5 insertions, 4 deletions
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 <http://www.gnu.org/licenses/>.
*/
#include "blackbody.h"
-#include <unistd.h>
+#include "macros.h"
#include <math.h>
#include <errno.h>
@@ -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;
}