Re: [Chicken-hackers] [PATCH] Introduce XDG directories

2018-11-24 Thread Peter Bex
On Thu, Aug 09, 2018 at 11:52:49AM +0200, ko...@upyum.com wrote:
> This patch is about using the XDG spec for configuration and cache
> directories (XDG_CONFIG_HOME and XDG_CACHE_HOME
> environment variables).

Hi all,

I just pushed this patch.  Thanks to everyone involved, and also thanks
for waiting it out for 5.0 to be released.  I noticed the patch did not
update the Manual, so I've taken the liberty of updating that.

Cheers,
Peter


signature.asc
Description: PGP signature
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Fix segfault in get-environment-variable and three C compiler warnings

2018-11-24 Thread Peter Bex
Hi all,

Moritz was compiling CHICKEN with gcc 7 (or perhaps a newer libc?) that
gave warnings like "null argument where it was not expected".  The
attached patch fixes those warnings, and I also noticed that if you
call get-environment-variable with #f as an argument, you would get a
segmentation fault.

I noticed that the other two places; file-link and set-root-directory!
already explicitly check the argument(s) for being strings.  The patch
is the smallest possible change to get rid of the compiler warnings and
also fix the segfault, but perhaps we want to remove those checks from
posixunix.scm, given that they're strictly redundant.  Or, we might
add such a check to library.scm because the error message is a bit
better when it includes the procedure name, and none of these procedures
should be very performance-sensitive anyway.

Cheers,
Peter
From 76a255ebcd910d758b45e665f6ea6a31139b27ac Mon Sep 17 00:00:00 2001
From: Peter Bex 
Date: Sat, 24 Nov 2018 12:30:08 +0100
Subject: [PATCH] Change definition of "link", "chroot" and "C_getenv" from
 c-string to nonnull-c-string to fix C compiler warnings

In file-link and set-root-directory! we already checked the argument
for being a string.  In get-environment we did not do that, which
meant #f would be passed to getenv() directly, causing a segfault.
---
 NEWS  | 7 +++
 library.scm   | 2 +-
 posixunix.scm | 4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 18eefd7f..5eb7c803 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+5.0.1
+
+- Core libraries
+  - Fix get-environment from (chicken process-context) to raise an
+ error when passed #f instead of segfaulting.
+
+
 5.0.0
 
 - Runtime system
diff --git a/library.scm b/library.scm
index 72d32150..d11bd7f5 100644
--- a/library.scm
+++ b/library.scm
@@ -5971,7 +5971,7 @@ static C_word C_fcall C_setenv(C_word x, C_word y) {
 ;;; Environment access:
 
 (define get-environment-variable
-  (foreign-lambda c-string "C_getenv" c-string))
+  (foreign-lambda c-string "C_getenv" nonnull-c-string))
 
 (define (set-environment-variable! var val)
   (##sys#check-string var 'set-environment-variable!)
diff --git a/posixunix.scm b/posixunix.scm
index e569ce97..a85f9dce 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -771,7 +771,7 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime)
 	(##sys#read-symbolic-link fname 'read-symbolic-link
 
 (set! chicken.file.posix#file-link
-  (let ([link (foreign-lambda int "link" c-string c-string)])
+  (let ((link (foreign-lambda int "link" nonnull-c-string nonnull-c-string)))
 (lambda (old new)
   (##sys#check-string old 'file-link)
   (##sys#check-string new 'file-link)
@@ -1284,7 +1284,7 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime)
 ;;; chroot:
 
 (set! chicken.process-context.posix#set-root-directory!
-  (let ([chroot (foreign-lambda int "chroot" c-string)])
+  (let ((chroot (foreign-lambda int "chroot" nonnull-c-string)))
 (lambda (dir)
   (##sys#check-string dir 'set-root-directory!)
   (when (fx< (chroot dir) 0)
-- 
2.11.0



signature.asc
Description: PGP signature
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers