[PATCH] add missing errno.h to lots of files

Hi,

radiance 3.5.0 will not build out of the box on my system (linux system
with glibc version 2.3.1 and gcc version 3.2.2). The problem is that
errno.h is not always #include'ed in every file that uses the global errno
variable. I'm surprised one can get away with this on any system but I
guess some C compilers assume extern int for all unresolved references?
Who knows. Anyway... the following patch adds errno.h where it seems to
be needed and gets radiance building fairly cleanly on my system.

This touches LOTS of files and probably doesn't add the #include's in ways
that make the maintainer(s) of those files happy (blank lines, etc.).
Also, radiance has a bit of a header-file spaghetti thing going on so it's
hard to tell what is actually including what. In the end I got sick of
adding one "#incude <errno.h>" at a time and testing with a rebuild so I
just grepped for files that reference errno but don't have errno.h. I did
try to decide if they might get errno.h through some other header file but
only checked this as far as my own patience could tolerate. SOOO.... this
patch might add a few that aren't really needed.

Good luck, and thanks all for a very fun piece of software!

              -Kipp

diff -uNr ray-orig/src/cal/ev.c ray/src/cal/ev.c
--- ray-orig/src/cal/ev.c 2003-02-21 19:07:20.000000000 -0700
+++ ray/src/cal/ev.c 2003-10-05 00:04:09.000000000 -0600
@@ -8,6 +8,7 @@
  */

#include <stdio.h>
+#include <errno.h>

#include "calcomp.h"

diff -uNr ray-orig/src/gen/mkillum2.c ray/src/gen/mkillum2.c
--- ray-orig/src/gen/mkillum2.c 2003-02-21 19:07:24.000000000 -0700
+++ ray/src/gen/mkillum2.c 2003-10-05 00:07:34.000000000 -0600
@@ -5,6 +5,7 @@
  * Routines to do the actual calculation for mkillum
  */

+#include <errno.h>
#include "mkillum.h"

#include "face.h"
diff -uNr ray-orig/src/gen/mkillum.c ray/src/gen/mkillum.c
--- ray-orig/src/gen/mkillum.c 2003-03-11 12:29:05.000000000 -0700
+++ ray/src/gen/mkillum.c 2003-10-05 00:06:23.000000000 -0600
@@ -8,7 +8,7 @@
#include "mkillum.h"

#include <signal.h>

···

-
+#include <errno.h>
#include <ctype.h>

         /* default parameters */
diff -uNr ray-orig/src/hd/holofile.c ray/src/hd/holofile.c
--- ray-orig/src/hd/holofile.c 2003-02-21 19:07:24.000000000 -0700
+++ ray/src/hd/holofile.c 2003-10-05 00:08:22.000000000 -0600
@@ -7,6 +7,7 @@
  * 9/30/97 GWLarson
  */

+#include <errno.h>
#include "holo.h"

#ifndef CACHESIZE
diff -uNr ray-orig/src/hd/rhdisp.c ray/src/hd/rhdisp.c
--- ray-orig/src/hd/rhdisp.c 2003-02-21 19:07:24.000000000 -0700
+++ ray/src/hd/rhdisp.c 2003-10-05 00:08:37.000000000 -0600
@@ -10,6 +10,7 @@
#include "rhdriver.h"
#include "selcall.h"
#include <ctype.h>
+#include <errno.h>

#ifndef VIEWHISTLEN
#define VIEWHISTLEN 4 /* number of remembered views */
diff -uNr ray-orig/src/hd/rholo2l.c ray/src/hd/rholo2l.c
--- ray-orig/src/hd/rholo2l.c 2003-02-21 19:07:25.000000000 -0700
+++ ray/src/hd/rholo2l.c 2003-10-05 00:08:49.000000000 -0600
@@ -9,6 +9,7 @@
#include "random.h"
#include "paths.h"
#include "selcall.h"
+#include <errno.h>
#include <signal.h>
#include <sys/time.h>

diff -uNr ray-orig/src/hd/rholo4.c ray/src/hd/rholo4.c
--- ray-orig/src/hd/rholo4.c 2003-02-21 19:07:25.000000000 -0700
+++ ray/src/hd/rholo4.c 2003-10-05 00:09:02.000000000 -0600
@@ -7,6 +7,7 @@

#include "rholo.h"
#include "rhdisp.h"
+#include <errno.h>
#include <sys/uio.h>

