Bug 140384 - [patch] chio(8) fix some harmless uninitialized argument warnings
Summary: [patch] chio(8) fix some harmless uninitialized argument warnings
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 7.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Ulrich Spörlein
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-08 11:00 UTC by Ulrich Spoerlein
Modified: 2010-07-30 13:48 UTC (History)
0 users

See Also:


Attachments
file.diff (2.61 KB, patch)
2009-11-08 11:00 UTC, Ulrich Spoerlein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Spoerlein 2009-11-08 11:00:07 UTC
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
Comment 1 Ulrich Spörlein freebsd_committer freebsd_triage 2010-02-04 07:19:28 UTC
Responsible Changed
From-To: freebsd-bugs->uqs

Assign my PRs to myself
Comment 2 dfilter service freebsd_committer freebsd_triage 2010-06-02 10:34:56 UTC
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"
Comment 3 Ulrich Spörlein freebsd_committer freebsd_triage 2010-06-02 10:36:02 UTC
State Changed
From-To: open->patched

Important parts have been committed in r208730.
Comment 4 dfilter service freebsd_committer freebsd_triage 2010-07-30 13:39:38 UTC
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"
Comment 5 dfilter service freebsd_committer freebsd_triage 2010-07-30 13:39:48 UTC
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"
Comment 6 Ulrich Spörlein freebsd_committer freebsd_triage 2010-07-30 13:48:51 UTC
State Changed
From-To: patched->closed

Merged to stable branches.