From 771b7ee43d15c24563557b102ec15f466ece13cb Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Fri, 23 Dec 2011 08:18:28 -0800
Subject: [PATCH] Fix more compiler warnings.

Linux-os.c:
o Fix warning about pointer to int warning.

lisp.c:
o Linux needs time.h to define tzset.
o Fix warning about unused result from getwcd.  If getcwd fails, we
  now just exit with a message because we can't find anything.
---
 src/lisp/Linux-os.c |  4 ++--
 src/lisp/lisp.c     | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/lisp/Linux-os.c b/src/lisp/Linux-os.c
index f4b96effe..20731e25d 100644
--- a/src/lisp/Linux-os.c
+++ b/src/lisp/Linux-os.c
@@ -65,7 +65,7 @@ int personality (unsigned long);
 #endif
 
 void
-check_personality(struct utsname *name, const char *argv[], const char *envp[])
+check_personality(struct utsname *name, char *const *argv, char *const *envp)
 {
     /* KLUDGE: Disable memory randomization on new Linux kernels
      * by setting a personality flag and re-executing. (We need
@@ -428,7 +428,7 @@ sigsegv_handler(HANDLER_ARGS)
 	tramp_signal = signal;
 	tramp_code = *code;
 	tramp_context = *context;
-	SC_PC(context) = sigsegv_handler_tramp;
+	SC_PC(context) = (unsigned long) sigsegv_handler_tramp;
 	return;
     }
 #endif
diff --git a/src/lisp/lisp.c b/src/lisp/lisp.c
index d719c8df7..2eb000f25 100644
--- a/src/lisp/lisp.c
+++ b/src/lisp/lisp.c
@@ -40,6 +40,10 @@
 #include <sys/utsname.h>
 #endif
 
+#if defined(__linux__)
+#include <time.h>
+#endif
+
 
 
 /* SIGINT handler that invokes the monitor. */
@@ -94,6 +98,16 @@ static char *cmucllib_search_list[] = {
     NULL
 };
 
+void
+getcwd_or_die(char* buf, size_t size)
+{
+    char *result = getcwd(buf, size);
+
+    if (result == NULL) {
+        perror("Cannot get cwd");
+        exit(1);
+    }
+}
 
 /* Set this to see how we're doing our search */
 int debug_lisp_search = FALSE;
@@ -154,7 +168,7 @@ default_cmucllib(const char *argv0arg)
 	 * append argv[0], after stripping off the executable name.
 	 */
 	cwd = malloc(FILENAME_MAX + strlen(argv0_dir) + 100);
-	getcwd(cwd, FILENAME_MAX);
+	getcwd_or_die(cwd, FILENAME_MAX);
 	strcat(cwd, "/");
 	if (*argv0_dir != '\0') {
 	    strcat(cwd, argv0_dir);
@@ -353,7 +367,7 @@ prepend_core_path(const char *lib, const char *corefile)
 	 * We have a relative path for the corefile.  Prepend our current
 	 * directory to get the full path.
 	 */
-	getcwd(cwd, FILENAME_MAX);
+	getcwd_or_die(cwd, FILENAME_MAX);
 	path = malloc(FILENAME_MAX + strlen(corefile) + 2);
 	strcpy(path, cwd);
 	strcat(path, "/");
-- 
GitLab