bug#76623: [PATCH] filesys.c: Use scm_sendfile to copy files.

Ludovic Courtès <[email protected]> Fri, 28 Feb 2025 21:11:10 +0100
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hi,

Tomas Volf <[email protected]> skribis:

> Use scm_sendfile instead of read-write loop.  This moves the work into
> the kernel, improving performance.  This implements Ludovic's suggestion
> from bug 68504.
>
> * libguile/filesys.c (scm_copy_file2): Use scm_sendfile.

Nice!  I had to apply the changes below to appease GCC.

The patch LGTM but I realize there’s no real ‘copy-file’ test.  Not your
fault but would you mind adding one or two tests?

Thanks,
Ludo’.
(unnamed) (text/x-patch, 415 B)
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 00171dade..4f861ab35 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1306,10 +1306,9 @@ SCM_DEFINE (scm_copy_file2, "copy-file", 2, 0, 1,
 {
   char *c_oldfile, *c_newfile;
   int oldfd, newfd;
-  int n, rv;
+  int rv;
   SCM cow = sym_auto;
   int clone_res;
-  char buf[BUFSIZ];
   struct stat_or_stat64 oldstat;
 
   scm_dynwind_begin (0);