Discussion:
FreeBSD integer->errno
William Vining
2014-01-19 00:50:58 UTC
Permalink
Hi s48,

integer->errno (in scheme/posix/errno.scm, accessible from the
posix-errnos structure) fails on FreeBSD for any named errno at a
higher index than #{errno nodata} in the named-errno vector.

This happens because ENODATA, as well as ENOSTR, ENOSR, and ETIME are
not defined in FreeBSD. When s48 initializes the named-errnos vector
these four errnos have their os-number field set to #f, which leads to
the error in integer->errno.

The problem can be solved trivially by adding a guard to integer->errno:

(define (integer->errno num)
(let loop ((i 0))
(if (= i (vector-length named-errnos))
(get-unnamed-errno num)
(let* ((e (vector-ref named-errnos i))
(errno-number (named-errno-os-number e)))
(if (and errno-number (= num errno-number))
e
(loop (+ i 1)))))))

I'm new to scheme48, so I wanted to run this by the community for
input. If anybody has any thoughts or comments please let me know.
Also I'm not sure how the development process works WRT
proposing/reviewing/testing/comiting changes.

Cheers,
Will Vining
Michael Sperber
2014-01-19 08:46:55 UTC
Permalink
Post by William Vining
integer->errno (in scheme/posix/errno.scm, accessible from the
posix-errnos structure) fails on FreeBSD for any named errno at a
higher index than #{errno nodata} in the named-errno vector. [...]
The problem can be solved trivially by adding a guard to
integer->errno: [...]
Thanks!

I've pushed your fix.
Post by William Vining
I'm new to scheme48, so I wanted to run this by the community for
input. If anybody has any thoughts or comments please let me know.
Also I'm not sure how the development process works WRT
proposing/reviewing/testing/comiting changes.
What you did is fine. Submitting a patch or a Mercurial changeset would
make it even easier.
--
Regards,
Mike
Roderic Morris
2014-01-19 11:13:50 UTC
Permalink
Thanks Will!

Hi Mike, is there any chance of this making it into a minor release any
time soon? The bug breaks things pretty badly for BSD users of scsh, and
the only workaround I can think of (groggy at 6am) is to redefine it
within the project.

-Roderic
Post by Michael Sperber
Post by William Vining
integer->errno (in scheme/posix/errno.scm, accessible from the
posix-errnos structure) fails on FreeBSD for any named errno at a
higher index than #{errno nodata} in the named-errno vector. [...]
The problem can be solved trivially by adding a guard to
integer->errno: [...]
Thanks!
I've pushed your fix.
Post by William Vining
I'm new to scheme48, so I wanted to run this by the community for
input. If anybody has any thoughts or comments please let me know.
Also I'm not sure how the development process works WRT
proposing/reviewing/testing/comiting changes.
What you did is fine. Submitting a patch or a Mercurial changeset would
make it even easier.
--
Regards,
Mike
Loading...