Commit 74d42bdb authored by Linus Torvalds's avatar Linus Torvalds
Browse files

fs/pipe: express 'pipe_empty()' in terms of 'pipe_occupancy()'



That's what 'pipe_full()' does, so it's more consistent. But more
importantly it gets the type limits right when the pipe head and tail
are no longer necessarily 'unsigned int'.

Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 848e0763
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -177,23 +177,23 @@ static inline bool pipe_has_watch_queue(const struct pipe_inode_info *pipe)
}

/**
 * pipe_empty - Return true if the pipe is empty
 * pipe_occupancy - Return number of slots used in the pipe
 * @head: The pipe ring head pointer
 * @tail: The pipe ring tail pointer
 */
static inline bool pipe_empty(unsigned int head, unsigned int tail)
static inline unsigned int pipe_occupancy(unsigned int head, unsigned int tail)
{
	return head == tail;
	return (pipe_index_t)(head - tail);
}

/**
 * pipe_occupancy - Return number of slots used in the pipe
 * pipe_empty - Return true if the pipe is empty
 * @head: The pipe ring head pointer
 * @tail: The pipe ring tail pointer
 */
static inline unsigned int pipe_occupancy(unsigned int head, unsigned int tail)
static inline bool pipe_empty(unsigned int head, unsigned int tail)
{
	return (pipe_index_t)(head - tail);
	return !pipe_occupancy(head, tail);
}

/**