]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
fs/pipe: express 'pipe_empty()' in terms of 'pipe_occupancy()'
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Mar 2025 17:30:42 +0000 (07:30 -1000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Mar 2025 17:30:42 +0000 (07:30 -1000)
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>
include/linux/pipe_fs_i.h

index e572e6fc4f81ffa425076380e9814e7624f91294..4d0a2267e6efce6750e490207bfae0ec309e22f9 100644 (file)
@@ -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);
 }
 
 /**