Raymond Toy pushed to branch issue-130-file-author-in-c at cmucl / cmucl
Commits:
4d0d6006 by Raymond Toy at 2022-09-05T15:41:50-07:00
Only free buffer if it's not the stack buffer
- - - - -
1 changed file:
- src/lisp/os-common.c
Changes:
=====================================
src/lisp/os-common.c
=====================================
@@ -776,6 +776,9 @@ os_file_author(const char *path)
exit:
fprintf(stderr, "buffer, initial = %p %p\n", buffer, initial);
- free(buffer);
+ if (buffer != initial) {
+ free(buffer);
+ }
+
return result;
}
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/4d0d6006bd9b85dae184edf…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/4d0d6006bd9b85dae184edf…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-130-file-author-in-c at cmucl / cmucl
Commits:
6557e832 by Raymond Toy at 2022-09-05T14:45:35-07:00
Reindent according to cmucl style
- - - - -
08b38701 by Raymond Toy at 2022-09-05T14:50:40-07:00
Apply suggested change to test for zero length.
- - - - -
3a41b05c by Raymond Toy at 2022-09-05T14:54:16-07:00
Add a few comments
- - - - -
c4a9d0d8 by Raymond Toy at 2022-09-05T15:16:43-07:00
Add assert.h and replace ARRAYSIZE with sizeof
We need to include assert.h to define the `assert` macro that we use.
`ARRAYSIZE` needs to be replaced with `sizeof` to compute the size of
the `initial` buffer.
- - - - -
2 changed files:
- src/code/filesys.lisp
- src/lisp/os-common.c
Changes:
=====================================
src/code/filesys.lisp
=====================================
@@ -1078,7 +1078,7 @@ optionally keeping some of the most recent old versions."
;; unix-namestring converts "." to "". Convert it back to
;; "." so we can stat the current directory. (Perhaps
;; that's a bug in unix-namestring?)
- (when (string= name "")
+ (when (zerop (length name))
(setf name "."))
(let (author)
(unwind-protect
=====================================
src/lisp/os-common.c
=====================================
@@ -5,6 +5,7 @@
*/
+#include <assert.h>
#include <errno.h>
#include <math.h>
#include <netdb.h>
@@ -738,31 +739,43 @@ os_file_author(const char *path)
if (stat(path, &sb) != 0) {
return NULL;
}
+
result = NULL;
buffer = initial;
- size = ARRAYSIZE(initial);
- assert(sysconf(_SC_GETPW_R_SIZE_MAX) <= 16384));
+ size = sizeof(initial) / sizeof(initial[0]);
+
+ /*
+ * Assume a buffer of size 16384 is enough to for getpwuid_r to do
+ * it's thing.
+ */
+ assert(sysconf(_SC_GETPW_R_SIZE_MAX) <= 16384);
+
+ /*
+ * Keep trying with larger buffers until a maximum is reached.
+ */
while (size <= 16384) {
switch (getpwuid_r(sb.st_uid, &pwd, buffer, size, &ppwd)) {
- case 0:
- /* Success, though we might not have a matching entry */
- result = (ppwd == NULL) ? NULL : strdup(pwd.pw_name);
- goto exit;
- case ERANGE:
- /* Buffer is too small, double its size and try again */
- size *= 2;
- obuffer = (buffer == initial) ? NULL : buffer;
- if ((buffer = realloc(obuffer, size)) == NULL) {
- free(obuffer);
- goto exit;
- }
- continue;
- default:
- /* All other errors */
- goto exit;
+ case 0:
+ /* Success, though we might not have a matching entry */
+ result = (ppwd == NULL) ? NULL : strdup(pwd.pw_name);
+ goto exit;
+ case ERANGE:
+ /* Buffer is too small, double its size and try again */
+ size *= 2;
+ obuffer = (buffer == initial) ? NULL : buffer;
+ if ((buffer = realloc(obuffer, size)) == NULL) {
+ free(obuffer);
+ goto exit;
+ }
+ continue;
+ default:
+ /* All other errors */
+ goto exit;
}
}
exit:
+ fprintf(stderr, "buffer, initial = %p %p\n", buffer, initial);
+
free(buffer);
return result;
}
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/518ef95922f48ff2e29087…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/518ef95922f48ff2e29087…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-130-file-author-in-c at cmucl / cmucl
Commits:
344f246c by Carl S. Shapiro at 2022-09-05T04:55:48+00:00
Apply 1 suggestion(s) to 1 file(s)
- - - - -
1 changed file:
- src/lisp/os-common.c
Changes:
=====================================
src/lisp/os-common.c
=====================================
@@ -9,7 +9,6 @@
#include <math.h>
#include <netdb.h>
#include <pwd.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/344f246c2bc4dd290e45f9d…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/344f246c2bc4dd290e45f9d…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-130-file-author-in-c at cmucl / cmucl
Commits:
8a90499a by Carl S. Shapiro at 2022-09-05T04:52:30+00:00
Apply 1 suggestion(s) to 1 file(s)
- - - - -
1 changed file:
- src/code/filesys.lisp
Changes:
=====================================
src/code/filesys.lisp
=====================================
@@ -1061,29 +1061,6 @@ optionally keeping some of the most recent old versions."
;;; File-Author -- Public
;;;
-#+nil
-(defun file-author (file)
- "Returns the file author as a string, or nil if the author cannot be
- determined. Signals an error of type file-error if file doesn't exist,
- or file is a wild pathname."
- (if (wild-pathname-p file)
- (error 'simple-file-error
- :pathname file
- :format-control (intl:gettext "Bad place for a wild pathname."))
- (let ((name (unix-namestring (merge-pathnames file) t)))
- (unless name
- (error 'simple-file-error
- :pathname file
- :format-control (intl:gettext "~S doesn't exist.")
- :format-arguments (list file)))
- (multiple-value-bind (winp dev ino mode nlink uid)
- (unix:unix-stat name)
- (declare (ignore dev ino mode nlink))
- (when winp
- (let ((user-info (unix:unix-getpwuid uid)))
- (when user-info
- (unix:user-info-name user-info))))))))
-
(defun file-author (file)
"Returns the file author as a string, or nil if the author cannot be
determined. Signals an error of type file-error if file doesn't exist,
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/8a90499aa2f4c569d8d32da…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/8a90499aa2f4c569d8d32da…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-132-ansi-test-rename-files at cmucl / cmucl
Commits:
41147e45 by Raymond Toy at 2022-09-03T21:46:04-07:00
Oops. Look for unexpected successes/failures
We were grep'ing for 'No unexpected' successes or failures. We really
should be looking for unexpected successes or failures.
- - - - -
1 changed file:
- .gitlab-ci.yml
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -80,7 +80,7 @@ linux:ansi-test:
script:
- cd ansi-test
- make LISP="../dist/bin/lisp -batch -noinit -nositeinit"
- - grep -a 'No unexpected \(successes\|failures\)' test.out
+ - grep -a 'unexpected \(successes\|failures\)' test.out
linux:benchmark:
stage: benchmark
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/41147e45c35af0c6d947e99…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/41147e45c35af0c6d947e99…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-132-ansi-test-rename-files at cmucl / cmucl
Commits:
c0e48e6c by Raymond Toy at 2022-09-03T21:21:49-07:00
Used grep -a to find unexpected changes
Without -a, grep doesn't find any changes, making the test pass. Use
-a to treat the file as text (which is mostly is, except for unicode
characters/strings) so that we can find if there unexpected successes
or failures.
- - - - -
1 changed file:
- .gitlab-ci.yml
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -80,7 +80,7 @@ linux:ansi-test:
script:
- cd ansi-test
- make LISP="../dist/bin/lisp -batch -noinit -nositeinit"
- - grep 'No unexpected \(successes\|failures\)' test.out
+ - grep -a 'No unexpected \(successes\|failures\)' test.out
linux:benchmark:
stage: benchmark
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c0e48e6c63680ca24ff3358…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c0e48e6c63680ca24ff3358…
You're receiving this email because of your account on gitlab.common-lisp.net.