Bug 210705

Summary: freebsd/sys/arm/mv/mv_common.c:2252]: (style) Suspicious condition
Product: Base System Reporter: David Binderman <dcb314>
Component: armAssignee: Oleksandr Tymoshenko <gonzo>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste, freebsd-arm, gonzo, zbb
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   

Description David Binderman 2016-06-29 19:32:10 UTC
freebsd/sys/arm/mv/mv_common.c:2252]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.

Source code is

        if (fdt_addrsize_cells(node, &addr_cells, &size_cells) == 0 &&
            (par_addr_cells = fdt_parent_addr_cells(node) <= 2)) {

Maybe better code

        if (fdt_addrsize_cells(node, &addr_cells, &size_cells) == 0 &&
            (par_addr_cells = fdt_parent_addr_cells(node)) <= 2) {
Comment 1 commit-hook freebsd_committer freebsd_triage 2019-01-16 21:14:23 UTC
A commit references this bug:

Author: gonzo
Date: Wed Jan 16 21:13:50 UTC 2019
New revision: 343104
URL: https://svnweb.freebsd.org/changeset/base/343104

Log:
  [mv] Fix invalid condition in fdt_fixup_ranges

  Add parentheses to perform assignment before comparison. The prior
  condition worked because fdt_parent_addr_cells returns 1 for the DTB
  on which fdt_fixup_ranges is called and accidentally par_addr_cells
  ends up to be set to the same value.

  PR:		210705
  Submitted by:	David Binderman <dcb314@hotmail.com>
  MFC after:	1 week

Changes:
  head/sys/arm/mv/mv_common.c
Comment 2 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-16 21:36:03 UTC
Fix committed. Thanks for the submission.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-02-03 09:15:08 UTC
A commit references this bug:

Author: gonzo
Date: Sun Feb  3 09:14:54 UTC 2019
New revision: 343710
URL: https://svnweb.freebsd.org/changeset/base/343710

Log:
  MFC r343028, r343104

  r343028:
  [mv_pci] Increase default PCI space size for mv_pci

  mv_pci driver reads PCI memory window layout from DTB data and if the
  data is incomplete falls back to default value. The value is too small
  to fit two PCI spaces for mwlwifi devices on WRT3200ACM so the resource
  allocation for them fails. Increase the default to 4Mb from 1Mb so
  the devices can be properly attached.

  r343104:
  [mv] Fix invalid condition in fdt_fixup_ranges

  Add parentheses to perform assignment before comparison. The prior
  condition worked because fdt_parent_addr_cells returns 1 for the DTB
  on which fdt_fixup_ranges is called and accidentally par_addr_cells
  ends up to be set to the same value.

  PR:		210705
  Submitted by:	David Binderman <dcb314@hotmail.com>

Changes:
_U  stable/12/
  stable/12/sys/arm/mv/mv_common.c
  stable/12/sys/arm/mv/mv_pci.c