Page MenuHomeFreeBSD

Fix enum warnings in ath_hal's ar9300
ClosedPublic

Authored by dim on Jul 31 2024, 7:44 PM.
Tags
None
Referenced Files
F97332759: D46201.diff
Sat, Sep 28, 5:22 PM
Unknown Object (File)
Fri, Sep 27, 2:25 AM
Unknown Object (File)
Sat, Sep 7, 6:03 PM
Unknown Object (File)
Mon, Sep 2, 8:41 PM
Unknown Object (File)
Aug 24 2024, 4:34 PM
Unknown Object (File)
Aug 17 2024, 11:29 AM
Unknown Object (File)
Aug 15 2024, 1:20 PM
Unknown Object (File)
Aug 13 2024, 6:49 AM
Subscribers

Details

Summary

This fixes a number of clang 19 warnings:

sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:709:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
  709 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
  148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
      |       ~~~ ^  ~~~~~~~~~~~~~~~~~~
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:745:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
  745 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
  148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
      |       ~~~ ^  ~~~~~~~~~~~~~~~~~~
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:781:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
  781 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
  148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
      |       ~~~ ^  ~~~~~~~~~~~~~~~~~~

The FBIN2FREQ() and FREQ2FBIN() macros in ar9300eep.h are invoked
in most places around the ath_hal code with a (effectively) boolean
second argument, corresponding to "is this 2GHz?". But in the code that
is warned about, the value HAL_FREQ_BAND_2GHZ is of a different
non-boolean type, HAL_FREQ_BAND.

Either the FBIN2FREQ() and FREQ2FBIN() macros can be left to use a
HAL_FREQ_BAND as a second argument, which would necessitate updating
all the call sites, or the macros can be changed to interpret the second
argument as a zero/nonzero value instead. The latter seems preferable,
since the above three instances are the only place where the macros get
invoked incorrectly with a HAL_FREQ_BAND second argument.

MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 58903
Build 55790: arc lint + arc unit

Event Timeline

dim requested review of this revision.Jul 31 2024, 7:44 PM

sys/dev/ath/ath_hal/ah_eeprom_v14.h has another copy of FREQ2FBIN which do not have the check but do treat the 2nd arg as boolean:
sys/dev/ath/ath_hal/ah_eeprom_v14.h:#define FREQ2FBIN(x,y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))

I do not care if we spell it as (y) or as (y != 0). Both work for me.

This revision is now accepted and ready to land.Aug 1 2024, 5:44 PM

can you add a comment above each macro just saying that != 0 is a check that it's HAL_FREQ_BAND_2GHZ? other than that, go ahead!

This revision was automatically updated to reflect the committed changes.