Skip to contentSkip to conversation

do we want negative file descriptors?

PATCH New Rolf Eike Beer 1 participant 1 message Sep 8, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do we want negative file descriptors?

As far as I can see it does not make much sense to have negative fds (which are in fact indexes for an array), so we can declare them unsigned. Or not? (If yes, this one avoids some compiler warnings with gcc 3.3)

Eike

include/linux/sched.h +3 -3
@@ -172,9 +172,9 @@
 struct files_struct {
 	atomic_t count;
 	rwlock_t file_lock;	/* Protects all the below members.  Nests inside tsk->alloc_lock */
-	int max_fds;
-	int max_fdset;
-	int next_fd;
+	unsigned int max_fds;
+	unsigned int max_fdset;
+	unsigned int next_fd;
 	struct file ** fd;	/* current fd array */
 	fd_set *close_on_exec;
 	fd_set *open_fds;
fs/file.c +4 -2
@@ -57,7 +57,8 @@
 int expand_fd_array(struct files_struct *files, int nr)
 {
 	struct file **new_fds;
-	int error, nfds;
+	int error;
+	unsigned int nfds;
 
 	
 	error = -EMFILE;
@@ -166,7 +167,8 @@
 int expand_fdset(struct files_struct *files, int nr)
 {
 	fd_set *new_openset = 0, *new_execset = 0;
-	int error, nfds = 0;
+	int error;
+	unsigned int nfds = 0;
 
 	error = -EMFILE;
 	if (files->max_fdset >= NR_OPEN || nr >= NR_OPEN)