#ifndef HDSUF
diff -uNr ray-orig/src/px/tiff/contrib/mfs/mfs_file.c ray/src/px/tiff/contrib/mfs/mfs_file.c
--- ray-orig/src/px/tiff/contrib/mfs/mfs_file.c 1997-08-29 16:56:40.000000000 -0600
+++ ray/src/px/tiff/contrib/mfs/mfs_file.c 2003-10-05 00:09:37.000000000 -0600
@@ -44,6 +44,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>

/*
--------------------------------------------------------------------------------
diff -uNr ray-orig/src/rt/aniso.c ray/src/rt/aniso.c
--- ray-orig/src/rt/aniso.c 2003-03-12 10:26:58.000000000 -0700
+++ ray/src/rt/aniso.c 2003-10-05 00:10:13.000000000 -0600
@@ -5,6 +5,7 @@
  * Shading functions for anisotropic materials.
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/m_brdf.c ray/src/rt/m_brdf.c
--- ray-orig/src/rt/m_brdf.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/m_brdf.c 2003-10-05 00:10:37.000000000 -0600
@@ -5,6 +5,7 @@
  * Shading for materials with arbitrary BRDF's
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/m_direct.c ray/src/rt/m_direct.c
--- ray-orig/src/rt/m_direct.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/m_direct.c 2003-10-05 00:10:47.000000000 -0600
@@ -6,6 +6,7 @@
  * their associated virtual light sources
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/mx_data.c ray/src/rt/mx_data.c
--- ray-orig/src/rt/mx_data.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/mx_data.c 2003-10-05 00:11:01.000000000 -0600
@@ -5,6 +5,7 @@
  * mx_data.c - routine for stored mixtures.
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/mx_func.c ray/src/rt/mx_func.c
--- ray-orig/src/rt/mx_func.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/mx_func.c 2003-10-05 00:11:10.000000000 -0600
@@ -5,6 +5,7 @@
  * mx_func.c - routine for mixture functions.
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/p_data.c ray/src/rt/p_data.c
--- ray-orig/src/rt/p_data.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/p_data.c 2003-10-05 00:11:24.000000000 -0600
@@ -5,6 +5,7 @@
  * p_data.c - routine for stored patterns.
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/p_func.c ray/src/rt/p_func.c
--- ray-orig/src/rt/p_func.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/p_func.c 2003-10-05 00:11:32.000000000 -0600
@@ -5,6 +5,7 @@
  * p_func.c - routine for procedural patterns.
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/raypcalls.c ray/src/rt/raypcalls.c
--- ray-orig/src/rt/raypcalls.c 2003-02-24 19:47:23.000000000 -0700
+++ ray/src/rt/raypcalls.c 2003-10-05 00:11:48.000000000 -0600
@@ -7,6 +7,7 @@
  * External symbols declared in ray.h
  */

+#include <errno.h>
#include "copyright.h"

/*
diff -uNr ray-orig/src/rt/rpict.c ray/src/rt/rpict.c
--- ray-orig/src/rt/rpict.c 2003-03-10 10:26:26.000000000 -0700
+++ ray/src/rt/rpict.c 2003-10-05 00:12:08.000000000 -0600
@@ -9,6 +9,7 @@

#include "ray.h"

+#include <errno.h>
#include <sys/types.h>

#ifndef NIX
diff -uNr ray-orig/src/rt/rpmain.c ray/src/rt/rpmain.c
--- ray-orig/src/rt/rpmain.c 2003-02-24 19:47:23.000000000 -0700
+++ ray/src/rt/rpmain.c 2003-10-05 00:12:29.000000000 -0600
@@ -17,6 +17,7 @@

#include "paths.h"

+#include <errno.h>
#include <sys/types.h>

#include <signal.h>
diff -uNr ray-orig/src/rt/rtmain.c ray/src/rt/rtmain.c
--- ray-orig/src/rt/rtmain.c 2003-02-24 19:47:23.000000000 -0700
+++ ray/src/rt/rtmain.c 2003-10-05 00:12:42.000000000 -0600
@@ -17,6 +17,7 @@

#include "paths.h"

+#include <errno.h>
#include <sys/types.h>

#include <signal.h>
diff -uNr ray-orig/src/rt/rview.c ray/src/rt/rview.c
--- ray-orig/src/rt/rview.c 2003-02-24 19:47:23.000000000 -0700
+++ ray/src/rt/rview.c 2003-10-05 00:12:53.000000000 -0600
@@ -13,6 +13,7 @@

#include "rpaint.h"

+#include <errno.h>
#include <signal.h>

#include <ctype.h>
diff -uNr ray-orig/src/rt/rvmain.c ray/src/rt/rvmain.c
--- ray-orig/src/rt/rvmain.c 2003-02-24 19:47:23.000000000 -0700
+++ ray/src/rt/rvmain.c 2003-10-05 00:13:08.000000000 -0600
@@ -17,6 +17,7 @@

#include "paths.h"

+#include <errno.h>
#include <signal.h>

#include "view.h"
diff -uNr ray-orig/src/rt/t_data.c ray/src/rt/t_data.c
--- ray-orig/src/rt/t_data.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/t_data.c 2003-10-05 00:13:26.000000000 -0600
@@ -5,6 +5,7 @@
  * t_data.c - routine for stored textures
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/rt/t_func.c ray/src/rt/t_func.c
--- ray-orig/src/rt/t_func.c 2003-03-05 09:16:53.000000000 -0700
+++ ray/src/rt/t_func.c 2003-10-05 00:13:35.000000000 -0600
@@ -5,6 +5,7 @@
  * t_func.c - routine for procedural textures.
  */

