Bug 203867 - usr/src/usr.bin/limits/limits.c:507: bad if test ?
Summary: usr/src/usr.bin/limits/limits.c:507: bad if test ?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-19 08:16 UTC by David Binderman
Modified: 2019-01-26 15:11 UTC (History)
2 users (show)

See Also:
avos: mfc-stable12+
avos: mfc-stable11+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2015-10-19 08:16:11 UTC
[usr/src/usr.bin/limits/limits.c:507]: (warning) Logical disjunction always evaluates to true: EXPR == 0 || EXPR.

  if (which_limits[rcswhich] == ANY || which_limits[rcswhich])
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2015-10-19 18:33:13 UTC
Yup. Definitely always true.
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2015-11-09 01:07:52 UTC
I think this will fix the issue properly, but I need to add more tests to ensure I'm not breaking something that works by accident:

$ svn diff limits.c
Index: limits.c
===================================================================
--- limits.c    (revision 290437)
+++ limits.c    (working copy)
@@ -504,7 +504,7 @@
 
     for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) {
        if (doall || num_limits == 0 || which_limits[rcswhich] != 0) {
-           if (which_limits[rcswhich] == ANY || which_limits[rcswhich])
+           if (which_limits[rcswhich] == ANY)
                which_limits[rcswhich] = type;
            if (shellparm[shelltype].lprm[rcswhich].pfx) {
                if (shellparm[shelltype].both && limits[rcswhich].rlim_cur == limits[rcswhich].rlim_max) {
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2017-11-05 20:47:20 UTC
Releasing bugs back to the pool.
Comment 4 Andriy Voskoboinyk freebsd_committer freebsd_triage 2019-01-26 15:11:38 UTC
Fixed in base r328212