bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] src/sort.c: pipe_fork is always called with tries > 0


From: Kovarththanan Rajaratnam
Subject: [PATCH] src/sort.c: pipe_fork is always called with tries > 0
Date: Wed, 6 Jan 2010 09:36:04 +0100

clang detected the following false positive:

sort.c:906:11: warning: The left operand of '<' is a garbage value
  if (pid < 0)
      ~~~ ^

src/sort.c: Add an assert indicating that pipe_fork is always called with tries 
> 0. This allows clang to deduce that 'pid' will always be set/is valid.

Signed-off-by: Kovarththanan Rajaratnam <address@hidden>
---
 src/sort.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index 010930b..9c25723 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -874,6 +874,8 @@ pipe_fork (int pipefds[2], size_t tries)
   pid_t pid IF_LINT (= -1);
   struct cs_status cs;
 
+  assert(tries > 0);
+
   if (pipe (pipefds) < 0)
     return -1;
 
-- 
1.6.3.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]