lib: explicitly cast long to int to fix clang warnings
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 Nov 2015 18:18:21 +0000 (13:18 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 9 Feb 2016 19:41:46 +0000 (14:41 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/file.nit
lib/core/math.nit
lib/core/text/abstract_text.nit
lib/ios/app.nit

index f54901e..66b81aa 100644 (file)
@@ -187,7 +187,7 @@ class FileReader
        end
 
        private fun native_poll_in(fd: Int): Int `{
-               struct pollfd fds = {fd, POLLIN, 0};
+               struct pollfd fds = {(int)fd, POLLIN, 0};
                return poll(&fds, 1, 0);
        `}
 end
@@ -292,7 +292,7 @@ redef class Int
        #
        # NOTE: The `mode` specified must be compatible with the one used in the file descriptor.
        private fun fd_to_stream(mode: NativeString): NativeFile `{
-               return fdopen(self, mode);
+               return fdopen((int)self, mode);
        `}
 end
 
@@ -1414,8 +1414,8 @@ private extern class NativeFile `{ FILE* `}
        fun flush: Int `{ return fflush(self); `}
 
        # Used to specify how the buffering will be handled for the current stream.
-       fun set_buffering_type(buf_length: Int, mode: Int): Int `{
-               return setvbuf(self, NULL, mode, buf_length);
+       fun set_buffering_type(buf_length, mode: Int): Int `{
+               return setvbuf(self, NULL, (int)mode, buf_length);
        `}
 
        new io_open_read(path: NativeString) `{ return fopen(path, "r"); `}
@@ -1499,15 +1499,14 @@ redef class Sys
                int first_polled_fd = -1;
                int result;
 
-               in_len = Array_of_Int_length( in_fds );
-               out_len = Array_of_Int_length( out_fds );
+               in_len = (int)Array_of_Int_length( in_fds );
+               out_len = (int)Array_of_Int_length( out_fds );
                total_len = in_len + out_len;
                c_fds = malloc( sizeof(struct pollfd) * total_len );
 
                /* input streams */
                for ( i=0; i<in_len; i ++ ) {
-                       int fd;
-                       fd = Array_of_Int__index( in_fds, i );
+                       int fd = (int)Array_of_Int__index( in_fds, i );
 
                        c_fds[i].fd = fd;
                        c_fds[i].events = POLLIN;
@@ -1515,8 +1514,7 @@ redef class Sys
 
                /* output streams */
                for ( i=0; i<out_len; i ++ ) {
-                       int fd;
-                       fd = Array_of_Int__index( out_fds, i );
+                       int fd = (int)Array_of_Int__index( out_fds, i );
 
                        c_fds[i].fd = fd;
                        c_fds[i].events = POLLOUT;
index 62cd544..bdd7daa 100644 (file)
@@ -545,9 +545,9 @@ fun pi: Float do return 3.14159265
 # assert 10.rand == a
 # assert 100.rand == b
 # ~~~~
-fun srand_from(x: Int) `{ nit_rand_seeded = 1; nit_rand_seed = x; `}
+fun srand_from(x: Int) `{ nit_rand_seeded = 1; nit_rand_seed = (unsigned int)x; `}
 
 # Reinitialize the pseudo-random generator used by the method `rand` and other.
 # This method is automatically invoked at the begin of the program, so usually, there is no need to manually invoke it.
 # The only exception is in conjunction with `srand_from` to reset the pseudo-random generator.
-fun srand `{ nit_rand_seeded = 0; srand(time(NULL)); `}
+fun srand `{ nit_rand_seeded = 0; srand((unsigned int)time(NULL)); `}
index 4770977..58a1c20 100644 (file)
@@ -1554,7 +1554,7 @@ end
 redef class Int
 
        # Wrapper of strerror C function
-       private fun strerror_ext: NativeString `{ return strerror(self); `}
+       private fun strerror_ext: NativeString `{ return strerror((int)self); `}
 
        # Returns a string describing error number
        fun strerror: String do return strerror_ext.to_s
index c90c05b..1dc461d 100644 (file)
@@ -102,7 +102,7 @@ redef class App
        # so we need to add it back. That's why Nit's `args` is smaller than in C.
        private fun register_args(program_name: NativeString, argc: Int,
        argv: Sequence[String]) import Sequence[String].[], String.to_cstring in "ObjC" `{
-               app_nit_ios_argc = argc+1;
+               app_nit_ios_argc = (int)(argc+1);
 
                // TODO copy or pin the strings when needed
                app_nit_ios_argv = malloc(argc * sizeof(char*));