Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed 1a2ac55

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

Comments (0)

Files changed (1)

pypy/module/_posixsubprocess/_posixsubprocess.c

 
 /* 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)
 {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.