+#include <errno.h>
#include "copyright.h"

#include "ray.h"
diff -uNr ray-orig/src/util/ranimate.c ray/src/util/ranimate.c
--- ray-orig/src/util/ranimate.c 2003-02-24 19:47:24.000000000 -0700
+++ ray/src/util/ranimate.c 2003-10-05 00:13:46.000000000 -0600
@@ -16,6 +16,7 @@
#include "copyright.h"

#include "standard.h"
+#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include "view.h"
diff -uNr ray-orig/src/util/rpiece.c ray/src/util/rpiece.c
--- ray-orig/src/util/rpiece.c 2003-02-21 19:07:30.000000000 -0700
+++ ray/src/util/rpiece.c 2003-10-05 00:13:59.000000000 -0600
@@ -5,6 +5,7 @@
  * Generate sections of a picture.
  */
  
+#include <errno.h>
#include "standard.h"

#ifndef F_SETLKW

Hi Kipp,

Can you tell us which compiles were giving you complaints, exactly? I just did a run-through of the HEAD distribution and couldn't find anyplace where errno is referenced that doesn't include <errno.h> either directly, or indirectly via "standard.h", "rtio.h" or "rtprocess.h".

I bet that some of these corrections were made subsequent to the official 3.5 release. We have posted this message before, but it bears repeating. If you wish to offer a patch, please offer a patch to the current HEAD release rather than to an earlier release. Last night's HEAD release may always be found at the download link on www.radiance-online.org.

Thanks!
-Greg

···

From: Kipp C Cannon <[email protected]>
Date: Tue Oct 21, 2003 7:00:37 PM US/Pacific

Hi,

radiance 3.5.0 will not build out of the box on my system (linux system
with glibc version 2.3.1 and gcc version 3.2.2). The problem is that
errno.h is not always #include'ed in every file that uses the global errno
variable. I'm surprised one can get away with this on any system but I
guess some C compilers assume extern int for all unresolved references?
Who knows. Anyway... the following patch adds errno.h where it seems to
be needed and gets radiance building fairly cleanly on my system.

This touches LOTS of files and probably doesn't add the #include's in ways
that make the maintainer(s) of those files happy (blank lines, etc.).
Also, radiance has a bit of a header-file spaghetti thing going on so it's
hard to tell what is actually including what. In the end I got sick of
adding one "#incude <errno.h>" at a time and testing with a rebuild so I
just grepped for files that reference errno but don't have errno.h. I did
try to decide if they might get errno.h through some other header file but
only checked this as far as my own patience could tolerate. SOOO.... this
patch might add a few that aren't really needed.

Good luck, and thanks all for a very fun piece of software!

              -Kipp

Hi Kipp,

Hi.

Can you tell us which compiles were giving you complaints, exactly? I
just did a run-through of the HEAD distribution and couldn't find
anyplace where errno is referenced that doesn't include <errno.h>
either directly, or indirectly via "standard.h", "rtio.h" or
"rtprocess.h".

Sure. It's the "last official release": rad3R5. And, no, you're right I
haven't tried compiling the HEAD release.

I bet that some of these corrections were made subsequent to the
official 3.5 release. We have posted this message before, but it bears
repeating. If you wish to offer a patch, please offer a patch to the
current HEAD release rather than to an earlier release. Last night's
HEAD release may always be found at the download link on
www.radiance-online.org.

Yeah, OK. I'll download it and give today's HEAD a try.

