1. Pypy
  2. Untitled project
  3. pypy

Commits

Amaury Forgeot d'Arc  committed 1a2ac55

Use signed number for array length, the binary search seems to use negative numbers.

  • Participants
  • Parent commits 5e8ec66
  • Branches py3k

Comments (0)

Files changed (1)

File pypy/module/_posixsubprocess/_posixsubprocess.c

View file
 
 /* Is fd found in the sorted Python Sequence? */
 static int
-_is_fd_in_sorted_fd_sequence(int fd, long *fd_sequence, size_t seq_len)
+_is_fd_in_sorted_fd_sequence(int fd, long *fd_sequence, ssize_t seq_len)
 {
     /* Binary search. */
-    size_t search_min = 0;
-    size_t search_max = seq_len - 1;
+    ssize_t search_min = 0;
+    ssize_t search_max = seq_len - 1;
     if (search_max < 0)
         return 0;
     do {
-        size_t middle = (search_min + search_max) / 2;
+        ssize_t middle = (search_min + search_max) / 2;
         long middle_fd = fd_sequence[middle];
         if (fd == middle_fd)
             return 1;
  */
 static void
 _close_fds_by_brute_force(int start_fd, int end_fd, long *py_fds_to_keep,
-			  size_t num_fds_to_keep)
+			  ssize_t num_fds_to_keep)
 {
-    size_t keep_seq_idx;
+    ssize_t keep_seq_idx;
     int fd_num;
     /* As py_fds_to_keep is sorted we can loop through the list closing
      * fds inbetween any in the keep list falling within our range. */
  */
 static void
 _close_open_fd_range_safe(int start_fd, int end_fd, long *py_fds_to_keep,
-			  size_t num_fds_to_keep)
+			  ssize_t num_fds_to_keep)
 {
     int fd_dir_fd;
     if (start_fd >= end_fd)
  */
 static void
 _close_open_fd_range_maybe_unsafe(int start_fd, int end_fd,
-                                  long *py_fds_to_keep, size_t num_fds_to_keep)
+                                  long *py_fds_to_keep, ssize_t num_fds_to_keep)
 {
     DIR *proc_fd_dir;
 #ifndef HAVE_DIRFD
            int close_fds, int restore_signals,
            int call_setsid,
            long *py_fds_to_keep,
-	   size_t num_fds_to_keep,
+	   ssize_t num_fds_to_keep,
            int (*preexec_fn)(void*),
            void *preexec_fn_arg)
 {