Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 4.3.12-dev-1 compile warning on MacOS



Sorry for a _very_ late reply.

At 9:11 AM -0700 11.7.18, Bart Schaefer wrote:
>I can only conclude that long and long long are both 64 bits but that
>the compiler treats %ul as incompabible with the latter.

Yes.

The only workaround I can think of is to cast rlim_t to long 
(or unsigned long) as in a possible patch below.
This cast is safe because if sizeof(rlim_t) > sizeof(long) then
either RLIM_T_IS_QUAD_T or RLIM_T_IS_LONG_LONG should have been
defined.

Similar fix in zftp.c is also included.


Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.24
diff -u -r1.24 rlimits.c
--- Src/Builtins/rlimits.c	19 Jun 2011 00:10:34 -0000	1.24
+++ Src/Builtins/rlimits.c	31 Oct 2011 08:33:36 -0000
@@ -102,9 +102,9 @@
 	printf("%lld\n", val);
 #  else
 #   ifdef RLIM_T_IS_UNSIGNED
-	printf("%lu\n", val);
+	printf("%lu\n", (unsigned long)val);
 #   else
-	printf("%ld\n", val);
+	printf("%ld\n", (long)val);
 #   endif /* RLIM_T_IS_UNSIGNED */
 #  endif /* RLIM_T_IS_LONG_LONG */
 # endif /* RLIM_T_IS_QUAD_T */
@@ -123,9 +123,9 @@
 	printf("%lldus\n", val);
 #  else
 #   ifdef RLIM_T_IS_UNSIGNED
-	printf("%luus\n", val);
+	printf("%luus\n", (unsigned long)val);
 #   else
-	printf("%ldus\n", val);
+	printf("%ldus\n", (long)val);
 #   endif /* RLIM_T_IS_UNSIGNED */
 #  endif /* RLIM_T_IS_LONG_LONG */
 # endif /* RLIM_T_IS_QUAD_T */
@@ -139,9 +139,9 @@
 	printf("%lld\n", val);
 #  else
 #   ifdef RLIM_T_IS_UNSIGNED
-	printf("%lu\n", val);
+	printf("%lu\n", (unsigned long)val);
 #   else
-	printf("%ld\n", val);
+	printf("%ld\n", (long)val);
 #   endif /* RLIM_T_IS_UNSIGNED */
 #  endif /* RLIM_T_IS_LONG_LONG */
 # endif /* RLIM_T_IS_QUAD_T */
@@ -158,13 +158,13 @@
 	printf("%lldkB\n", val / 1024L);
 #  else
 #   ifdef RLIM_T_IS_UNSIGNED
-    printf("%luMB\n", val / (1024L * 1024L));
+    printf("%luMB\n", (unsigned long)(val / (1024L * 1024L)));
     else
-	printf("%lukB\n", val / 1024L);
+	printf("%lukB\n", (unsigned long)(val / 1024L));
 #   else
-    printf("%ldMB\n", val / (1024L * 1024L));
+    printf("%ldMB\n", (long)val / (1024L * 1024L));
     else
-	printf("%ldkB\n", val / 1024L);
+	printf("%ldkB\n", (long)val / 1024L);
 #   endif /* RLIM_T_IS_UNSIGNED */
 #  endif /* RLIM_T_IS_LONG_LONG */
 # endif /* RLIM_T_IS_QUAD_T */
@@ -398,9 +398,9 @@
 	printf("%lld\n", limit);
 #  else
 #   ifdef RLIM_T_IS_UNSIGNED
-	printf("%lu\n", limit);
+	printf("%lu\n", (unsigned long)limit);
 #   else
-	printf("%ld\n", limit);
+	printf("%ld\n", (long)limit);
 #   endif /* RLIM_T_IS_UNSIGNED */
 #  endif /* RLIM_T_IS_LONG_LONG */
 # endif /* RLIM_T_IS_QUAD_T */

Index: Src/Modules/zftp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zftp.c,v
retrieving revision 1.54
diff -u -r1.54 zftp.c
--- Src/Modules/zftp.c	13 May 2011 18:12:06 -0000	1.54
+++ Src/Modules/zftp.c	31 Oct 2011 08:36:40 -0000
@@ -2520,7 +2520,7 @@
 	printf("%s %s\n", output64(sz), mt);
 #else
 	DPUTS(sizeof(sz) > 4, "Shell compiled with wrong off_t size");
-	printf("%ld %s\n", sz, mt);
+	printf("%ld %s\n", (long)sz, mt);
 #endif
 	zsfree(mt);
 	if (dofd)




Messages sorted by: Reverse Date, Date, Thread, Author