These were found by Clang/Static Analyzer - Removed three dead increments - More importantly, removes an uninitialized value read. While the zeroing of struct cesr upfront is enough and matches other parts of the code, I also removed the writing of a zero value into the struct, as it is unneeded. If this is deemed a superfluous optimization, just leave those assignments in. see also: https://www.spoerlein.net/scan-build/2009-11-07-1/report-wzs4FL.html#EndPath https://www.spoerlein.net/scan-build/2009-11-07-1/report-apJ1ME.html#EndPath https://www.spoerlein.net/scan-build/2009-11-07-1/report-Driys4.html#EndPath https://www.spoerlein.net/scan-build/2009-11-07-1/report-4kHXS5.html#EndPath
Responsible Changed From-To: freebsd-bugs->uqs Assign my PRs to myself
Author: uqs Date: Wed Jun 2 09:34:41 2010 New Revision: 208730 URL: http://svn.freebsd.org/changeset/base/208730 Log: Zero struct before reading from it PR: 140384 Found by: clang static analyzer MFC after: 3 weeks Modified: head/bin/chio/chio.c Modified: head/bin/chio/chio.c ============================================================================== --- head/bin/chio/chio.c Wed Jun 2 08:43:18 2010 (r208729) +++ head/bin/chio/chio.c Wed Jun 2 09:34:41 2010 (r208730) @@ -1072,6 +1072,7 @@ find_element(char *voltag, uint16_t *et, /* Read in the changer slots */ if (cp.cp_nslots > 0) { + (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_ST; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_nslots; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
State Changed From-To: open->patched Important parts have been committed in r208730.
Author: uqs Date: Fri Jul 30 12:36:40 2010 New Revision: 210643 URL: http://svn.freebsd.org/changeset/base/210643 Log: MFC r208730: Zero struct before reading from it PR: 140384 Modified: stable/8/bin/chio/chio.c Directory Properties: stable/8/bin/chio/ (props changed) Changes in other areas also in this revision: Modified: stable/7/bin/chio/chio.c Directory Properties: stable/7/bin/chio/ (props changed) Modified: stable/8/bin/chio/chio.c ============================================================================== --- stable/8/bin/chio/chio.c Fri Jul 30 12:04:29 2010 (r210642) +++ stable/8/bin/chio/chio.c Fri Jul 30 12:36:40 2010 (r210643) @@ -1072,6 +1072,7 @@ find_element(char *voltag, uint16_t *et, /* Read in the changer slots */ if (cp.cp_nslots > 0) { + (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_ST; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_nslots; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Author: uqs Date: Fri Jul 30 12:36:40 2010 New Revision: 210643 URL: http://svn.freebsd.org/changeset/base/210643 Log: MFC r208730: Zero struct before reading from it PR: 140384 Modified: stable/7/bin/chio/chio.c Directory Properties: stable/7/bin/chio/ (props changed) Changes in other areas also in this revision: Modified: stable/8/bin/chio/chio.c Directory Properties: stable/8/bin/chio/ (props changed) Modified: stable/7/bin/chio/chio.c ============================================================================== --- stable/7/bin/chio/chio.c Fri Jul 30 12:04:29 2010 (r210642) +++ stable/7/bin/chio/chio.c Fri Jul 30 12:36:40 2010 (r210643) @@ -1072,6 +1072,7 @@ find_element(char *voltag, uint16_t *et, /* Read in the changer slots */ if (cp.cp_nslots > 0) { + (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_ST; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_nslots; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
State Changed From-To: patched->closed Merged to stable branches.