How far away is a new official release? Even if the problem is fixed, I
think most users, like me, are somewhat uncomfortable running something
labeled "experimental" and really uncomfortable running a random nightly
build.

              -Kipp

···

On Tue, 21 Oct 2003, Greg Ward wrote:

From: Kipp C Cannon <[email protected]>
Date: Tue Oct 21, 2003 8:33:05 PM US/Pacific

How far away is a new official release? Even if the problem is fixed, I
think most users, like me, are somewhat uncomfortable running something
labeled "experimental" and really uncomfortable running a random nightly
build.

Well, if all you want is the official release, then why don't you download the binaries as opposed to rebuilding it yourself? The "experimental" version is a lot more reliable than the official release, because immediately after the official release we found a whole bunch of build problems and other bugs that showed up when people started compiling it on various systems. Unfortunately, this is often the case with "public works" software like Radiance -- we simply don't have the resources to test it out on all sorts of machines prior to making a release.

At one time, we would offer a "patched official release" that fixed the major bugs we would find immediately following a new release, but with the current setup offering continuous updates, we thought this would be superfluous. We probably should think about having a more traditional "patch" branch and "development" branch, but the extra administrative effort required seemed unnecessary as most of the changes we make are either limited to one or two programs or are bug fixes that should go into a patch release, anyway.

-Greg

> From: Kipp C Cannon <[email protected]>
> Date: Tue Oct 21, 2003 8:33:05 PM US/Pacific
>
> How far away is a new official release? Even if the problem is fixed,
> I
> think most users, like me, are somewhat uncomfortable running something
> labeled "experimental" and really uncomfortable running a random
> nightly
> build.

Well, if all you want is the official release, then why don't you
download the binaries as opposed to rebuilding it yourself?

Pride, suspicion, superstition, who knows. :-). No, seriously though, I
package it up into an RPM to make upgrades easier and it's convenient to
do that from the source. Besides, in the past its always been a really
nice clean build. In any case, there's no reason the source shouldn't be
buildable. Particularly not for this reason.

The
"experimental" version is a lot more reliable than the official
release, because immediately after the official release we found a
whole bunch of build problems and other bugs that showed up when people
started compiling it on various systems.

[snip]

At one time, we would offer a "patched official release" that fixed the
major bugs we would find immediately following a new release, but with
the current setup offering continuous updates, we thought this would be
superfluous.

Ahhh... I see. Yes, building used to involve downloading the source and
the most recent patch. I had assumed this had not changed and, since
there are no patches yet, that 3R5 is the most recent version.

We probably should think about having a more traditional
"patch" branch and "development" branch, but the extra administrative
effort required seemed unnecessary as most of the changes we make are
either limited to one or two programs or are bug fixes that should go
into a patch release, anyway.

Well that makes it sound like all that needs to be done is change the
wording on the web site from "experimental" to, I don't know, maybe
something like "pre-release". Something that still sounds like this is a
thing in flux but also suggests to people that they should give it a try
if they are hitting a bug. Less bleeding-edge. I think most open
development projects are pretty fast and loose with their "daily
snapshots" but if the radiance team keeps a tight lid on the condition of
theirs then it would be good to somehow make this more clear to users so
they feel more comfortable giving it a go.

              -Kipp

···

On Tue, 21 Oct 2003, Greg Ward wrote:

Hi,

OK. I gave today's HEAD (2003-10-20) a try and the errno problem has
disappeared. Great!

              -Kipp

···

On Tue, 21 Oct 2003, Kipp C Cannon wrote:

On Tue, 21 Oct 2003, Greg Ward wrote:

> Hi Kipp,

Hi.

> Can you tell us which compiles were giving you complaints, exactly? I
> just did a run-through of the HEAD distribution and couldn't find
> anyplace where errno is referenced that doesn't include <errno.h>
> either directly, or indirectly via "standard.h", "rtio.h" or
> "rtprocess.h".

Sure. It's the "last official release": rad3R5. And, no, you're right I
haven't tried compiling the HEAD release.

> I bet that some of these corrections were made subsequent to the
> official 3.5 release. We have posted this message before, but it bears
> repeating. If you wish to offer a patch, please offer a patch to the
> current HEAD release rather than to an earlier release. Last night's
> HEAD release may always be found at the download link on
> www.radiance-online.org.

Yeah, OK. I'll download it and give today's HEAD a try.

How far away is a new official release? Even if the problem is fixed, I
think most users, like me, are somewhat uncomfortable running something
labeled "experimental" and really uncomfortable running a random nightly
build.

              -Kipp