Skip to content

Commit 74d42bd

Browse files
committed
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: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 848e076 commit 74d42bd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

include/linux/pipe_fs_i.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,23 @@ static inline bool pipe_has_watch_queue(const struct pipe_inode_info *pipe)
177177
}
178178

179179
/**
180-
* pipe_empty - Return true if the pipe is empty
180+
* pipe_occupancy - Return number of slots used in the pipe
181181
* @head: The pipe ring head pointer
182182
* @tail: The pipe ring tail pointer
183183
*/
184-
static inline bool pipe_empty(unsigned int head, unsigned int tail)
184+
static inline unsigned int pipe_occupancy(unsigned int head, unsigned int tail)
185185
{
186-
return head == tail;
186+
return (pipe_index_t)(head - tail);
187187
}
188188

189189
/**
190-
* pipe_occupancy - Return number of slots used in the pipe
190+
* pipe_empty - Return true if the pipe is empty
191191
* @head: The pipe ring head pointer
192192
* @tail: The pipe ring tail pointer
193193
*/
194-
static inline unsigned int pipe_occupancy(unsigned int head, unsigned int tail)
194+
static inline bool pipe_empty(unsigned int head, unsigned int tail)
195195
{
196-
return (pipe_index_t)(head - tail);
196+
return !pipe_occupancy(head, tail);
197197
}
198198

199199
/**

0 commit comments

Comments
 (0)