[rtems commit] objectsetname.c: Fix always true condition ( Coverity ID 1063874)

Joel Sherril joel at rtems.org
Fri Nov 21 19:13:32 UTC 2014


Module:    rtems
Branch:    master
Commit:    ed4c5568c7b7dda50f7374b7e3d79e21c0ad8185
Changeset: http://git.rtems.org/rtems/commit/?id=ed4c5568c7b7dda50f7374b7e3d79e21c0ad8185

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Thu Nov 20 17:25:15 2014 -0600

objectsetname.c: Fix always true condition (Coverity ID 1063874)

Coverity spotted the comparison (0 <= length) which is always true.
Changed logic to address this.

---

 cpukit/score/src/objectsetname.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cpukit/score/src/objectsetname.c b/cpukit/score/src/objectsetname.c
index e405c8a..c699570 100644
--- a/cpukit/score/src/objectsetname.c
+++ b/cpukit/score/src/objectsetname.c
@@ -6,7 +6,7 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2009.
+ *  COPYRIGHT (c) 1989-2014.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -53,10 +53,10 @@ bool _Objects_Set_name(
 #endif
   {
     the_object->name.name_u32 =  _Objects_Build_name(
-      ((0 <= length) ? s[ 0 ] : ' '),
-      ((1 <  length) ? s[ 1 ] : ' '),
-      ((2 <  length) ? s[ 2 ] : ' '),
-      ((3 <  length) ? s[ 3 ] : ' ')
+      ((length)     ? s[ 0 ] : ' '),
+      ((length > 1) ? s[ 1 ] : ' '),
+      ((length > 2) ? s[ 2 ] : ' '),
+      ((length > 3) ? s[ 3 ] : ' ')
     );
 
   }




More information about the vc mailing list