Bug 170397 - [ath] [patch] Uninitialized variables in ah_eeprom_9287.c
Summary: [ath] [patch] Uninitialized variables in ah_eeprom_9287.c
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-wireless (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-05 21:20 UTC by Dimitry Andric
Modified: 2014-06-07 05:29 UTC (History)
0 users

See Also:


Attachments
file.diff (821 bytes, patch)
2012-08-05 21:20 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2012-08-05 21:20:02 UTC
I'm busy with importing a new clang snapshot into head.  This version
has a bunch of interesting new warnings, and I got the following one
during building of ath:

  sys/dev/ath/ath_hal/ah_eeprom_9287.c:307:6: error: variable 'magic' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
          if (ah->ah_eepromdata == NULL) {
              ^~~~~~~~~~~~~~~~~~~~~~~~~
  sys/dev/ath/ath_hal/ah_eeprom_9287.c:316:6: note: uninitialized use occurs here
          if (magic != AR5416_EEPROM_MAGIC) {
              ^~~~~
  sys/dev/ath/ath_hal/ah_eeprom_9287.c:307:2: note: remove the 'if' if its condition is always true
          if (ah->ah_eepromdata == NULL) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  sys/dev/ath/ath_hal/ah_eeprom_9287.c:295:27: note: initialize the variable 'magic' to silence this warning
          uint16_t *eep_data, magic;
                                   ^
                                    = 0

It's because if ah->ah_eepromdata is non-null, magic just contains
garbage, and is then still checked against AR5416_EEPROM_MAGIC.  If the
comment above ("Don't check magic if we're supplied with an EEPROM
block") applies, then I suggest to move the checking block inside the
previous if, as in the attached patch.

Fix: Patch attached with submission follows:
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-08-06 02:30:13 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-wireless

Over to maintainer(s).
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2014-06-03 20:21:50 UTC
Fixed in r239704.